Spaces:
Running
on
Zero
Running
on
Zero
Martin Tomov
commited on
classification_boxes and segmentation update
Browse files
app.py
CHANGED
@@ -148,8 +148,13 @@ def extract_and_paste_insect(original_image: np.ndarray, detection: DetectionRes
|
|
148 |
x_offset, y_offset = xmin, ymin
|
149 |
x_end, y_end = x_offset + insect.shape[1], y_offset + insect.shape[0]
|
150 |
|
151 |
-
#
|
152 |
-
|
|
|
|
|
|
|
|
|
|
|
153 |
|
154 |
def create_yellow_background_with_insects(image: np.ndarray, detections: List[DetectionResult]) -> np.ndarray:
|
155 |
yellow_background = np.full((image.shape[0], image.shape[1], 3), (0, 255, 255), dtype=np.uint8)
|
|
|
148 |
x_offset, y_offset = xmin, ymin
|
149 |
x_end, y_end = x_offset + insect.shape[1], y_offset + insect.shape[0]
|
150 |
|
151 |
+
# Ensure the background area under the bounding box is yellow
|
152 |
+
yellow_area = np.full_like(insect_crop, (0, 255, 255), dtype=np.uint8)
|
153 |
+
background[y_offset:y_end, x_offset:x_end] = yellow_area
|
154 |
+
|
155 |
+
# Combine the insect with the yellow background
|
156 |
+
combined = cv2.add(background[y_offset:y_end, x_offset:x_end], insect)
|
157 |
+
background[y_offset:y_end, x_offset:x_end] = combined
|
158 |
|
159 |
def create_yellow_background_with_insects(image: np.ndarray, detections: List[DetectionResult]) -> np.ndarray:
|
160 |
yellow_background = np.full((image.shape[0], image.shape[1], 3), (0, 255, 255), dtype=np.uint8)
|