Spaces:
Sleeping
Sleeping
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -11,7 +11,8 @@ from PIL import Image
|
|
| 11 |
|
| 12 |
|
| 13 |
# --- Place any download or path setup here ---
|
| 14 |
-
MODEL_ID ="
|
|
|
|
| 15 |
DEVICE = "cpu"
|
| 16 |
MODEL_CACHE = "/workspace/.cache/huggingface"
|
| 17 |
|
|
@@ -25,6 +26,11 @@ pipe = StableDiffusionImg2ImgPipeline.from_pretrained(
|
|
| 25 |
# safety_checker=None, # Disable for demo/testing; enable in prod
|
| 26 |
).to(DEVICE)
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
def generate_sticker(input_image, prompt):
|
| 29 |
"""
|
| 30 |
Given a user image and a prompt, generates a sticker/emoji-style portrait.
|
|
|
|
| 11 |
|
| 12 |
|
| 13 |
# --- Place any download or path setup here ---
|
| 14 |
+
MODEL_ID ="runwayml/stable-diffusion-v1-5" # Can swap for custom path if using IP-Adapter
|
| 15 |
+
ADAPTER_PATH = "/workspace/.cache/huggingface/ip_adapter/ip-adapter_sd15.bin"
|
| 16 |
DEVICE = "cpu"
|
| 17 |
MODEL_CACHE = "/workspace/.cache/huggingface"
|
| 18 |
|
|
|
|
| 26 |
# safety_checker=None, # Disable for demo/testing; enable in prod
|
| 27 |
).to(DEVICE)
|
| 28 |
|
| 29 |
+
pipe.load_ip_adapter(
|
| 30 |
+
pretrained_model_name_or_path=ADAPTER_PATH,
|
| 31 |
+
# Optionally: subfolder="models" if using the repo, not a direct path
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
def generate_sticker(input_image, prompt):
|
| 35 |
"""
|
| 36 |
Given a user image and a prompt, generates a sticker/emoji-style portrait.
|