Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -91,14 +91,15 @@ if not os.path.exists(ip_adapter_weights):
|
|
| 91 |
# Initialize model with empty weights
|
| 92 |
with init_empty_weights():
|
| 93 |
pipe = StableDiffusionXLPipeline.from_pretrained(
|
| 94 |
-
"
|
| 95 |
torch_dtype=dtype,
|
| 96 |
safety_checker=None,
|
|
|
|
| 97 |
)
|
| 98 |
|
| 99 |
# Load and dispatch model with accelerate
|
| 100 |
pipe = load_checkpoint_and_dispatch(pipe, model_path, device_map="cpu", offload_folder=None)
|
| 101 |
-
pipe.load_ip_adapter("
|
| 102 |
|
| 103 |
def generate_image(uploaded_image, prompt):
|
| 104 |
img = cv2.cvtColor(np.array(uploaded_image), cv2.COLOR_RGB2BGR)
|
|
@@ -130,4 +131,4 @@ interface = gr.Interface(
|
|
| 130 |
description="Upload an image with a face, enter a prompt, and generate a new image preserving the reference face."
|
| 131 |
)
|
| 132 |
|
| 133 |
-
interface.launch()
|
|
|
|
| 91 |
# Initialize model with empty weights
|
| 92 |
with init_empty_weights():
|
| 93 |
pipe = StableDiffusionXLPipeline.from_pretrained(
|
| 94 |
+
"./", # Use local model path
|
| 95 |
torch_dtype=dtype,
|
| 96 |
safety_checker=None,
|
| 97 |
+
local_files_only=True # Force local file usage
|
| 98 |
)
|
| 99 |
|
| 100 |
# Load and dispatch model with accelerate
|
| 101 |
pipe = load_checkpoint_and_dispatch(pipe, model_path, device_map="cpu", offload_folder=None)
|
| 102 |
+
pipe.load_ip_adapter("./", subfolder=None, weight_name="ipa-faceid-plus.bin")
|
| 103 |
|
| 104 |
def generate_image(uploaded_image, prompt):
|
| 105 |
img = cv2.cvtColor(np.array(uploaded_image), cv2.COLOR_RGB2BGR)
|
|
|
|
| 131 |
description="Upload an image with a face, enter a prompt, and generate a new image preserving the reference face."
|
| 132 |
)
|
| 133 |
|
| 134 |
+
interface.launch()
|