Spaces:
Runtime error
Runtime error
Future-Tense
commited on
Commit
·
5c4768f
1
Parent(s):
bc97b37
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,20 @@
|
|
1 |
import cv2 # opencv2 package for python.
|
2 |
-
|
3 |
from torch import hub # Hub contains other models like FasterRCNN
|
4 |
|
5 |
URL = "https://www.youtube.com/watch?v=dQw4w9WgXcQ" #URL to parse
|
6 |
-
play = pafy.new(_URL).streams[-1] #'-1' means read the lowest quality of video.
|
7 |
|
8 |
-
assert play is not None # we want to make sure their is a input to read.
|
9 |
-
stream = cv2.VideoCapture(play.url) #create a opencv video stream.
|
10 |
#stream = cv2.VideoCapture(0) # 0 means read from local camera.
|
11 |
#camera_ip = "rtsp://username:password@IP/port"
|
12 |
#stream = cv2.VideoCapture(camera_ip)
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
model = torch.hub.load('ultralytics/yolov5','yolov5s',pretrained=True)
|
15 |
|
|
|
1 |
import cv2 # opencv2 package for python.
|
2 |
+
from pytube import YouTube
|
3 |
from torch import hub # Hub contains other models like FasterRCNN
|
4 |
|
5 |
URL = "https://www.youtube.com/watch?v=dQw4w9WgXcQ" #URL to parse
|
6 |
+
#play = pafy.new(_URL).streams[-1] #'-1' means read the lowest quality of video.
|
7 |
|
8 |
+
#assert play is not None # we want to make sure their is a input to read.
|
9 |
+
#stream = cv2.VideoCapture(play.url) #create a opencv video stream.
|
10 |
#stream = cv2.VideoCapture(0) # 0 means read from local camera.
|
11 |
#camera_ip = "rtsp://username:password@IP/port"
|
12 |
#stream = cv2.VideoCapture(camera_ip)
|
13 |
+
def load():
|
14 |
+
yt = YouTube(URL)
|
15 |
+
vid_cap = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first().download(filename="tmp.mp4")
|
16 |
+
stream = cv2.VideoCapture(vid)
|
17 |
+
return vid_cap
|
18 |
|
19 |
model = torch.hub.load('ultralytics/yolov5','yolov5s',pretrained=True)
|
20 |
|