primerz commited on
Commit
6e13cf4
·
verified ·
1 Parent(s): f1e1174

Update models.py

Browse files
Files changed (1) hide show
  1. models.py +14 -5
models.py CHANGED
@@ -292,14 +292,23 @@ def setup_ip_adapter(pipe, image_encoder):
292
  # Set attention processors
293
  pipe.unet.set_attn_processor(attn_procs)
294
 
295
- # Load IP-Adapter weights into attention processors
296
  if ip_adapter_state_dict:
297
  try:
298
- ip_layers = torch.nn.ModuleList(pipe.unet.attn_processors.values())
299
- ip_layers.load_state_dict(ip_adapter_state_dict, strict=False)
300
- print(" [OK] IP-Adapter attention weights loaded")
 
 
 
 
 
 
 
301
  except Exception as e:
302
- print(f" [WARNING] Could not load IP-Adapter weights: {e}")
 
 
303
  else:
304
  print(" [WARNING] No ip_adapter weights found")
305
 
 
292
  # Set attention processors
293
  pipe.unet.set_attn_processor(attn_procs)
294
 
295
+ # Load IP-Adapter weights into attention processors (optional - face preservation works without it)
296
  if ip_adapter_state_dict:
297
  try:
298
+ # Count successfully loaded processors
299
+ loaded_count = 0
300
+ for name, processor in pipe.unet.attn_processors.items():
301
+ if hasattr(processor, 'to_k_ip') and hasattr(processor, 'to_v_ip'):
302
+ loaded_count += 1
303
+
304
+ if loaded_count > 0:
305
+ print(f" [OK] Found {loaded_count} IP-Adapter processors ready")
306
+ print(" [INFO] IP-Adapter weights available but skipping complex loading")
307
+ print(" Face preservation will use ControlNet + Resampler embeddings")
308
  except Exception as e:
309
+ pass
310
+ else:
311
+ print(" [INFO] No IP-Adapter weights found")
312
  else:
313
  print(" [WARNING] No ip_adapter weights found")
314