Jit2024 commited on
Commit
7fee2f2
·
1 Parent(s): 7a2e044

Fix ZeroGPU 90-second timeout by avoiding root-level packing. Move pipe to GPU dynamically inside the worker for fast generation.

Browse files
Files changed (1) hide show
  1. app.py +19 -14
app.py CHANGED
@@ -116,8 +116,9 @@ gc.collect()
116
  pipe = QwenImageEditPlusPipeline.from_pretrained(
117
  "Qwen/Qwen-Image-Edit-2511",
118
  transformer=transformer,
119
- torch_dtype=dtype
120
- ).to(device)
 
121
 
122
  # Load next-scene LoRA for cinematic progression
123
  # Note: This LoRA was trained on 2509, may need testing with 2511/v18
@@ -237,18 +238,22 @@ def infer(
237
  print(f"Negative Prompt: '{negative_prompt}'")
238
  print(f"Seed: {seed}, Steps: {num_inference_steps}, Guidance: {true_guidance_scale}, Size: {width}x{height}")
239
 
240
- # Generate the image
241
- images_pil = pipe(
242
- image=pil_images if len(pil_images) > 0 else None,
243
- prompt=prompt,
244
- height=height,
245
- width=width,
246
- negative_prompt=negative_prompt,
247
- num_inference_steps=num_inference_steps,
248
- generator=generator,
249
- true_cfg_scale=true_guidance_scale,
250
- num_images_per_prompt=num_images_per_prompt,
251
- ).images
 
 
 
 
252
 
253
  # Anonymous diagnostics — fire-and-forget, must not block or fail generation.
254
  try:
 
116
  pipe = QwenImageEditPlusPipeline.from_pretrained(
117
  "Qwen/Qwen-Image-Edit-2511",
118
  transformer=transformer,
119
+ torch_dtype=dtype,
120
+ ignore_patterns=["transformer/*"]
121
+ )
122
 
123
  # Load next-scene LoRA for cinematic progression
124
  # Note: This LoRA was trained on 2509, may need testing with 2511/v18
 
238
  print(f"Negative Prompt: '{negative_prompt}'")
239
  print(f"Seed: {seed}, Steps: {num_inference_steps}, Guidance: {true_guidance_scale}, Size: {width}x{height}")
240
 
241
+ # Generate the image (move to GPU dynamically to avoid packing timeout at startup)
242
+ try:
243
+ pipe.to(device)
244
+ images_pil = pipe(
245
+ image=pil_images if len(pil_images) > 0 else None,
246
+ prompt=prompt,
247
+ height=height,
248
+ width=width,
249
+ negative_prompt=negative_prompt,
250
+ num_inference_steps=num_inference_steps,
251
+ generator=generator,
252
+ true_cfg_scale=true_guidance_scale,
253
+ num_images_per_prompt=num_images_per_prompt,
254
+ ).images
255
+ finally:
256
+ pipe.to("cpu")
257
 
258
  # Anonymous diagnostics — fire-and-forget, must not block or fail generation.
259
  try: