Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -20,14 +20,21 @@ model = YOLO(modin)
|
|
20 |
|
21 |
def draw_box(image,det):
|
22 |
height, width, channels = image.shape
|
23 |
-
for ea in det.xyxy:
|
24 |
#bbox = convert_coords(ea, width, height)
|
25 |
#print(bbox)
|
26 |
start_point = ((int(ea[0]),int(ea[1])))
|
27 |
end_point = ((int(ea[2]),int(ea[3])))
|
28 |
color = (255, 0, 0)
|
29 |
thickness = 2
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
image = cv2.rectangle(image, start_point, end_point, color, thickness)
|
|
|
31 |
return image
|
32 |
|
33 |
@spaces.GPU
|
|
|
20 |
|
21 |
def draw_box(image,det):
|
22 |
height, width, channels = image.shape
|
23 |
+
for i,ea in enumerate(det.xyxy):
|
24 |
#bbox = convert_coords(ea, width, height)
|
25 |
#print(bbox)
|
26 |
start_point = ((int(ea[0]),int(ea[1])))
|
27 |
end_point = ((int(ea[2]),int(ea[3])))
|
28 |
color = (255, 0, 0)
|
29 |
thickness = 2
|
30 |
+
label = f'{det.data[i]}
|
31 |
+
font = cv2.FONT_HERSHEY_SIMPLEX # Choose a font
|
32 |
+
font_scale = 1
|
33 |
+
color = (0, 0, 255) # Blue color
|
34 |
+
thickness = 2
|
35 |
+
text_position = (int(ea[0]), int(ea[1]) + 10) # Adjust position as needed
|
36 |
image = cv2.rectangle(image, start_point, end_point, color, thickness)
|
37 |
+
cv2.putText(image, label, text_position, font, font_scale, color, thickness)
|
38 |
return image
|
39 |
|
40 |
@spaces.GPU
|