Spaces:
Runtime error
Runtime error
Future-Tense
commited on
Commit
·
2a1d794
1
Parent(s):
b18bae5
Update app.py
Browse files
app.py
CHANGED
@@ -7,14 +7,17 @@ from ultralyticsplus import YOLO, render_result
|
|
7 |
|
8 |
#from torch import hub # Hub contains other models like FasterRCNN
|
9 |
model = YOLO('ultralyticsplus/yolov8s')
|
|
|
|
|
10 |
|
11 |
# set model parameters
|
12 |
model.overrides['conf'] = 0.25 # NMS confidence threshold
|
13 |
model.overrides['iou'] = 0.45 # NMS IoU threshold
|
14 |
model.overrides['agnostic_nms'] = False # NMS class-agnostic
|
15 |
model.overrides['max_det'] = 1000 # maximum number of detections per image
|
|
|
|
|
16 |
|
17 |
-
URL = "https://www.youtube.com/watch?v=dQw4w9WgXcQ" #URL to parse
|
18 |
#play = pafy.new(_URL).streams[-1] #'-1' means read the lowest quality of video.
|
19 |
|
20 |
#assert play is not None # we want to make sure their is a input to read.
|
@@ -42,9 +45,7 @@ URL = "https://www.youtube.com/watch?v=dQw4w9WgXcQ" #URL to parse
|
|
42 |
"""
|
43 |
The function below identifies the device which is availabe to make the prediction and uses it to load and infer the frame. Once it has results it will extract the labels and cordinates(Along with scores) for each object detected in the frame.
|
44 |
"""
|
45 |
-
def score_frame(frame
|
46 |
-
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
47 |
-
model.to(device)
|
48 |
frame = [torch.tensor(frame)]
|
49 |
results = model(frame)
|
50 |
labels = results.xyxyn[0][:, -1].numpy()
|
|
|
7 |
|
8 |
#from torch import hub # Hub contains other models like FasterRCNN
|
9 |
model = YOLO('ultralyticsplus/yolov8s')
|
10 |
+
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
11 |
+
URL = "https://www.youtube.com/watch?v=dQw4w9WgXcQ" #URL to parse
|
12 |
|
13 |
# set model parameters
|
14 |
model.overrides['conf'] = 0.25 # NMS confidence threshold
|
15 |
model.overrides['iou'] = 0.45 # NMS IoU threshold
|
16 |
model.overrides['agnostic_nms'] = False # NMS class-agnostic
|
17 |
model.overrides['max_det'] = 1000 # maximum number of detections per image
|
18 |
+
model.to(device)
|
19 |
+
|
20 |
|
|
|
21 |
#play = pafy.new(_URL).streams[-1] #'-1' means read the lowest quality of video.
|
22 |
|
23 |
#assert play is not None # we want to make sure their is a input to read.
|
|
|
45 |
"""
|
46 |
The function below identifies the device which is availabe to make the prediction and uses it to load and infer the frame. Once it has results it will extract the labels and cordinates(Along with scores) for each object detected in the frame.
|
47 |
"""
|
48 |
+
def score_frame(frame):
|
|
|
|
|
49 |
frame = [torch.tensor(frame)]
|
50 |
results = model(frame)
|
51 |
labels = results.xyxyn[0][:, -1].numpy()
|