Spaces:
Runtime error
Runtime error
Martin Tomov
commited on
refine insect extraction
Browse files
app.py
CHANGED
|
@@ -149,7 +149,8 @@ def extract_and_paste_insect(original_image: np.ndarray, detection: DetectionRes
|
|
| 149 |
x_offset, y_offset = xmin, ymin
|
| 150 |
x_end, y_end = x_offset + insect.shape[1], y_offset + insect.shape[0]
|
| 151 |
|
| 152 |
-
background[y_offset:y_end, x_offset:x_end]
|
|
|
|
| 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) # BGR for yellow
|
|
|
|
| 149 |
x_offset, y_offset = xmin, ymin
|
| 150 |
x_end, y_end = x_offset + insect.shape[1], y_offset + insect.shape[0]
|
| 151 |
|
| 152 |
+
insect_area = background[y_offset:y_end, x_offset:x_end]
|
| 153 |
+
insect_area[mask_crop == 1] = insect[mask_crop == 1]
|
| 154 |
|
| 155 |
def create_yellow_background_with_insects(image: np.ndarray, detections: List[DetectionResult]) -> np.ndarray:
|
| 156 |
yellow_background = np.full((image.shape[0], image.shape[1], 3), (0, 255, 255), dtype=np.uint8) # BGR for yellow
|