Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -110,16 +110,16 @@ def generate(segment, image, prompt, size, guidance_scale, num_inference_steps,
|
|
110 |
segment_timesteps = torch.from_numpy(timesteps_split_np[0]).to("cuda")
|
111 |
num_channels_latents = pipe.transformer.config.in_channels
|
112 |
num_channels_latents = int(num_channels_latents / 2)
|
113 |
-
image = pipe.video_processor.preprocess(image, height=
|
114 |
device, dtype=prompt_embeds.dtype
|
115 |
)
|
116 |
num_latent_frames = (frames - 1) // pipe.vae_scale_factor_temporal + 1
|
117 |
latents = pipe.prepare_latents(
|
118 |
-
batch_size=1, num_channels_latents=pipe.transformer.config.in_channels, height=
|
119 |
dtype=torch.float32, device=device, generator=generator, latents=None,
|
120 |
)
|
121 |
image_latents = pipe.image_latents(
|
122 |
-
image, batch_size,
|
123 |
)
|
124 |
image_latents = image_latents.to(pipe.transformer.dtype)
|
125 |
guidance = torch.tensor([guidance_scale] * latents.shape[0], dtype=transformer_dtype, device=device) * 1000.0
|
@@ -130,8 +130,8 @@ def generate(segment, image, prompt, size, guidance_scale, num_inference_steps,
|
|
130 |
latents = state["intermediate_latents"].to("cuda", dtype=torch.bfloat16)
|
131 |
guidance_scale = state["guidance_scale"]
|
132 |
all_timesteps_cpu = state["all_timesteps"]
|
133 |
-
|
134 |
-
|
135 |
pipe.scheduler.set_timesteps(len(all_timesteps_cpu), device=device)
|
136 |
timesteps_split_np = np.array_split(all_timesteps_cpu.numpy(), 8)
|
137 |
segment_timesteps = torch.from_numpy(timesteps_split_np[segment - 1]).to("cuda")
|
@@ -194,8 +194,8 @@ def generate(segment, image, prompt, size, guidance_scale, num_inference_steps,
|
|
194 |
"seed": seed,
|
195 |
"prompt": prompt, # Save originals for reference/verification
|
196 |
"negative_prompt": negative_prompt,
|
197 |
-
"height":
|
198 |
-
"width":
|
199 |
}
|
200 |
state_file = f"SkyReel_{segment}_{seed}.pt"
|
201 |
torch.save(state, state_file)
|
|
|
110 |
segment_timesteps = torch.from_numpy(timesteps_split_np[0]).to("cuda")
|
111 |
num_channels_latents = pipe.transformer.config.in_channels
|
112 |
num_channels_latents = int(num_channels_latents / 2)
|
113 |
+
image = pipe.video_processor.preprocess(image, height=size, width=size).to(
|
114 |
device, dtype=prompt_embeds.dtype
|
115 |
)
|
116 |
num_latent_frames = (frames - 1) // pipe.vae_scale_factor_temporal + 1
|
117 |
latents = pipe.prepare_latents(
|
118 |
+
batch_size=1, num_channels_latents=pipe.transformer.config.in_channels, height=size, width=size, num_frames=frames,
|
119 |
dtype=torch.float32, device=device, generator=generator, latents=None,
|
120 |
)
|
121 |
image_latents = pipe.image_latents(
|
122 |
+
image, batch_size, size, size, device, torch.float32, num_channels_latents, num_latent_frames
|
123 |
)
|
124 |
image_latents = image_latents.to(pipe.transformer.dtype)
|
125 |
guidance = torch.tensor([guidance_scale] * latents.shape[0], dtype=transformer_dtype, device=device) * 1000.0
|
|
|
130 |
latents = state["intermediate_latents"].to("cuda", dtype=torch.bfloat16)
|
131 |
guidance_scale = state["guidance_scale"]
|
132 |
all_timesteps_cpu = state["all_timesteps"]
|
133 |
+
size = state["height"]
|
134 |
+
size = state["width"]
|
135 |
pipe.scheduler.set_timesteps(len(all_timesteps_cpu), device=device)
|
136 |
timesteps_split_np = np.array_split(all_timesteps_cpu.numpy(), 8)
|
137 |
segment_timesteps = torch.from_numpy(timesteps_split_np[segment - 1]).to("cuda")
|
|
|
194 |
"seed": seed,
|
195 |
"prompt": prompt, # Save originals for reference/verification
|
196 |
"negative_prompt": negative_prompt,
|
197 |
+
"height": size, # Save dimensions used
|
198 |
+
"width": size
|
199 |
}
|
200 |
state_file = f"SkyReel_{segment}_{seed}.pt"
|
201 |
torch.save(state, state_file)
|