ford442 commited on
Commit
6e951bd
·
verified ·
1 Parent(s): 88e1a4e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -154,9 +154,10 @@ def generate(
154
  )
155
  pipe.scheduler.set_timesteps(num_inference_steps, device=torch.device('cuda'))
156
  timesteps = pipe.scheduler.timesteps
157
-
 
 
158
  split_point = num_inference_steps // 8
159
-
160
  segment_timesteps = timesteps[:split_point].to("cuda") # Slice from CPU list, move to GPU
161
  num_channels_latents = pipe.unet.config.in_channels
162
  latents = pipe.prepare_latents(
@@ -192,7 +193,7 @@ def generate(
192
  guidance_scale = state["guidance_scale"]
193
  all_timesteps_cpu = state["all_timesteps"]
194
 
195
- timesteps_split = state["timesteps_split"]
196
  timesteps_chunk_np = state["timesteps_split"][segment - 1]
197
  segment_timesteps = torch.from_numpy(timesteps_chunk_np).to("cuda")
198
 
@@ -218,7 +219,6 @@ def generate(
218
 
219
  added_cond_kwargs = {"text_embeds": unet_added_text_embeds, "time_ids": loop_add_time_ids}
220
  current_latents = latents # Start with loaded intermediate latents
221
-
222
 
223
  for i, t in enumerate(pipe.progress_bar(segment_timesteps)): # Only first half timesteps
224
  latent_model_input = torch.cat([current_latents] * 2) if guidance_scale > 1.0 else current_latents
@@ -255,9 +255,7 @@ def generate(
255
  "negative_pooled_prompt_embeds": original_negative_pooled_prompt_embeds_cpu,
256
  "add_time_ids": original_add_time_ids_cpu, # Save ORIGINAL time IDs
257
  "guidance_scale": guidance_scale,
258
-
259
- "timesteps_split": timesteps_split,
260
-
261
  "seed": seed,
262
  "prompt": prompt, # Save originals for reference/verification
263
  "negative_prompt": negative_prompt,
@@ -293,7 +291,7 @@ with gr.Blocks(theme=gr.themes.Origin()) as demo:
293
  slider = gr.Slider(
294
  minimum=1,
295
  maximum=250,
296
- value=[i * 125],
297
  step=1,
298
  label=f"Range {i + 1}",
299
  )
 
154
  )
155
  pipe.scheduler.set_timesteps(num_inference_steps, device=torch.device('cuda'))
156
  timesteps = pipe.scheduler.timesteps
157
+ all_timesteps_cpu = timesteps.cpu()
158
+ timesteps_split_np = np.array_split(all_timesteps_cpu.numpy(), 8)
159
+ timesteps_split_for_state = [chunk for chunk in timesteps_split_np] # Store list of numpy arrays
160
  split_point = num_inference_steps // 8
 
161
  segment_timesteps = timesteps[:split_point].to("cuda") # Slice from CPU list, move to GPU
162
  num_channels_latents = pipe.unet.config.in_channels
163
  latents = pipe.prepare_latents(
 
193
  guidance_scale = state["guidance_scale"]
194
  all_timesteps_cpu = state["all_timesteps"]
195
 
196
+ timesteps_split_for_state = state["timesteps_split"]
197
  timesteps_chunk_np = state["timesteps_split"][segment - 1]
198
  segment_timesteps = torch.from_numpy(timesteps_chunk_np).to("cuda")
199
 
 
219
 
220
  added_cond_kwargs = {"text_embeds": unet_added_text_embeds, "time_ids": loop_add_time_ids}
221
  current_latents = latents # Start with loaded intermediate latents
 
222
 
223
  for i, t in enumerate(pipe.progress_bar(segment_timesteps)): # Only first half timesteps
224
  latent_model_input = torch.cat([current_latents] * 2) if guidance_scale > 1.0 else current_latents
 
255
  "negative_pooled_prompt_embeds": original_negative_pooled_prompt_embeds_cpu,
256
  "add_time_ids": original_add_time_ids_cpu, # Save ORIGINAL time IDs
257
  "guidance_scale": guidance_scale,
258
+ "timesteps_split": timesteps_split_for_state,
 
 
259
  "seed": seed,
260
  "prompt": prompt, # Save originals for reference/verification
261
  "negative_prompt": negative_prompt,
 
291
  slider = gr.Slider(
292
  minimum=1,
293
  maximum=250,
294
+ value=[i * (master_slider // 8)],
295
  step=1,
296
  label=f"Range {i + 1}",
297
  )