Aumkeshchy2003 commited on
Commit
d73ddf5
·
verified ·
1 Parent(s): d5e3d23

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -65,11 +65,11 @@ def detect_objects(image):
65
  class_id = int(cls)
66
  color = colors[class_id].tolist()
67
 
68
- # Thinner, stylish bounding boxes
69
- cv2.rectangle(output_image, (x1, y1), (x2, y2), color, 2, lineType=cv2.LINE_AA)
70
 
71
  label = f"{model.names[class_id]} {conf:.2f}"
72
- font_scale, font_thickness = 0.7, 1
73
  (w, h), _ = cv2.getTextSize(label, cv2.FONT_HERSHEY_SIMPLEX, font_scale, font_thickness)
74
 
75
  cv2.rectangle(output_image, (x1, y1 - h - 10), (x1 + w + 10, y1), color, -1)
@@ -89,7 +89,7 @@ def detect_objects(image):
89
 
90
  return output_image
91
 
92
- example_images = ["spring_street_after.jpg", "pexels-hikaique-109919.jpg"]
93
  os.makedirs("examples", exist_ok=True)
94
 
95
  with gr.Blocks(title="Optimized YOLOv5 Object Detection") as demo:
@@ -101,14 +101,12 @@ with gr.Blocks(title="Optimized YOLOv5 Object Detection") as demo:
101
  with gr.Row():
102
  with gr.Column(scale=1):
103
  input_image = gr.Image(label="Input Image", type="numpy")
 
 
104
 
105
  with gr.Column(scale=1):
106
  output_image = gr.Image(label="Detected Objects", type="numpy")
107
 
108
- with gr.Row():
109
- clear_button = gr.Button("Clear")
110
- submit_button = gr.Button("Submit", variant="primary")
111
-
112
  gr.Examples(
113
  examples=example_images,
114
  inputs=input_image,
 
65
  class_id = int(cls)
66
  color = colors[class_id].tolist()
67
 
68
+ # Thicker bounding boxes
69
+ cv2.rectangle(output_image, (x1, y1), (x2, y2), color, 3, lineType=cv2.LINE_AA)
70
 
71
  label = f"{model.names[class_id]} {conf:.2f}"
72
+ font_scale, font_thickness = 0.9, 2 # Increased for better readability
73
  (w, h), _ = cv2.getTextSize(label, cv2.FONT_HERSHEY_SIMPLEX, font_scale, font_thickness)
74
 
75
  cv2.rectangle(output_image, (x1, y1 - h - 10), (x1 + w + 10, y1), color, -1)
 
89
 
90
  return output_image
91
 
92
+ examples = ["spring_street_after.jpg", "pexels-hikaique-109919.jpg"]
93
  os.makedirs("examples", exist_ok=True)
94
 
95
  with gr.Blocks(title="Optimized YOLOv5 Object Detection") as demo:
 
101
  with gr.Row():
102
  with gr.Column(scale=1):
103
  input_image = gr.Image(label="Input Image", type="numpy")
104
+ submit_button = gr.Button("Submit", variant="primary")
105
+ clear_button = gr.Button("Clear")
106
 
107
  with gr.Column(scale=1):
108
  output_image = gr.Image(label="Detected Objects", type="numpy")
109
 
 
 
 
 
110
  gr.Examples(
111
  examples=example_images,
112
  inputs=input_image,