primerz commited on
Commit
aafb1d2
·
verified ·
1 Parent(s): 99cd3f0

Update models.py

Browse files
Files changed (1) hide show
  1. models.py +11 -12
models.py CHANGED
@@ -18,8 +18,8 @@ from insightface.app import FaceAnalysis
18
  from controlnet_aux import ZoeDetector, OpenposeDetector, LeresDetector, MidasDetector, MediapipeFaceDetector
19
  from huggingface_hub import hf_hub_download, snapshot_download
20
 
21
- # --- START FIX: Import CompelForSDXL ---
22
- from compel import CompelForSDXL
23
  # --- END FIX ---
24
 
25
  # Use reference implementation's attention processor
@@ -385,17 +385,16 @@ def setup_ip_adapter(pipe, image_encoder):
385
  return None, False
386
 
387
 
388
- # --- START FIX: Use CompelForSDXL and ENABLE TRUNCATION ---
389
- def setup_compel(pipe):
390
- """Setup CompelForSDXL for better SDXL prompt handling."""
391
- print("Setting up Compel for enhanced prompt processing (using CompelForSDXL)...")
392
  try:
393
- # Pass the whole pipeline and enable truncation
394
- compel = CompelForSDXL(pipe, truncate_long_prompts=True)
395
- print(" [OK] CompelForSDXL loaded successfully (with truncation)")
396
- return compel, True
397
  except Exception as e:
398
- print(f" [WARNING] Compel not available: {e}")
399
  return None, False
400
  # --- END FIX ---
401
 
@@ -469,4 +468,4 @@ def set_clip_skip(pipe):
469
  print(f" [OK] CLIP skip set to {CLIP_SKIP}")
470
 
471
 
472
- print("[OK] Model loading functions ready")
 
18
  from controlnet_aux import ZoeDetector, OpenposeDetector, LeresDetector, MidasDetector, MediapipeFaceDetector
19
  from huggingface_hub import hf_hub_download, snapshot_download
20
 
21
+ # --- START FIX: Import our new Cappella module ---
22
+ from cappella import Cappella
23
  # --- END FIX ---
24
 
25
  # Use reference implementation's attention processor
 
385
  return None, False
386
 
387
 
388
+ # --- START FIX: Use our new Cappella module ---
389
+ def setup_cappella(pipe):
390
+ """Setup Cappella for our custom prompt encoding."""
391
+ print("Setting up Cappella (custom prompt encoder)...")
392
  try:
393
+ cappella = Cappella(pipe, device)
394
+ print(" [OK] Cappella loaded successfully.")
395
+ return cappella, True
 
396
  except Exception as e:
397
+ print(f" [WARNING] Cappella not available: {e}")
398
  return None, False
399
  # --- END FIX ---
400
 
 
468
  print(f" [OK] CLIP skip set to {CLIP_SKIP}")
469
 
470
 
471
+ print("[OK] Model loading functions ready")