Commit
•
a0e9111
1
Parent(s):
f717c2a
Upload 11 files (#1)
Browse files- Upload 11 files (6402e73fcb3b72796de40f3d5936967fe92b5b69)
- Update requirements.txt (716062eb782ef9a0f1299544cde847f84f86fe51)
- README.md +15 -10
- create_handler.ipynb +0 -0
- crysis.jpeg +0 -0
- requirements.txt +0 -1
- result_crysis.png +0 -0
- thumbnail.png +0 -0
README.md
CHANGED
@@ -35,7 +35,6 @@ There is also a [notebook](https://huggingface.co/philschmid/ControlNet-endpoint
|
|
35 |
"negative_prompt": "low res, bad anatomy, worst quality, low quality",
|
36 |
"controlnet_type": "depth",
|
37 |
"image" : "iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAAB7GkOtAAAABGdBTUEAALGPC",
|
38 |
-
"mask_image": "iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAAB7GkOtAAAABGdBTUEAALGPC",
|
39 |
}
|
40 |
```
|
41 |
|
@@ -61,8 +60,8 @@ import base64
|
|
61 |
from PIL import Image
|
62 |
from io import BytesIO
|
63 |
|
64 |
-
ENDPOINT_URL = ""
|
65 |
-
HF_TOKEN = ""
|
66 |
|
67 |
# helper image utils
|
68 |
def encode_image(image_path):
|
@@ -73,10 +72,9 @@ def encode_image(image_path):
|
|
73 |
|
74 |
def predict(prompt, image, negative_prompt=None, controlnet_type = "normal"):
|
75 |
image = encode_image(image)
|
76 |
-
mask_image = encode_image(mask_image)
|
77 |
|
78 |
# prepare sample payload
|
79 |
-
request = {"
|
80 |
# headers
|
81 |
headers = {
|
82 |
"Authorization": f"Bearer {HF_TOKEN}",
|
@@ -84,17 +82,24 @@ def predict(prompt, image, negative_prompt=None, controlnet_type = "normal"):
|
|
84 |
"Accept": "image/png" # important to get an image back
|
85 |
}
|
86 |
|
87 |
-
response = r.post(ENDPOINT_URL, headers=headers, json=
|
|
|
|
|
|
|
88 |
img = Image.open(BytesIO(response.content))
|
89 |
return img
|
90 |
|
|
|
91 |
prediction = predict(
|
92 |
-
prompt = "
|
93 |
-
negative_prompt ="lowres, bad anatomy, worst quality, low quality",
|
94 |
-
controlnet_type = "
|
95 |
-
image =
|
96 |
)
|
97 |
|
|
|
|
|
|
|
98 |
```
|
99 |
expected output
|
100 |
|
|
|
35 |
"negative_prompt": "low res, bad anatomy, worst quality, low quality",
|
36 |
"controlnet_type": "depth",
|
37 |
"image" : "iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAAB7GkOtAAAABGdBTUEAALGPC",
|
|
|
38 |
}
|
39 |
```
|
40 |
|
|
|
60 |
from PIL import Image
|
61 |
from io import BytesIO
|
62 |
|
63 |
+
ENDPOINT_URL = "" # your endpoint url
|
64 |
+
HF_TOKEN = "" # your huggingface token `hf_xxx`
|
65 |
|
66 |
# helper image utils
|
67 |
def encode_image(image_path):
|
|
|
72 |
|
73 |
def predict(prompt, image, negative_prompt=None, controlnet_type = "normal"):
|
74 |
image = encode_image(image)
|
|
|
75 |
|
76 |
# prepare sample payload
|
77 |
+
request = {"inputs": prompt, "image": image, "negative_prompt": negative_prompt, "controlnet_type": controlnet_type}
|
78 |
# headers
|
79 |
headers = {
|
80 |
"Authorization": f"Bearer {HF_TOKEN}",
|
|
|
82 |
"Accept": "image/png" # important to get an image back
|
83 |
}
|
84 |
|
85 |
+
response = r.post(ENDPOINT_URL, headers=headers, json=request)
|
86 |
+
if response.status_code != 200:
|
87 |
+
print(response.text)
|
88 |
+
raise Exception("Prediction failed")
|
89 |
img = Image.open(BytesIO(response.content))
|
90 |
return img
|
91 |
|
92 |
+
|
93 |
prediction = predict(
|
94 |
+
prompt = "cloudy sky background lush landscape house and green trees, RAW photo (high detailed skin:1.2), 8k uhd, dslr, soft lighting, high quality, film grain, Fujifilm XT3",
|
95 |
+
negative_prompt ="lowres, bad anatomy, worst quality, low quality, city, traffic",
|
96 |
+
controlnet_type = "hed",
|
97 |
+
image = "huggingface.png"
|
98 |
)
|
99 |
|
100 |
+
prediction.save("result.png")
|
101 |
+
```
|
102 |
+
|
103 |
```
|
104 |
expected output
|
105 |
|
create_handler.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
crysis.jpeg
ADDED
requirements.txt
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
|
2 |
git+https://github.com/huggingface/diffusers.git
|
3 |
safetensors
|
4 |
-
#xformers
|
5 |
opencv-python
|
6 |
controlnet_hinter==0.0.5
|
|
|
1 |
|
2 |
git+https://github.com/huggingface/diffusers.git
|
3 |
safetensors
|
|
|
4 |
opencv-python
|
5 |
controlnet_hinter==0.0.5
|
result_crysis.png
CHANGED
thumbnail.png
CHANGED