Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -101,25 +101,6 @@ def detect_video(video):
|
|
| 101 |
# Release resources
|
| 102 |
cap.release()
|
| 103 |
|
| 104 |
-
|
| 105 |
-
def show_preds_video(video_path):
|
| 106 |
-
cap = cv2.VideoCapture(video_path)
|
| 107 |
-
while(cap.isOpened()):
|
| 108 |
-
ret, frame = cap.read()
|
| 109 |
-
if ret:
|
| 110 |
-
frame_copy = frame.copy()
|
| 111 |
-
outputs = detection_model.predict(source=frame)
|
| 112 |
-
results = outputs[0].cpu().numpy()
|
| 113 |
-
for i, det in enumerate(results.boxes.xyxy):
|
| 114 |
-
cv2.rectangle(
|
| 115 |
-
frame_copy,
|
| 116 |
-
(int(det[0]), int(det[1])),
|
| 117 |
-
(int(det[2]), int(det[3])),
|
| 118 |
-
color=(0, 0, 255),
|
| 119 |
-
thickness=2,
|
| 120 |
-
lineType=cv2.LINE_AA
|
| 121 |
-
)
|
| 122 |
-
yield cv2.cvtColor(frame_copy, cv2.COLOR_BGR2RGB)
|
| 123 |
|
| 124 |
inputs_video = [
|
| 125 |
gr.components.Video(type="filepath", label="Input Video"),
|
|
@@ -177,7 +158,7 @@ c = os.path.join(os.path.dirname(__file__), "data/c.mp4") # Video
|
|
| 177 |
# )
|
| 178 |
|
| 179 |
stt_demo = gr.Interface(
|
| 180 |
-
fn=
|
| 181 |
inputs=inputs_video,
|
| 182 |
outputs=outputs_video,
|
| 183 |
examples=[
|
|
|
|
| 101 |
# Release resources
|
| 102 |
cap.release()
|
| 103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
inputs_video = [
|
| 106 |
gr.components.Video(type="filepath", label="Input Video"),
|
|
|
|
| 158 |
# )
|
| 159 |
|
| 160 |
stt_demo = gr.Interface(
|
| 161 |
+
fn=detect_video,
|
| 162 |
inputs=inputs_video,
|
| 163 |
outputs=outputs_video,
|
| 164 |
examples=[
|