Spaces:
Runtime error
Runtime error
Commit
·
a750237
1
Parent(s):
02eb002
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ from ultralyticsplus import YOLO, render_result
|
|
8 |
|
9 |
model = YOLO('ultralyticsplus/yolov8s')
|
10 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
11 |
-
URL = "https://www.youtube.com/watch?v=
|
12 |
|
13 |
# set model parameters
|
14 |
model.overrides['conf'] = 0.25 # NMS confidence threshold
|
@@ -19,15 +19,17 @@ model.to(device)
|
|
19 |
|
20 |
|
21 |
def load(URL):
|
|
|
22 |
yt = YouTube(URL)
|
23 |
vid_cap = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().last().download(filename="tmp.mp4")
|
24 |
global player
|
|
|
25 |
player = cv2.VideoCapture(vid_cap)
|
26 |
frame_num = int(player.get(cv2.CAP_PROP_POS_FRAMES))
|
27 |
frame_count = int(player.get(cv2.CAP_PROP_FRAME_COUNT))
|
28 |
frame_fps = (player.get(cv2.CAP_PROP_FPS))
|
29 |
-
|
30 |
-
return vid_cap,frame_num,frame_count,frame_fps
|
31 |
|
32 |
def vid_play(cap,frame_num):
|
33 |
assert player.isOpened() # Make sure that their is a stream.
|
@@ -93,7 +95,7 @@ with gr.Blocks() as app:
|
|
93 |
cur_frame.change(pl_fn,[output_win,cur_frame,total_frames,fps_frames,pl_tog],[det_win,cur_frame],show_progress=False)
|
94 |
bk.click(bk_fn,[cur_frame],cur_frame,show_progress=False)
|
95 |
fw.click(fw_fn,[cur_frame,total_frames],cur_frame,show_progress=False)
|
96 |
-
load_button.click(load,youtube_url,[output_win,cur_frame,total_frames,fps_frames])
|
97 |
#run_button.click(vid_play, [output_win,cur_frame], det_win)
|
98 |
|
99 |
app.queue(concurrency_count=10).launch()
|
|
|
8 |
|
9 |
model = YOLO('ultralyticsplus/yolov8s')
|
10 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
11 |
+
URL = "https://www.youtube.com/watch?v=6NBwbKMyzEE" #URL to parse
|
12 |
|
13 |
# set model parameters
|
14 |
model.overrides['conf'] = 0.25 # NMS confidence threshold
|
|
|
19 |
|
20 |
|
21 |
def load(URL):
|
22 |
+
|
23 |
yt = YouTube(URL)
|
24 |
vid_cap = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().last().download(filename="tmp.mp4")
|
25 |
global player
|
26 |
+
player.release()
|
27 |
player = cv2.VideoCapture(vid_cap)
|
28 |
frame_num = int(player.get(cv2.CAP_PROP_POS_FRAMES))
|
29 |
frame_count = int(player.get(cv2.CAP_PROP_FRAME_COUNT))
|
30 |
frame_fps = (player.get(cv2.CAP_PROP_FPS))
|
31 |
+
tog = 0
|
32 |
+
return vid_cap,frame_num,frame_count,frame_fps,tog
|
33 |
|
34 |
def vid_play(cap,frame_num):
|
35 |
assert player.isOpened() # Make sure that their is a stream.
|
|
|
95 |
cur_frame.change(pl_fn,[output_win,cur_frame,total_frames,fps_frames,pl_tog],[det_win,cur_frame],show_progress=False)
|
96 |
bk.click(bk_fn,[cur_frame],cur_frame,show_progress=False)
|
97 |
fw.click(fw_fn,[cur_frame,total_frames],cur_frame,show_progress=False)
|
98 |
+
load_button.click(load,youtube_url,[output_win,cur_frame,total_frames,fps_frames,pl_tog])
|
99 |
#run_button.click(vid_play, [output_win,cur_frame], det_win)
|
100 |
|
101 |
app.queue(concurrency_count=10).launch()
|