Spaces:
Sleeping
Sleeping
Optimize image process
Browse files- app.py +6 -1
- configuration.py +1 -1
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import tempfile
|
|
|
2 |
import gradio as gr
|
3 |
import tensorflow as tf
|
4 |
from moviepy.editor import VideoFileClip
|
@@ -39,7 +40,11 @@ def fn(video: gr.Video):
|
|
39 |
frame = draw_boxes(frame, detections, actions)
|
40 |
processed_frames.append(frame)
|
41 |
if i % config.yield_frame_steps == 0:
|
42 |
-
|
|
|
|
|
|
|
|
|
43 |
processed_clip = ImageSequenceClip(processed_frames, clip.fps)
|
44 |
processed_clip.audio = clip.audio
|
45 |
processed_clip.write_videofile(output, fps=clip.fps, audio_codec='aac', logger=None)
|
|
|
1 |
import tempfile
|
2 |
+
import cv2
|
3 |
import gradio as gr
|
4 |
import tensorflow as tf
|
5 |
from moviepy.editor import VideoFileClip
|
|
|
40 |
frame = draw_boxes(frame, detections, actions)
|
41 |
processed_frames.append(frame)
|
42 |
if i % config.yield_frame_steps == 0:
|
43 |
+
with tempfile.NamedTemporaryFile(suffix='.jpeg') as f:
|
44 |
+
quality = 1
|
45 |
+
_, img_encoded = cv2.imencode('.jpg', img_array, [int(cv2.IMWRITE_JPEG_QUALITY), quality])
|
46 |
+
f.write(img_encoded)
|
47 |
+
yield f.name, None
|
48 |
processed_clip = ImageSequenceClip(processed_frames, clip.fps)
|
49 |
processed_clip.audio = clip.audio
|
50 |
processed_clip.write_videofile(output, fps=clip.fps, audio_codec='aac', logger=None)
|
configuration.py
CHANGED
@@ -29,4 +29,4 @@ class Config:
|
|
29 |
detect_object_frame_steps = 5
|
30 |
classify_action_frame_steps = 15
|
31 |
classify_action_num_frames = 8
|
32 |
-
yield_frame_steps =
|
|
|
29 |
detect_object_frame_steps = 5
|
30 |
classify_action_frame_steps = 15
|
31 |
classify_action_num_frames = 8
|
32 |
+
yield_frame_steps = 5
|