Spaces:
Sleeping
Sleeping
Update src/features/region_extraction.py
Browse files
src/features/region_extraction.py
CHANGED
|
@@ -170,7 +170,18 @@ class RegionExtractor:
|
|
| 170 |
region_image = original_image[y_min:y_max, x_min:x_max].copy()
|
| 171 |
region_mask_cropped = region_mask[y_min:y_max, x_min:x_max]
|
| 172 |
|
|
|
|
| 173 |
# Critical Fix #4: Region-level confidence aggregation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
region_probs = probability_map[region_mask > 0]
|
| 175 |
region_confidence = float(np.mean(region_probs)) if len(region_probs) > 0 else 0.0
|
| 176 |
|
|
|
|
| 170 |
region_image = original_image[y_min:y_max, x_min:x_max].copy()
|
| 171 |
region_mask_cropped = region_mask[y_min:y_max, x_min:x_max]
|
| 172 |
|
| 173 |
+
|
| 174 |
# Critical Fix #4: Region-level confidence aggregation
|
| 175 |
+
# Ensure region_mask and probability_map have same shape
|
| 176 |
+
if region_mask.shape != probability_map.shape:
|
| 177 |
+
import cv2
|
| 178 |
+
# Resize probability_map to match region_mask
|
| 179 |
+
probability_map = cv2.resize(
|
| 180 |
+
probability_map,
|
| 181 |
+
(region_mask.shape[1], region_mask.shape[0]),
|
| 182 |
+
interpolation=cv2.INTER_LINEAR
|
| 183 |
+
)
|
| 184 |
+
|
| 185 |
region_probs = probability_map[region_mask > 0]
|
| 186 |
region_confidence = float(np.mean(region_probs)) if len(region_probs) > 0 else 0.0
|
| 187 |
|