Spaces:
Running
on
Zero
Running
on
Zero
Update
Browse files
app.py
CHANGED
@@ -27,8 +27,6 @@ if torch.cuda.is_available():
|
|
27 |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
28 |
pipe.enable_model_cpu_offload()
|
29 |
pipe.enable_vae_slicing()
|
30 |
-
else:
|
31 |
-
pipe = None
|
32 |
|
33 |
|
34 |
def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
|
@@ -37,7 +35,8 @@ def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
|
|
37 |
return seed
|
38 |
|
39 |
|
40 |
-
def to_video(frames:
|
|
|
41 |
out_file = tempfile.NamedTemporaryFile(suffix=".mp4", delete=False)
|
42 |
writer = imageio.get_writer(out_file.name, format="FFMPEG", fps=fps)
|
43 |
for frame in frames:
|
@@ -62,7 +61,7 @@ def generate(
|
|
62 |
width=576,
|
63 |
height=320,
|
64 |
generator=generator,
|
65 |
-
).frames
|
66 |
return to_video(frames, 8)
|
67 |
|
68 |
|
|
|
27 |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
28 |
pipe.enable_model_cpu_offload()
|
29 |
pipe.enable_vae_slicing()
|
|
|
|
|
30 |
|
31 |
|
32 |
def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
|
|
|
35 |
return seed
|
36 |
|
37 |
|
38 |
+
def to_video(frames: np.ndarray, fps: int) -> str:
|
39 |
+
frames = np.clip((frames * 255), 0, 255).astype(np.uint8)
|
40 |
out_file = tempfile.NamedTemporaryFile(suffix=".mp4", delete=False)
|
41 |
writer = imageio.get_writer(out_file.name, format="FFMPEG", fps=fps)
|
42 |
for frame in frames:
|
|
|
61 |
width=576,
|
62 |
height=320,
|
63 |
generator=generator,
|
64 |
+
).frames[0]
|
65 |
return to_video(frames, 8)
|
66 |
|
67 |
|