updating gradio_test imports
Browse files- gradio_test.py +27 -31
gradio_test.py
CHANGED
@@ -156,11 +156,9 @@ class OneFormerManager:
|
|
156 |
def extract_floor_areas(self, segmentation: np.ndarray) -> np.ndarray:
|
157 |
"""Extract floor areas from segmentation"""
|
158 |
floor_mask = np.zeros_like(segmentation, dtype=bool)
|
159 |
-
|
160 |
for class_ids in FLOOR_CLASSES.values():
|
161 |
for class_id in class_ids:
|
162 |
floor_mask |= (segmentation == class_id)
|
163 |
-
|
164 |
return floor_mask
|
165 |
|
166 |
########################################
|
@@ -173,7 +171,6 @@ class ImprovedBlackspotDetector:
|
|
173 |
def __init__(self, model_path: str):
|
174 |
self.model_path = model_path
|
175 |
self.predictor = None
|
176 |
-
|
177 |
# Expanded floor-related classes in ADE20K
|
178 |
self.floor_classes = [3, 4, 13, 28, 78] # floor, wood floor, rug, carpet, mat
|
179 |
|
@@ -237,13 +234,11 @@ class ImprovedBlackspotDetector:
|
|
237 |
) -> List[np.ndarray]:
|
238 |
"""Filter out blackspots that are not on floor surfaces"""
|
239 |
filtered_masks = []
|
240 |
-
|
241 |
for mask in blackspot_masks:
|
242 |
if self.is_on_floor_surface(mask, segmentation, floor_mask):
|
243 |
filtered_masks.append(mask)
|
244 |
else:
|
245 |
logger.debug(f"Filtered out non-floor blackspot with area {np.sum(mask)}")
|
246 |
-
|
247 |
return filtered_masks
|
248 |
|
249 |
def detect_blackspots(
|
@@ -299,7 +294,6 @@ class ImprovedBlackspotDetector:
|
|
299 |
if floor_prior is not None:
|
300 |
floor_mask = floor_prior
|
301 |
else:
|
302 |
-
# Create floor mask from segmentation
|
303 |
floor_mask = np.zeros(segmentation.shape, dtype=bool)
|
304 |
for cls in self.floor_classes:
|
305 |
floor_mask |= (segmentation == cls)
|
@@ -687,35 +681,37 @@ def create_gradio_interface():
|
|
687 |
height=400
|
688 |
)
|
689 |
|
|
|
|
|
|
|
690 |
# Analysis settings
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
)
|
697 |
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
|
720 |
# Analysis button
|
721 |
analyze_button = gr.Button(
|
|
|
156 |
def extract_floor_areas(self, segmentation: np.ndarray) -> np.ndarray:
|
157 |
"""Extract floor areas from segmentation"""
|
158 |
floor_mask = np.zeros_like(segmentation, dtype=bool)
|
|
|
159 |
for class_ids in FLOOR_CLASSES.values():
|
160 |
for class_id in class_ids:
|
161 |
floor_mask |= (segmentation == class_id)
|
|
|
162 |
return floor_mask
|
163 |
|
164 |
########################################
|
|
|
171 |
def __init__(self, model_path: str):
|
172 |
self.model_path = model_path
|
173 |
self.predictor = None
|
|
|
174 |
# Expanded floor-related classes in ADE20K
|
175 |
self.floor_classes = [3, 4, 13, 28, 78] # floor, wood floor, rug, carpet, mat
|
176 |
|
|
|
234 |
) -> List[np.ndarray]:
|
235 |
"""Filter out blackspots that are not on floor surfaces"""
|
236 |
filtered_masks = []
|
|
|
237 |
for mask in blackspot_masks:
|
238 |
if self.is_on_floor_surface(mask, segmentation, floor_mask):
|
239 |
filtered_masks.append(mask)
|
240 |
else:
|
241 |
logger.debug(f"Filtered out non-floor blackspot with area {np.sum(mask)}")
|
|
|
242 |
return filtered_masks
|
243 |
|
244 |
def detect_blackspots(
|
|
|
294 |
if floor_prior is not None:
|
295 |
floor_mask = floor_prior
|
296 |
else:
|
|
|
297 |
floor_mask = np.zeros(segmentation.shape, dtype=bool)
|
298 |
for cls in self.floor_classes:
|
299 |
floor_mask |= (segmentation == cls)
|
|
|
681 |
height=400
|
682 |
)
|
683 |
|
684 |
+
# Settings header (since Accordion is unavailable)
|
685 |
+
gr.Markdown("### ⚙️ Analysis Settings")
|
686 |
+
|
687 |
# Analysis settings
|
688 |
+
enable_blackspot = gr.Checkbox(
|
689 |
+
value=blackspot_ok,
|
690 |
+
label="Enable Floor Blackspot Detection",
|
691 |
+
interactive=blackspot_ok
|
692 |
+
)
|
|
|
693 |
|
694 |
+
blackspot_threshold = gr.Slider(
|
695 |
+
minimum=0.1,
|
696 |
+
maximum=0.9,
|
697 |
+
value=0.5,
|
698 |
+
step=0.05,
|
699 |
+
label="Detection Sensitivity",
|
700 |
+
visible=blackspot_ok
|
701 |
+
)
|
702 |
|
703 |
+
enable_contrast = gr.Checkbox(
|
704 |
+
value=True,
|
705 |
+
label="Enable Universal Contrast Analysis"
|
706 |
+
)
|
707 |
|
708 |
+
contrast_threshold = gr.Slider(
|
709 |
+
minimum=3.0,
|
710 |
+
maximum=7.0,
|
711 |
+
value=4.5,
|
712 |
+
step=0.1,
|
713 |
+
label="WCAG Contrast Threshold (4.5:1 recommended)"
|
714 |
+
)
|
715 |
|
716 |
# Analysis button
|
717 |
analyze_button = gr.Button(
|