Spaces:
Running
Running
Update utils.py
Browse files
utils.py
CHANGED
@@ -9,7 +9,7 @@ import torch
|
|
9 |
import pandas as pd
|
10 |
import numpy as np
|
11 |
import cv2
|
12 |
-
import yt_dlp
|
13 |
import gradio as gr
|
14 |
from ultralytics import YOLO
|
15 |
|
@@ -35,12 +35,12 @@ def detect_image(image_path: str, model: YOLO, conf: float, iou: float) -> np.nd
|
|
35 |
def detect_video(video_path_or_url: str, model: YOLO, conf: float, iou: float) -> Tuple[Path, Path]:
|
36 |
progress = gr.Progress()
|
37 |
video_path = video_path_or_url
|
38 |
-
if 'youtube.com' in video_path_or_url or 'youtu.be' in video_path_or_url:
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
|
45 |
cap = cv2.VideoCapture(video_path)
|
46 |
num_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
|
|
|
9 |
import pandas as pd
|
10 |
import numpy as np
|
11 |
import cv2
|
12 |
+
# import yt_dlp
|
13 |
import gradio as gr
|
14 |
from ultralytics import YOLO
|
15 |
|
|
|
35 |
def detect_video(video_path_or_url: str, model: YOLO, conf: float, iou: float) -> Tuple[Path, Path]:
|
36 |
progress = gr.Progress()
|
37 |
video_path = video_path_or_url
|
38 |
+
# if 'youtube.com' in video_path_or_url or 'youtu.be' in video_path_or_url:
|
39 |
+
# progress(0.001, desc='Downloading video from YouTube...')
|
40 |
+
# ydl_opts = {'format': 'bestvideo[height<=720]'}
|
41 |
+
# with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
42 |
+
# video_info_dict = ydl.extract_info(video_path_or_url, download=True)
|
43 |
+
# video_path = ydl.prepare_filename(video_info_dict)
|
44 |
|
45 |
cap = cv2.VideoCapture(video_path)
|
46 |
num_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
|