Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -14,26 +14,11 @@ ltr=["n","s","m","1","x"]
|
|
14 |
tsk=["","-seg","-pose","-obb","-cls"]
|
15 |
#yolov8s.pt
|
16 |
modin=f"yolov{ver[9]}{ltr[1]}{tsk[0]}.pt"
|
17 |
-
|
18 |
-
print(modin)
|
19 |
model = YOLO(modin)
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
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 |
-
label = f'{det.data["class_name"][i]}'
|
29 |
-
font = cv2.FONT_HERSHEY_COMPLEX # Choose a font
|
30 |
-
font_scale = 1
|
31 |
-
color = (0, 0, 255) # Blue color
|
32 |
-
thickness = 1
|
33 |
-
text_position = (int(ea[0]), int(ea[1]) + 10) # Adjust position as needed
|
34 |
-
image = cv2.rectangle(image, start_point, end_point, color, thickness)
|
35 |
-
cv2.putText(image, label, text_position, font, font_scale, color, thickness)
|
36 |
-
return image
|
37 |
|
38 |
@spaces.GPU
|
39 |
def stream_object_detection(video):
|
@@ -57,7 +42,8 @@ def stream_object_detection(video):
|
|
57 |
detections = sv.Detections.from_ultralytics(result)
|
58 |
print(detections)
|
59 |
|
60 |
-
box_annotator = sv.
|
|
|
61 |
outp = box_annotator.annotate(
|
62 |
scene=frame.copy(),
|
63 |
detections=detections)
|
|
|
14 |
tsk=["","-seg","-pose","-obb","-cls"]
|
15 |
#yolov8s.pt
|
16 |
modin=f"yolov{ver[9]}{ltr[1]}{tsk[0]}.pt"
|
|
|
|
|
17 |
model = YOLO(modin)
|
18 |
+
annotators = ["Box","RoundBox","BoxCorner","Color",
|
19 |
+
"Circle","Dot","Triangle","Elipse","Halo",
|
20 |
+
"PercentageBar","Mask","Polygon","Label",
|
21 |
+
"RichLabel","Icon","Crop","Blur","Pixelate","HeatMap"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
@spaces.GPU
|
24 |
def stream_object_detection(video):
|
|
|
42 |
detections = sv.Detections.from_ultralytics(result)
|
43 |
print(detections)
|
44 |
|
45 |
+
box_annotator = eval(f'sv.{annotators[11]}()')
|
46 |
+
|
47 |
outp = box_annotator.annotate(
|
48 |
scene=frame.copy(),
|
49 |
detections=detections)
|