Update app.py
Browse files
app.py
CHANGED
@@ -58,7 +58,22 @@ def generate_and_export_animation(prompt):
|
|
58 |
with tempfile.NamedTemporaryFile(suffix='.mp4', delete=False) as temp_file:
|
59 |
temp_video_path = temp_file.name
|
60 |
print('temp_video_path', temp_video_path)
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
with open(temp_video_path, 'rb') as video_file:
|
64 |
video_binary = video_file.read()
|
|
|
58 |
with tempfile.NamedTemporaryFile(suffix='.mp4', delete=False) as temp_file:
|
59 |
temp_video_path = temp_file.name
|
60 |
print('temp_video_path', temp_video_path)
|
61 |
+
|
62 |
+
processed_frames = []
|
63 |
+
for frame_tensor in output.frames:
|
64 |
+
# Convert frame tensor to numpy array
|
65 |
+
frame_numpy = frame_tensor.cpu().numpy()
|
66 |
+
|
67 |
+
# # Ensure frame has the correct shape (H, W, C)
|
68 |
+
# if len(frame_numpy.shape) == 4:
|
69 |
+
frame_numpy = frame_numpy.squeeze(0)
|
70 |
+
|
71 |
+
# Append processed frame to the list
|
72 |
+
processed_frames.append(frame_numpy)
|
73 |
+
|
74 |
+
# Export processed frames to a video file
|
75 |
+
export_to_video(processed_frames, temp_video_path)
|
76 |
+
# export_to_video(output.frames, temp_video_path)
|
77 |
|
78 |
with open(temp_video_path, 'rb') as video_file:
|
79 |
video_binary = video_file.read()
|