Commit
·
850b601
1
Parent(s):
9b3ec88
add image to pil
Browse files- handler.py +8 -2
handler.py
CHANGED
|
@@ -5,6 +5,9 @@ import numpy as np
|
|
| 5 |
|
| 6 |
from PIL import Image
|
| 7 |
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
from huggingface_hub import hf_hub_download, snapshot_download
|
| 10 |
from ip_adapter.ip_adapter import IPAdapterXL
|
|
@@ -200,7 +203,10 @@ class EndpointHandler():
|
|
| 200 |
return input_image
|
| 201 |
|
| 202 |
|
| 203 |
-
|
|
|
|
|
|
|
|
|
|
| 204 |
source_image =None
|
| 205 |
prompt = "a cat, masterpiece, best quality, high quality"
|
| 206 |
scale =1.0
|
|
@@ -208,7 +214,7 @@ class EndpointHandler():
|
|
| 208 |
|
| 209 |
|
| 210 |
return create_image(
|
| 211 |
-
image_pil=
|
| 212 |
input_image=source_image,
|
| 213 |
prompt=prompt,
|
| 214 |
n_prompt="text, watermark, lowres, low quality, worst quality, deformed, glitch, low contrast, noisy, saturation, blurry",
|
|
|
|
| 5 |
|
| 6 |
from PIL import Image
|
| 7 |
from pathlib import Path
|
| 8 |
+
import requests
|
| 9 |
+
from io import BytesIO
|
| 10 |
+
|
| 11 |
|
| 12 |
from huggingface_hub import hf_hub_download, snapshot_download
|
| 13 |
from ip_adapter.ip_adapter import IPAdapterXL
|
|
|
|
| 203 |
return input_image
|
| 204 |
|
| 205 |
|
| 206 |
+
style_image_url = "https://huggingface.co/spaces/radames/InstantStyle-SDXL-Lightning/resolve/main/assets/0.jpg"
|
| 207 |
+
response = requests.get(style_image_url)
|
| 208 |
+
style_image_pil = Image.open(BytesIO(response.content))
|
| 209 |
+
|
| 210 |
source_image =None
|
| 211 |
prompt = "a cat, masterpiece, best quality, high quality"
|
| 212 |
scale =1.0
|
|
|
|
| 214 |
|
| 215 |
|
| 216 |
return create_image(
|
| 217 |
+
image_pil=style_image_pil,
|
| 218 |
input_image=source_image,
|
| 219 |
prompt=prompt,
|
| 220 |
n_prompt="text, watermark, lowres, low quality, worst quality, deformed, glitch, low contrast, noisy, saturation, blurry",
|