Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -25,6 +25,18 @@ modin=f"yolov{ver[2]}{ltr[1]}-{tsk[0]}.pt"
|
|
25 |
print(modin)
|
26 |
model = YOLO(modin)
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
@spaces.GPU
|
29 |
def stream_object_detection(video):
|
30 |
SUBSAMPLE=1
|
@@ -66,5 +78,7 @@ with gr.Blocks() as app:
|
|
66 |
inp = gr.Video()
|
67 |
btn = gr.Button()
|
68 |
outp_v = gr.Video(label="Processed Video", streaming=True, autoplay=True)
|
69 |
-
|
|
|
|
|
70 |
app.queue().launch()
|
|
|
25 |
print(modin)
|
26 |
model = YOLO(modin)
|
27 |
|
28 |
+
def draw_box(image,det):
|
29 |
+
height, width, channels = image.shape
|
30 |
+
for ea in det.xyxy:
|
31 |
+
#bbox = convert_coords(ea, width, height)
|
32 |
+
#print(bbox)
|
33 |
+
start_point = ((int(ea[0]),int(ea[1])))
|
34 |
+
end_point = ((int(ea[2]),int(ea[3])))
|
35 |
+
color = (255, 0, 0)
|
36 |
+
thickness = 2
|
37 |
+
image = cv2.rectangle(image, start_point, end_point, color, thickness)
|
38 |
+
return image
|
39 |
+
|
40 |
@spaces.GPU
|
41 |
def stream_object_detection(video):
|
42 |
SUBSAMPLE=1
|
|
|
78 |
inp = gr.Video()
|
79 |
btn = gr.Button()
|
80 |
outp_v = gr.Video(label="Processed Video", streaming=True, autoplay=True)
|
81 |
+
outp_j = gr.JSON()
|
82 |
+
|
83 |
+
btn.click(stream_object_detection,inp,[outp_v,outp_j])
|
84 |
app.queue().launch()
|