Spaces:
Sleeping
Sleeping
Shreyansh Khaitan commited on
changes
Browse files
app.py
CHANGED
|
@@ -59,7 +59,11 @@ def detect_components(image):
|
|
| 59 |
|
| 60 |
# β
Draw bounding box
|
| 61 |
draw_final.rectangle([x_min_full, y_min_full, x_max_full, y_max_full], outline="green", width=2)
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
return final_image, total_counts, detected_boxes
|
| 64 |
|
| 65 |
# β
First pass detection
|
|
@@ -88,7 +92,13 @@ def detect_components(image):
|
|
| 88 |
for label in set(counts_pass1) | set(counts_pass2) | set(counts_pass3):
|
| 89 |
final_counts[label] = counts_pass1.get(label, 0) + counts_pass2.get(label, 0) + counts_pass3.get(label, 0)
|
| 90 |
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
# β
Gradio Interface
|
| 94 |
interface = gr.Interface(
|
|
@@ -96,9 +106,12 @@ interface = gr.Interface(
|
|
| 96 |
inputs=gr.Image(type="pil"),
|
| 97 |
outputs=[
|
| 98 |
gr.Image(type="pil", label="Detection Pass 1"),
|
|
|
|
| 99 |
gr.Image(type="pil", label="Detection Pass 2"),
|
|
|
|
| 100 |
gr.Image(type="pil", label="Detection Pass 3"),
|
| 101 |
-
gr.
|
|
|
|
| 102 |
],
|
| 103 |
title="HVAC Component Detector",
|
| 104 |
description="Upload an image to detect HVAC components using Roboflow API across three passes."
|
|
|
|
| 59 |
|
| 60 |
# β
Draw bounding box
|
| 61 |
draw_final.rectangle([x_min_full, y_min_full, x_max_full, y_max_full], outline="green", width=2)
|
| 62 |
+
|
| 63 |
+
print(f"\nCounts after pass {pass_num}:")
|
| 64 |
+
for label, count in total_counts.items():
|
| 65 |
+
print(f"{label}: {count}")
|
| 66 |
+
|
| 67 |
return final_image, total_counts, detected_boxes
|
| 68 |
|
| 69 |
# β
First pass detection
|
|
|
|
| 92 |
for label in set(counts_pass1) | set(counts_pass2) | set(counts_pass3):
|
| 93 |
final_counts[label] = counts_pass1.get(label, 0) + counts_pass2.get(label, 0) + counts_pass3.get(label, 0)
|
| 94 |
|
| 95 |
+
# β
Return counts after each pass
|
| 96 |
+
return (
|
| 97 |
+
image_after_pass1, counts_pass1,
|
| 98 |
+
image_after_pass2, counts_pass2,
|
| 99 |
+
image_after_pass3, counts_pass3,
|
| 100 |
+
final_counts
|
| 101 |
+
)
|
| 102 |
|
| 103 |
# β
Gradio Interface
|
| 104 |
interface = gr.Interface(
|
|
|
|
| 106 |
inputs=gr.Image(type="pil"),
|
| 107 |
outputs=[
|
| 108 |
gr.Image(type="pil", label="Detection Pass 1"),
|
| 109 |
+
gr.JSON(label="Counts After Pass 1"), # β
Displays first pass counts
|
| 110 |
gr.Image(type="pil", label="Detection Pass 2"),
|
| 111 |
+
gr.JSON(label="Counts After Pass 2"), # β
Displays second pass counts
|
| 112 |
gr.Image(type="pil", label="Detection Pass 3"),
|
| 113 |
+
gr.JSON(label="Counts After Pass 3"), # β
Displays third pass counts
|
| 114 |
+
gr.JSON(label="Final Detected Components") # β
Displays total counts
|
| 115 |
],
|
| 116 |
title="HVAC Component Detector",
|
| 117 |
description="Upload an image to detect HVAC components using Roboflow API across three passes."
|