Shreyansh Khaitan commited on
Commit
5ea165d
Β·
unverified Β·
1 Parent(s): e46dacf
Files changed (1) hide show
  1. app.py +16 -3
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
- return image_after_pass1, image_after_pass2, image_after_pass3, dict(final_counts)
 
 
 
 
 
 
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.Label(label="Final Detected Components"), # βœ… Gradio now properly receives numbers
 
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."