Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,17 +23,23 @@ except Exception as e:
|
|
| 23 |
raise RuntimeError(f"Failed to load InsightFace model: {e}. Ensure network access for initial download.")
|
| 24 |
|
| 25 |
# Define paths for preloaded weights
|
| 26 |
-
model_path = "./
|
| 27 |
ip_adapter_path = "./"
|
| 28 |
|
| 29 |
-
# Debug: List files
|
| 30 |
print("Files in root directory:", os.listdir("."))
|
| 31 |
print("Files in ./unet/ directory:", os.listdir("./unet") if os.path.exists("./unet") else "No ./unet/ directory")
|
| 32 |
|
| 33 |
# Check if weights exist
|
| 34 |
kolors_weights = model_path + "diffusion_pytorch_model.safetensors"
|
| 35 |
if not os.path.exists(kolors_weights):
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
if not os.path.exists(ip_adapter_path + "ip-adapter.bin"):
|
| 38 |
raise FileNotFoundError(f"IP-Adapter weights not found at {ip_adapter_path}")
|
| 39 |
|
|
|
|
| 23 |
raise RuntimeError(f"Failed to load InsightFace model: {e}. Ensure network access for initial download.")
|
| 24 |
|
| 25 |
# Define paths for preloaded weights
|
| 26 |
+
model_path = "./" # Start with root, adjust if needed
|
| 27 |
ip_adapter_path = "./"
|
| 28 |
|
| 29 |
+
# Debug: List files to confirm preloading
|
| 30 |
print("Files in root directory:", os.listdir("."))
|
| 31 |
print("Files in ./unet/ directory:", os.listdir("./unet") if os.path.exists("./unet") else "No ./unet/ directory")
|
| 32 |
|
| 33 |
# Check if weights exist
|
| 34 |
kolors_weights = model_path + "diffusion_pytorch_model.safetensors"
|
| 35 |
if not os.path.exists(kolors_weights):
|
| 36 |
+
# Check if it's in ./unet/ as a fallback
|
| 37 |
+
kolors_weights_unet = "./unet/diffusion_pytorch_model.safetensors"
|
| 38 |
+
if os.path.exists(kolors_weights_unet):
|
| 39 |
+
model_path = "./unet/"
|
| 40 |
+
kolors_weights = kolors_weights_unet
|
| 41 |
+
else:
|
| 42 |
+
raise FileNotFoundError(f"Kolors model weights not found at {kolors_weights} or {kolors_weights_unet}. Preloading failed. Please check .env configuration.")
|
| 43 |
if not os.path.exists(ip_adapter_path + "ip-adapter.bin"):
|
| 44 |
raise FileNotFoundError(f"IP-Adapter weights not found at {ip_adapter_path}")
|
| 45 |
|