Spaces:
Build error
Build error
Commit
·
59e0448
1
Parent(s):
3906f18
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,14 +3,9 @@ import cv2
|
|
| 3 |
from ultralytics import YOLO
|
| 4 |
|
| 5 |
model = YOLO('best.pt')
|
| 6 |
-
|
| 7 |
-
def show_preds(video_path
|
| 8 |
cap = cv2.VideoCapture(video_path)
|
| 9 |
-
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
| 10 |
-
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
| 11 |
-
fps = cap.get(cv2.CAP_PROP_FPS)
|
| 12 |
-
fourcc = cv2.VideoWriter_fourcc(*'h264')
|
| 13 |
-
writer = cv2.VideoWriter(output_path, fourcc, fps, (width, height))
|
| 14 |
while True:
|
| 15 |
ret, frame = cap.read()
|
| 16 |
if ret:
|
|
@@ -26,25 +21,24 @@ def show_preds(video_path, output_path):
|
|
| 26 |
thickness=2,
|
| 27 |
lineType=cv2.LINE_AA
|
| 28 |
)
|
| 29 |
-
writer.write(frame_copy)
|
| 30 |
yield cv2.cvtColor(frame_copy, cv2.COLOR_BGR2RGB)
|
| 31 |
-
else:
|
| 32 |
-
break
|
| 33 |
-
writer.release()
|
| 34 |
|
| 35 |
input_video = [
|
| 36 |
-
gr.
|
| 37 |
]
|
| 38 |
-
|
| 39 |
-
gr.
|
| 40 |
]
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
show_preds,
|
| 44 |
inputs=input_video, # type: ignore
|
| 45 |
-
outputs=
|
| 46 |
title='Pothole Detection',
|
| 47 |
-
|
|
|
|
| 48 |
)
|
| 49 |
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
from ultralytics import YOLO
|
| 4 |
|
| 5 |
model = YOLO('best.pt')
|
| 6 |
+
# video_path = 'Deployment\\test_videos\\test2.mp4'
|
| 7 |
+
def show_preds(video_path):
|
| 8 |
cap = cv2.VideoCapture(video_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
while True:
|
| 10 |
ret, frame = cap.read()
|
| 11 |
if ret:
|
|
|
|
| 21 |
thickness=2,
|
| 22 |
lineType=cv2.LINE_AA
|
| 23 |
)
|
|
|
|
| 24 |
yield cv2.cvtColor(frame_copy, cv2.COLOR_BGR2RGB)
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
input_video = [
|
| 27 |
+
gr.components.Video(type='filepath', label='Input Video'),
|
| 28 |
]
|
| 29 |
+
outputs_video = [
|
| 30 |
+
gr.components.Image(type='numpy', label='Output Image'),
|
| 31 |
]
|
| 32 |
+
interface_video = gr.Interface(
|
| 33 |
+
fn=show_preds,
|
|
|
|
| 34 |
inputs=input_video, # type: ignore
|
| 35 |
+
outputs=outputs_video, # type: ignore
|
| 36 |
title='Pothole Detection',
|
| 37 |
+
#examples=video_path,
|
| 38 |
+
cache_examples=False,
|
| 39 |
)
|
| 40 |
|
| 41 |
+
gr.TabbedInterface(
|
| 42 |
+
[interface_video],
|
| 43 |
+
tab_names=['Video Inference']
|
| 44 |
+
).queue().launch()
|