Spaces:
Running
on
Zero
Running
on
Zero
Update model.py
Browse files
model.py
CHANGED
|
@@ -11,7 +11,7 @@ from diffusers import (
|
|
| 11 |
# Import the custom pipeline from your local file
|
| 12 |
from pipeline_stable_diffusion_xl_instantid_img2img import StableDiffusionXLInstantIDImg2ImgPipeline
|
| 13 |
|
| 14 |
-
from huggingface_hub import snapshot_download, hf_hub_download
|
| 15 |
from insightface.app import FaceAnalysis
|
| 16 |
from controlnet_aux import ZoeDetector, LineartDetector
|
| 17 |
|
|
@@ -113,9 +113,7 @@ class ModelHandler:
|
|
| 113 |
# 5. Load Adapters (IP-Adapter & LoRA)
|
| 114 |
print("Loading Adapters (IP-Adapter & LoRA)...")
|
| 115 |
|
| 116 |
-
#
|
| 117 |
-
# We must download the ip-adapter.bin file and pass its local path,
|
| 118 |
-
# not the repository name.
|
| 119 |
ip_adapter_filename = "ip-adapter.bin"
|
| 120 |
ip_adapter_local_path = os.path.join("./models", ip_adapter_filename)
|
| 121 |
|
|
@@ -130,8 +128,7 @@ class ModelHandler:
|
|
| 130 |
|
| 131 |
# The custom pipeline has this method, now pass the LOCAL FILE PATH
|
| 132 |
print(f"Loading IP-Adapter from local file: {ip_adapter_local_path}")
|
| 133 |
-
self.pipeline.load_ip_adapter_instantid(ip_adapter_local_path) #
|
| 134 |
-
# --- END FIX ---
|
| 135 |
|
| 136 |
self.pipeline.load_lora_weights(Config.REPO_ID, weight_name=Config.LORA_FILENAME)
|
| 137 |
self.pipeline.fuse_lora(lora_scale=1.0)
|
|
@@ -150,7 +147,9 @@ class ModelHandler:
|
|
| 150 |
|
| 151 |
try:
|
| 152 |
# Convert PIL to CV2
|
| 153 |
-
|
|
|
|
|
|
|
| 154 |
faces = self.app.get(cv2_img)
|
| 155 |
|
| 156 |
if len(faces) == 0:
|
|
|
|
| 11 |
# Import the custom pipeline from your local file
|
| 12 |
from pipeline_stable_diffusion_xl_instantid_img2img import StableDiffusionXLInstantIDImg2ImgPipeline
|
| 13 |
|
| 14 |
+
from huggingface_hub import snapshot_download, hf_hub_download
|
| 15 |
from insightface.app import FaceAnalysis
|
| 16 |
from controlnet_aux import ZoeDetector, LineartDetector
|
| 17 |
|
|
|
|
| 113 |
# 5. Load Adapters (IP-Adapter & LoRA)
|
| 114 |
print("Loading Adapters (IP-Adapter & LoRA)...")
|
| 115 |
|
| 116 |
+
# Download the ip-adapter.bin file and pass its local path
|
|
|
|
|
|
|
| 117 |
ip_adapter_filename = "ip-adapter.bin"
|
| 118 |
ip_adapter_local_path = os.path.join("./models", ip_adapter_filename)
|
| 119 |
|
|
|
|
| 128 |
|
| 129 |
# The custom pipeline has this method, now pass the LOCAL FILE PATH
|
| 130 |
print(f"Loading IP-Adapter from local file: {ip_adapter_local_path}")
|
| 131 |
+
self.pipeline.load_ip_adapter_instantid(ip_adapter_local_path) # Pass local path
|
|
|
|
| 132 |
|
| 133 |
self.pipeline.load_lora_weights(Config.REPO_ID, weight_name=Config.LORA_FILENAME)
|
| 134 |
self.pipeline.fuse_lora(lora_scale=1.0)
|
|
|
|
| 147 |
|
| 148 |
try:
|
| 149 |
# Convert PIL to CV2
|
| 150 |
+
# --- START FIX ---
|
| 151 |
+
cv2_img = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR) # <-- Corrected typo
|
| 152 |
+
# --- END FIX ---
|
| 153 |
faces = self.app.get(cv2_img)
|
| 154 |
|
| 155 |
if len(faces) == 0:
|