Spaces:
Runtime error
Runtime error
TenPoisk
commited on
Commit
·
eecbc64
1
Parent(s):
b7cdb2a
Create kemal.py
Browse files
kemal.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
|
| 3 |
+
API_URL = "https://api-inference.huggingface.co/models/johnslegers/epic-diffusion"
|
| 4 |
+
headers = {"Authorization": "Bearer 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"}
|
| 5 |
+
|
| 6 |
+
def query(payload):
|
| 7 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
| 8 |
+
return response.content
|
| 9 |
+
image_bytes = query({
|
| 10 |
+
"inputs": "Astronaut riding a horse",
|
| 11 |
+
})
|
| 12 |
+
# You can access the image with PIL.Image for example
|
| 13 |
+
import io
|
| 14 |
+
from PIL import Image
|
| 15 |
+
image = Image.open(io.BytesIO(image_bytes))
|