primerz commited on
Commit
c336b59
·
verified ·
1 Parent(s): 97a7af1

Update generator.py

Browse files
Files changed (1) hide show
  1. generator.py +20 -21
generator.py CHANGED
@@ -305,9 +305,9 @@ class RetroArtConverter:
305
  # Generate depth map
306
  depth_image = self.get_depth_map(resized_image)
307
 
308
- # ═══════════════════════════════════════════════════════════
309
  # FACE DETECTION
310
- # ═══════════════════════════════════════════════════════════
311
  has_detected_faces = False
312
  face_kps_image = None
313
  face_embeddings = None
@@ -355,15 +355,14 @@ class RetroArtConverter:
355
  except Exception as e:
356
  print(f"[LORA] Could not fuse: {e}")
357
 
358
- # ═══════════════════════════════════════════════════════════
359
  # PIPELINE CONFIGURATION
360
- # ═══════════════════════════════════════════════════════════
361
  pipe_kwargs = {
362
  "image": resized_image,
363
  "strength": strength,
364
  "num_inference_steps": num_inference_steps,
365
  "guidance_scale": guidance_scale,
366
- "cross_attention_kwargs": {"scale": lora_scale},
367
  }
368
 
369
  # Setup generator with seed
@@ -398,14 +397,14 @@ class RetroArtConverter:
398
  pipe_kwargs["prompt"] = prompt
399
  pipe_kwargs["negative_prompt"] = negative_prompt
400
 
401
- # ═══════════════════════════════════════════════════════════
402
  # CONTROLNET + IP-ADAPTER CONFIGURATION
403
- # ═══════════════════════════════════════════════════════════
404
 
405
  if has_detected_faces and face_kps_image is not None and face_embeddings is not None:
406
- print("═" * 60)
407
  print("MODE: InstantID (Face Keypoints + Depth + IP-Adapter)")
408
- print("═" * 60)
409
 
410
  # Set IP-Adapter scale
411
  self.pipe.set_ip_adapter_scale(identity_preservation)
@@ -430,13 +429,13 @@ class RetroArtConverter:
430
  print(f" [CONTROLNET] Identity scale: {identity_control_scale}")
431
  print(f" [CONTROLNET] Depth scale: {depth_control_scale}")
432
  print(f" [EMBEDDINGS] Shape: {face_embeddings.shape} (raw)")
433
- print(" [INFO] Pipeline will handle: Resampler → Concatenation → Attention")
434
- print("═" * 60)
435
 
436
  elif has_detected_faces and face_kps_image is not None:
437
- print("═" * 60)
438
  print("MODE: InstantID Keypoints Only (no embeddings)")
439
- print("═" * 60)
440
 
441
  # Disable IP-Adapter
442
  self.pipe.set_ip_adapter_scale(0.0)
@@ -456,12 +455,12 @@ class RetroArtConverter:
456
  pipe_kwargs["image_embeds"] = zero_embeddings
457
 
458
  print(" [INFO] Using keypoints for structure only (zero embeddings)")
459
- print("═" * 60)
460
 
461
  else:
462
- print("═" * 60)
463
  print("MODE: Depth Only (no face detection)")
464
- print("═" * 60)
465
 
466
  # Disable IP-Adapter
467
  self.pipe.set_ip_adapter_scale(0.0)
@@ -479,20 +478,20 @@ class RetroArtConverter:
479
 
480
  print(f" [CONTROLNET] Depth scale: {depth_control_scale}")
481
  print(" [INFO] Generating without face preservation (zero embeddings)")
482
- print("═" * 60)
483
 
484
- # ═══════════════════════════════════════════════════════════
485
  # GENERATION
486
- # ═══════════════════════════════════════════════════════════
487
  print(f"\nGenerating: Steps={num_inference_steps}, CFG={guidance_scale}, Strength={strength}")
488
 
489
  result = self.pipe(**pipe_kwargs)
490
 
