Spaces:
Sleeping
Sleeping
fix bug with video output
Browse files- app.py +10 -5
- packages.txt +1 -0
- requirements.txt +0 -0
- src/results/gradcam_video.mp4 +2 -2
app.py
CHANGED
@@ -20,7 +20,11 @@ from util import transform
|
|
20 |
from gradio_blocks import build_video_to_camvideo
|
21 |
import cv2
|
22 |
import ffmpeg
|
|
|
|
|
23 |
|
|
|
|
|
24 |
|
25 |
IMAGE_PATH = os.path.join(os.getcwd(), 'src/examples')
|
26 |
IMAGES_PER_ROW = 7
|
@@ -148,11 +152,12 @@ def gradcam_video(video, alpha=0.5, cam_method=GradCAM, layer=None, specific_cla
|
|
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:
|
155 |
-
|
|
|
156 |
video.release()
|
157 |
return 'src/results/gradcam_video.mp4'
|
158 |
|
|
|
20 |
from gradio_blocks import build_video_to_camvideo
|
21 |
import cv2
|
22 |
import ffmpeg
|
23 |
+
import shutil
|
24 |
+
import mediapy
|
25 |
|
26 |
+
ffmpeg_path = shutil.which('ffmpeg')
|
27 |
+
mediapy.set_ffmpeg(ffmpeg_path)
|
28 |
|
29 |
IMAGE_PATH = os.path.join(os.getcwd(), 'src/examples')
|
30 |
IMAGES_PER_ROW = 7
|
|
|
152 |
# save video
|
153 |
# fourcc = cv2.VideoWriter_fourcc(*'AVC1')
|
154 |
# fourcc = cv2.VideoWriter_fourcc(*'MP4V')
|
155 |
+
# fourcc = cv2.VideoWriter_fourcc(*'XVID')
|
156 |
+
# size = (results[0].shape[1], results[0].shape[0])
|
157 |
+
# video = cv2.VideoWriter('src/results/gradcam_video.mp4', fourcc, OUTPUT_FPS, size)
|
158 |
+
# for frame in results:
|
159 |
+
# video.write(frame)
|
160 |
+
mediapy.write_video('src/results/gradcam_video.mp4', results, fps=OUTPUT_FPS)
|
161 |
video.release()
|
162 |
return 'src/results/gradcam_video.mp4'
|
163 |
|
packages.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
ffmpeg
|
requirements.txt
CHANGED
Binary files a/requirements.txt and b/requirements.txt differ
|
|
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:0b5c5763b98e7c7c4e0191e120a415cf50580aeb3d15f8c6fdee8e0a3a50fe05
|
3 |
+
size 648305
|