rahul7star commited on
Commit
3c91d3c
Β·
verified Β·
1 Parent(s): 93c177b

Update app_quant_latent1.py

Browse files
Files changed (1) hide show
  1. app_quant_latent1.py +8 -8
app_quant_latent1.py CHANGED
@@ -322,8 +322,8 @@ def generate_image(prompt, height, width, steps, seed, guidance_scale=0.0):
322
  LOGS.append(msg)
323
  print(msg)
324
 
325
- device = "cuda" if torch.cuda.is_available() else "cpu"
326
- generator = torch.Generator(device).manual_seed(int(seed))
327
 
328
  log("🎨 START IMAGE GENERATION")
329
 
@@ -331,7 +331,7 @@ log("🎨 START IMAGE GENERATION")
331
  # ==========================================================
332
  # πŸ§ͺ TRY ADVANCED LATENT GENERATOR (Your original generate())
333
  # ==========================================================
334
- latents, latent_err = safe_generate_with_latents(
335
  transformer=transformer,
336
  vae=vae,
337
  text_encoder=text_encoder,
@@ -349,9 +349,9 @@ latents, latent_err = safe_generate_with_latents(
349
  cfg_normalization=False,
350
  cfg_truncation=1.0,
351
  max_sequence_length=4096,
352
- )
353
 
354
- if latent_err is None:
355
  log("βœ… Latent generator succeeded.")
356
  try:
357
  # Decode latents to image
@@ -372,14 +372,14 @@ if latent_err is None:
372
  log(f"⚠️ Latent decode failed: {decode_error}")
373
  log("πŸ” Falling back to standard pipeline...")
374
 
375
- else:
376
  log(f"⚠️ Latent generator failed: {latent_err}")
377
  log("πŸ” Switching to standard pipeline...")
378
 
379
  # ==========================================================
380
  # 🟩 STANDARD PIPELINE FALLBACK (Never fails)
381
  # ==========================================================
382
- try:
383
  output = pipe(
384
  prompt=prompt,
385
  height=height,
@@ -392,7 +392,7 @@ try:
392
  log("🟒 Standard pipeline succeeded.")
393
  return image, None, LOGS
394
 
395
- except Exception as e:
396
  log(f"❌ Standard pipeline failed: {e}")
397
  return None, None, LOGS
398
 
 
322
  LOGS.append(msg)
323
  print(msg)
324
 
325
+
326
+ generator = torch.Generator(device).manual_seed(int(seed))
327
 
328
  log("🎨 START IMAGE GENERATION")
329
 
 
331
  # ==========================================================
332
  # πŸ§ͺ TRY ADVANCED LATENT GENERATOR (Your original generate())
333
  # ==========================================================
334
+ latents, latent_err = safe_generate_with_latents(
335
  transformer=transformer,
336
  vae=vae,
337
  text_encoder=text_encoder,
 
349
  cfg_normalization=False,
350
  cfg_truncation=1.0,
351
  max_sequence_length=4096,
352
+ )
353
 
354
+ if latent_err is None:
355
  log("βœ… Latent generator succeeded.")
356
  try:
357
  # Decode latents to image
 
372
  log(f"⚠️ Latent decode failed: {decode_error}")
373
  log("πŸ” Falling back to standard pipeline...")
374
 
375
+ else:
376
  log(f"⚠️ Latent generator failed: {latent_err}")
377
  log("πŸ” Switching to standard pipeline...")
378
 
379
  # ==========================================================
380
  # 🟩 STANDARD PIPELINE FALLBACK (Never fails)
381
  # ==========================================================
382
+ try:
383
  output = pipe(
384
  prompt=prompt,
385
  height=height,
 
392
  log("🟒 Standard pipeline succeeded.")
393
  return image, None, LOGS
394
 
395
+ except Exception as e:
396
  log(f"❌ Standard pipeline failed: {e}")
397
  return None, None, LOGS
398