-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
building out dataloader properly for training
- Loading branch information
1 parent
3b79930
commit 3df1b97
Showing
2 changed files
with
173 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
def create_strips_and_labels(self, image, img_name): | ||
# Convert image to numpy array for processing | ||
image_array = np.array(image) | ||
height, width = image_array.shape[:2] | ||
strip_height = 32 # Define the height of each strip | ||
strips = [] | ||
labels = [] | ||
|
||
# Get bounding boxes for the current image | ||
bboxes = self.bbox_data.get( | ||
os.path.basename(img_name), [] | ||
) # Get bounding boxes for the image | ||
|
||
# Create strips from the image | ||
for y in range(0, height, strip_height): | ||
strip = image_array[y : y + strip_height, :] # Get a strip | ||
strips.append(strip) | ||
|
||
# Check if any bounding box intersects with the current strip | ||
label = self.check_intersection(bboxes, y, strip_height) | ||
labels.append(label) | ||
|
||
return ( | ||
strips, | ||
labels, | ||
) # Return the list of strips and their corresponding labels |