Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,10 +33,10 @@ def fn_video(video_file, conf_thres, iou_thres, start_sec, duration):
|
|
| 33 |
# Unfortunately, gradio doesn't play too nice with videos rn so we have to do some hackiness
|
| 34 |
# with ffmpeg at the end of the function here.
|
| 35 |
with tempfile.NamedTemporaryFile(suffix=".mp4") as temp_file:
|
| 36 |
-
out = cv2.VideoWriter(temp_file.name, cv2.VideoWriter_fourcc(*"MP4V"),
|
| 37 |
|
| 38 |
num_frames = 0
|
| 39 |
-
max_frames = duration *
|
| 40 |
while cap.isOpened():
|
| 41 |
try:
|
| 42 |
ret, frame = cap.read()
|
|
@@ -73,7 +73,7 @@ image_interface = gr.Interface(
|
|
| 73 |
title="Human Detection",
|
| 74 |
description=(
|
| 75 |
"Gradio demo for Human detection on images. To use it, simply upload your image or click one of the"
|
| 76 |
-
" examples to load them.
|
| 77 |
),
|
| 78 |
allow_flagging=False,
|
| 79 |
allow_screenshot=False,
|
|
@@ -85,8 +85,8 @@ video_interface = gr.Interface(
|
|
| 85 |
gr.Video(type="file"),
|
| 86 |
gr.Slider(0, 1, value=0.25, label="Confidence Threshold"),
|
| 87 |
gr.Slider(0, 1, value=0.45, label="IOU Threshold"),
|
| 88 |
-
gr.Slider(0,
|
| 89 |
-
gr.Slider(0,
|
| 90 |
],
|
| 91 |
outputs=gr.Video(type="file", format="mp4"),
|
| 92 |
examples=[
|
|
@@ -97,7 +97,7 @@ video_interface = gr.Interface(
|
|
| 97 |
title="Human Detection",
|
| 98 |
description=(
|
| 99 |
"Gradio demo for Human detection on videos. To use it, simply upload your video or click one of the"
|
| 100 |
-
" examples to load them.
|
| 101 |
),
|
| 102 |
allow_flagging=False,
|
| 103 |
allow_screenshot=False,
|
|
@@ -115,7 +115,7 @@ webcam_interface = gr.Interface(
|
|
| 115 |
title="Human Detection",
|
| 116 |
description=(
|
| 117 |
"Gradio demo for Human detection on real time webcam. To use it, simply allow the browser to access"
|
| 118 |
-
" your webcam.
|
| 119 |
),
|
| 120 |
allow_flagging=False,
|
| 121 |
allow_screenshot=False,
|
|
|
|
| 33 |
# Unfortunately, gradio doesn't play too nice with videos rn so we have to do some hackiness
|
| 34 |
# with ffmpeg at the end of the function here.
|
| 35 |
with tempfile.NamedTemporaryFile(suffix=".mp4") as temp_file:
|
| 36 |
+
out = cv2.VideoWriter(temp_file.name, cv2.VideoWriter_fourcc(*"MP4V"), 120, (1280, 720))
|
| 37 |
|
| 38 |
num_frames = 0
|
| 39 |
+
max_frames = duration * 120
|
| 40 |
while cap.isOpened():
|
| 41 |
try:
|
| 42 |
ret, frame = cap.read()
|
|
|
|
| 73 |
title="Human Detection",
|
| 74 |
description=(
|
| 75 |
"Gradio demo for Human detection on images. To use it, simply upload your image or click one of the"
|
| 76 |
+
" examples to load them."
|
| 77 |
),
|
| 78 |
allow_flagging=False,
|
| 79 |
allow_screenshot=False,
|
|
|
|
| 85 |
gr.Video(type="file"),
|
| 86 |
gr.Slider(0, 1, value=0.25, label="Confidence Threshold"),
|
| 87 |
gr.Slider(0, 1, value=0.45, label="IOU Threshold"),
|
| 88 |
+
gr.Slider(0, 120, value=0, label="Start Second", step=1),
|
| 89 |
+
gr.Slider(0, 120 if pipeline.device.type != 'cpu' else 1, value=2, label="Duration", step=1),
|
| 90 |
],
|
| 91 |
outputs=gr.Video(type="file", format="mp4"),
|
| 92 |
examples=[
|
|
|
|
| 97 |
title="Human Detection",
|
| 98 |
description=(
|
| 99 |
"Gradio demo for Human detection on videos. To use it, simply upload your video or click one of the"
|
| 100 |
+
" examples to load them."
|
| 101 |
),
|
| 102 |
allow_flagging=False,
|
| 103 |
allow_screenshot=False,
|
|
|
|
| 115 |
title="Human Detection",
|
| 116 |
description=(
|
| 117 |
"Gradio demo for Human detection on real time webcam. To use it, simply allow the browser to access"
|
| 118 |
+
" your webcam."
|
| 119 |
),
|
| 120 |
allow_flagging=False,
|
| 121 |
allow_screenshot=False,
|