491
  generated_image = result.images[0]
492
 
493
- # ═══════════════════════════════════════════════════════════
494
  # POST-PROCESSING
495
- # ═══════════════════════════════════════════════════════════
496
  if enable_color_matching and has_detected_faces:
497
  print("Applying enhanced face-aware color matching...")
498
  try:
 
305
  # Generate depth map
306
  depth_image = self.get_depth_map(resized_image)
307
 
308
+ # ═══════════════════════════════════════════════════════════
309
  # FACE DETECTION
310
+ # ═══════════════════════════════════════════════════════════
311
  has_detected_faces = False
312
  face_kps_image = None
313
  face_embeddings = None
 
355
  except Exception as e:
356
  print(f"[LORA] Could not fuse: {e}")
357
 
358
+ # ═══════════════════════════════════════════════════════════
359
  # PIPELINE CONFIGURATION
360
+ # ════════════��══════════════════════════════════════════════
361
  pipe_kwargs = {
362
  "image": resized_image,
363
  "strength": strength,
364
  "num_inference_steps": num_inference_steps,
365
  "guidance_scale": guidance_scale,
 
366
  }
367
 
368
  # Setup generator with seed
 
397
  pipe_kwargs["prompt"] = prompt
398
  pipe_kwargs["negative_prompt"] = negative_prompt
399
 
400
+ # ═══════════════════════════════════════════════════════════
401
  # CONTROLNET + IP-ADAPTER CONFIGURATION
402
+ # ═══════════════════════════════════════════════════════════
403
 
404
  if has_detected_faces and face_kps_image is not None and face_embeddings is not None:
405
+ print("═" * 60)
406
  print("MODE: InstantID (Face Keypoints + Depth + IP-Adapter)")
407
+ print("═" * 60)
408
 
409
  # Set IP-Adapter scale
410
  self.pipe.set_ip_adapter_scale(identity_preservation)
 
429
  print(f" [CONTROLNET] Identity scale: {identity_control_scale}")
430
  print(f" [CONTROLNET] Depth scale: {depth_control_scale}")
431
  print(f" [EMBEDDINGS] Shape: {face_embeddings.shape} (raw)")
432
+ print(" [INFO] Pipeline will handle: Resampler → Concatenation → Attention")
433
+ print("═" * 60)
434
 
435
  elif has_detected_faces and face_kps_image is not None:
436
+ print("═" * 60)
437
  print("MODE: InstantID Keypoints Only (no embeddings)")
438
+ print("═" * 60)
439
 
440
  # Disable IP-Adapter
441
  self.pipe.set_ip_adapter_scale(0.0)
 
455
  pipe_kwargs["image_embeds"] = zero_embeddings
456
 
457
  print(" [INFO] Using keypoints for structure only (zero embeddings)")
458
+ print("═" * 60)
459
 
460
  else:
461
+ print("═" * 60)
462
  print("MODE: Depth Only (no face detection)")
463
+ print("═" * 60)
464
 
465
  # Disable IP-Adapter
466
  self.pipe.set_ip_adapter_scale(0.0)
 
478
 
479
  print(f" [CONTROLNET] Depth scale: {depth_control_scale}")
480
  print(" [INFO] Generating without face preservation (zero embeddings)")
481
+ print("═" * 60)
482
 
483
+ # ═══════════════════════════════════════════════════════════
484
  # GENERATION
485
+ # ═══════════════════════════════════════════════════════════
486
  print(f"\nGenerating: Steps={num_inference_steps}, CFG={guidance_scale}, Strength={strength}")
487
 
488
  result = self.pipe(**pipe_kwargs)
489
 
490
  generated_image = result.images[0]
491
 
492
+ # ════════════════════════��══════════════════════════════════
493
  # POST-PROCESSING
494
+ # ═══════════════════════════════════════════════════════════
495
  if enable_color_matching and has_detected_faces:
496
  print("Applying enhanced face-aware color matching...")
497
  try: