Spaces:
Runtime error
Runtime error
Update app.py (#7)
Browse files- Update app.py (4b9bca0dab3c9feb9c3e6bb59106709a35b9313d)
Co-authored-by: Linoy Tsaban <[email protected]>
app.py
CHANGED
@@ -117,7 +117,7 @@ def process_video_for_canny(video, width, height):
|
|
117 |
detect_resolution = max(video[0].size[0],video[0].size[1])
|
118 |
image_resolution = max(width, height)
|
119 |
for frame in video:
|
120 |
-
canny_video.append(canny_processor(frame, low_threshold=50, high_threshold=200, detect_resolution=detect_resolution, image_resolution=image_resolution))
|
121 |
|
122 |
return canny_video
|
123 |
|
@@ -137,11 +137,14 @@ def process_input_video(reference_video, width, height,
|
|
137 |
processed_video = process_video_for_canny(video, width, height)
|
138 |
|
139 |
# Create a preview video file for display
|
140 |
-
|
141 |
-
|
142 |
-
|
|
|
|
|
|
|
143 |
|
144 |
-
return
|
145 |
|
146 |
except Exception as e:
|
147 |
print(f"Error processing input video: {e}")
|
|
|
117 |
detect_resolution = max(video[0].size[0],video[0].size[1])
|
118 |
image_resolution = max(width, height)
|
119 |
for frame in video:
|
120 |
+
canny_video.append(canny_processor(frame, low_threshold=50, high_threshold=200, detect_resolution=detect_resolution, image_resolution=image_resolution, output_type="np"))
|
121 |
|
122 |
return canny_video
|
123 |
|
|
|
137 |
processed_video = process_video_for_canny(video, width, height)
|
138 |
|
139 |
# Create a preview video file for display
|
140 |
+
output_filename = "control.mp4"
|
141 |
+
video_uint8_frames = [(frame * 255).astype(np.uint8) for frame in processed_video]
|
142 |
+
with imageio.get_writer(output_filename, fps=FPS, quality=8, macro_block_size=1) as writer:
|
143 |
+
for frame_idx, frame_data in enumerate(video_uint8_frames):
|
144 |
+
progress((frame_idx + 1) / len(video_uint8_frames), desc="Encoding video frames...")
|
145 |
+
writer.append_data(frame_data)
|
146 |
|
147 |
+
return output_filename
|
148 |
|
149 |
except Exception as e:
|
150 |
print(f"Error processing input video: {e}")
|