Spaces:
Sleeping
Sleeping
fix bug with video output
Browse files- app.py +7 -5
- src/gradio_blocks.py +2 -2
- src/results/gradcam_video.mp4 +2 -2
app.py
CHANGED
@@ -27,8 +27,8 @@ IMAGES_PER_ROW = 7
|
|
27 |
|
28 |
MAXIMAL_FRAMES = 1000
|
29 |
BATCHES_TO_PROCESS = 10
|
30 |
-
OUTPUT_FPS =
|
31 |
-
MAX_OUT_FRAMES =
|
32 |
|
33 |
CAM_METHODS = {
|
34 |
"GradCAM": GradCAM,
|
@@ -146,7 +146,9 @@ def gradcam_video(video, alpha=0.5, cam_method=GradCAM, layer=None, specific_cla
|
|
146 |
cam.remove_hooks()
|
147 |
|
148 |
# save video
|
149 |
-
fourcc = cv2.VideoWriter_fourcc(*'
|
|
|
|
|
150 |
size = (results[0].shape[1], results[0].shape[0])
|
151 |
video = cv2.VideoWriter('src/results/gradcam_video.mp4', fourcc, OUTPUT_FPS, size)
|
152 |
for frame in results:
|
@@ -255,7 +257,7 @@ with gr.Blocks(theme='freddyaboulton/dracula_revamped', css=css) as demo:
|
|
255 |
# -------------------------------------------
|
256 |
# EXPLAIN
|
257 |
# -------------------------------------------
|
258 |
-
with gr.Tab("Explain"):
|
259 |
with gr.Row():
|
260 |
with gr.Column():
|
261 |
cam_method = gr.Radio(
|
@@ -314,7 +316,7 @@ with gr.Blocks(theme='freddyaboulton/dracula_revamped', css=css) as demo:
|
|
314 |
# -------------------------------------------
|
315 |
# GIF CAM
|
316 |
# -------------------------------------------
|
317 |
-
with gr.Tab("
|
318 |
build_video_to_camvideo(CAM_METHODS, ALL_CLASSES, gradcam_video)
|
319 |
|
320 |
# -------------------------------------------
|
|
|
27 |
|
28 |
MAXIMAL_FRAMES = 1000
|
29 |
BATCHES_TO_PROCESS = 10
|
30 |
+
OUTPUT_FPS = 10
|
31 |
+
MAX_OUT_FRAMES = 40
|
32 |
|
33 |
CAM_METHODS = {
|
34 |
"GradCAM": GradCAM,
|
|
|
146 |
cam.remove_hooks()
|
147 |
|
148 |
# save video
|
149 |
+
# fourcc = cv2.VideoWriter_fourcc(*'AVC1')
|
150 |
+
# fourcc = cv2.VideoWriter_fourcc(*'MP4V')
|
151 |
+
fourcc = cv2.VideoWriter_fourcc(*'XVID')
|
152 |
size = (results[0].shape[1], results[0].shape[0])
|
153 |
video = cv2.VideoWriter('src/results/gradcam_video.mp4', fourcc, OUTPUT_FPS, size)
|
154 |
for frame in results:
|
|
|
257 |
# -------------------------------------------
|
258 |
# EXPLAIN
|
259 |
# -------------------------------------------
|
260 |
+
with gr.Tab("Explain Image"):
|
261 |
with gr.Row():
|
262 |
with gr.Column():
|
263 |
cam_method = gr.Radio(
|
|
|
316 |
# -------------------------------------------
|
317 |
# GIF CAM
|
318 |
# -------------------------------------------
|
319 |
+
with gr.Tab("Explain Video"):
|
320 |
build_video_to_camvideo(CAM_METHODS, ALL_CLASSES, gradcam_video)
|
321 |
|
322 |
# -------------------------------------------
|
src/gradio_blocks.py
CHANGED
@@ -52,8 +52,8 @@ def build_video_to_camvideo(CAM_METHODS, ALL_CLASSES, gradcam_video):
|
|
52 |
|
53 |
with gr.Column():
|
54 |
with gr.Column():
|
55 |
-
video_in = gr.Video(autoplay=
|
56 |
-
video_out = gr.Video(autoplay=
|
57 |
|
58 |
gif_cam_mode_button = gr.Button(value="Show GradCAM-Video", label="GradCAM", scale=1)
|
59 |
gif_cam_mode_button.click(fn=gradcam_video, inputs=[video_in, video_alpha, video_cam_method, video_layer, video_animal_to_explain], outputs=[video_out], queue=True)
|
|
|
52 |
|
53 |
with gr.Column():
|
54 |
with gr.Column():
|
55 |
+
video_in = gr.Video(autoplay=False, include_audio=False)
|
56 |
+
video_out = gr.Video(autoplay=False, include_audio=False)
|
57 |
|
58 |
gif_cam_mode_button = gr.Button(value="Show GradCAM-Video", label="GradCAM", scale=1)
|
59 |
gif_cam_mode_button.click(fn=gradcam_video, inputs=[video_in, video_alpha, video_cam_method, video_layer, video_animal_to_explain], outputs=[video_out], queue=True)
|
src/results/gradcam_video.mp4
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:23fecbd3a23e2abfa91532fe87ebeb754a69897d583232de98a1a07a2819f0d1
|
3 |
+
size 1049141
|