Spaces:
Paused
Paused
Commit
·
b0df1f2
1
Parent(s):
93fbc4c
Fix video export to match original repo implementation
Browse filesUse the correct output format: pipe()[0] then video[0]
Remove unnecessary tensor conversion logic
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
app.py
CHANGED
|
@@ -61,7 +61,7 @@ def generate_interpolation(
|
|
| 61 |
# Generate video
|
| 62 |
generator = torch.Generator(device="cuda").manual_seed(seed)
|
| 63 |
|
| 64 |
-
|
| 65 |
prompt=prompt,
|
| 66 |
first_image=first_image,
|
| 67 |
last_image=last_image,
|
|
@@ -70,36 +70,14 @@ def generate_interpolation(
|
|
| 70 |
num_frames=num_frames,
|
| 71 |
guidance_scale=guidance_scale,
|
| 72 |
generator=generator,
|
| 73 |
-
)
|
| 74 |
-
|
| 75 |
-
# Extract video frames - handle different output formats
|
| 76 |
-
if hasattr(output, 'frames'):
|
| 77 |
-
video_frames = output.frames[0]
|
| 78 |
-
elif isinstance(output, (list, tuple)):
|
| 79 |
-
video_frames = output[0]
|
| 80 |
-
else:
|
| 81 |
-
video_frames = output
|
| 82 |
-
|
| 83 |
-
# Convert tensor to numpy if needed
|
| 84 |
-
if torch.is_tensor(video_frames):
|
| 85 |
-
video_frames = video_frames.cpu().numpy()
|
| 86 |
-
|
| 87 |
-
# Ensure correct format: list of numpy arrays in [0, 255] range
|
| 88 |
-
if isinstance(video_frames, np.ndarray):
|
| 89 |
-
# If shape is (frames, height, width, channels)
|
| 90 |
-
if video_frames.ndim == 4:
|
| 91 |
-
# Convert from float [0, 1] to uint8 [0, 255] if needed
|
| 92 |
-
if video_frames.dtype == np.float32 or video_frames.dtype == np.float64:
|
| 93 |
-
video_frames = (video_frames * 255).astype(np.uint8)
|
| 94 |
-
# Convert to list of frames
|
| 95 |
-
video_frames = [video_frames[i] for i in range(video_frames.shape[0])]
|
| 96 |
|
| 97 |
# Export to temporary file
|
| 98 |
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".mp4")
|
| 99 |
output_path = temp_file.name
|
| 100 |
temp_file.close()
|
| 101 |
|
| 102 |
-
export_to_video(
|
| 103 |
|
| 104 |
status = f"✓ Video generated successfully! ({num_frames} frames at {fps} fps)"
|
| 105 |
print(status)
|
|
|
|
| 61 |
# Generate video
|
| 62 |
generator = torch.Generator(device="cuda").manual_seed(seed)
|
| 63 |
|
| 64 |
+
video = pipe(
|
| 65 |
prompt=prompt,
|
| 66 |
first_image=first_image,
|
| 67 |
last_image=last_image,
|
|
|
|
| 70 |
num_frames=num_frames,
|
| 71 |
guidance_scale=guidance_scale,
|
| 72 |
generator=generator,
|
| 73 |
+
)[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
# Export to temporary file
|
| 76 |
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".mp4")
|
| 77 |
output_path = temp_file.name
|
| 78 |
temp_file.close()
|
| 79 |
|
| 80 |
+
export_to_video(video[0], output_path, fps=fps)
|
| 81 |
|
| 82 |
status = f"✓ Video generated successfully! ({num_frames} frames at {fps} fps)"
|
| 83 |
print(status)
|