Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import cv2
|
|
| 2 |
import torch
|
| 3 |
import numpy as np
|
| 4 |
import gradio as gr
|
| 5 |
-
from diffusers import
|
| 6 |
from insightface.app import FaceAnalysis
|
| 7 |
from huggingface_hub import hf_hub_download
|
| 8 |
import os
|
|
@@ -73,15 +73,15 @@ ip_adapter_weights = download_file(
|
|
| 73 |
ip_adapter_path
|
| 74 |
)
|
| 75 |
|
| 76 |
-
# Load the pipeline with
|
| 77 |
-
logger.info("Loading Stable Diffusion
|
| 78 |
try:
|
| 79 |
max_retries = 3
|
| 80 |
for attempt in range(max_retries):
|
| 81 |
try:
|
| 82 |
-
logger.info(f"Attempt {attempt + 1}/{max_retries}: Loading
|
| 83 |
-
pipe =
|
| 84 |
-
"stabilityai/stable-diffusion-
|
| 85 |
torch_dtype=dtype,
|
| 86 |
safety_checker=None,
|
| 87 |
local_files_only=False,
|
|
@@ -89,7 +89,7 @@ try:
|
|
| 89 |
variant="fp16",
|
| 90 |
use_safetensors=True
|
| 91 |
)
|
| 92 |
-
logger.info("
|
| 93 |
break
|
| 94 |
except Exception as e:
|
| 95 |
logger.error(f"Load attempt {attempt + 1} failed: {e}")
|
|
@@ -97,9 +97,9 @@ try:
|
|
| 97 |
logger.info("Retrying in 5 seconds...")
|
| 98 |
time.sleep(5)
|
| 99 |
else:
|
| 100 |
-
raise RuntimeError(f"Failed to load
|
| 101 |
except Exception as e:
|
| 102 |
-
logger.error(f"Failed to load
|
| 103 |
raise
|
| 104 |
|
| 105 |
# Load IP-Adapter
|
|
|
|
| 2 |
import torch
|
| 3 |
import numpy as np
|
| 4 |
import gradio as gr
|
| 5 |
+
from diffusers import StableDiffusionPipeline # Use SD 2.1 instead of SDXL
|
| 6 |
from insightface.app import FaceAnalysis
|
| 7 |
from huggingface_hub import hf_hub_download
|
| 8 |
import os
|
|
|
|
| 73 |
ip_adapter_path
|
| 74 |
)
|
| 75 |
|
| 76 |
+
# Load the pipeline with SD 2.1
|
| 77 |
+
logger.info("Loading Stable Diffusion 2.1 base model...")
|
| 78 |
try:
|
| 79 |
max_retries = 3
|
| 80 |
for attempt in range(max_retries):
|
| 81 |
try:
|
| 82 |
+
logger.info(f"Attempt {attempt + 1}/{max_retries}: Loading SD 2.1 model...")
|
| 83 |
+
pipe = StableDiffusionPipeline.from_pretrained(
|
| 84 |
+
"stabilityai/stable-diffusion-2-1",
|
| 85 |
torch_dtype=dtype,
|
| 86 |
safety_checker=None,
|
| 87 |
local_files_only=False,
|
|
|
|
| 89 |
variant="fp16",
|
| 90 |
use_safetensors=True
|
| 91 |
)
|
| 92 |
+
logger.info("SD 2.1 base model loaded successfully.")
|
| 93 |
break
|
| 94 |
except Exception as e:
|
| 95 |
logger.error(f"Load attempt {attempt + 1} failed: {e}")
|
|
|
|
| 97 |
logger.info("Retrying in 5 seconds...")
|
| 98 |
time.sleep(5)
|
| 99 |
else:
|
| 100 |
+
raise RuntimeError(f"Failed to load SD 2.1 model after {max_retries} attempts: {e}")
|
| 101 |
except Exception as e:
|
| 102 |
+
logger.error(f"Failed to load SD 2.1 base model: {e}")
|
| 103 |
raise
|
| 104 |
|
| 105 |
# Load IP-Adapter
|