Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: openrail
|
| 3 |
+
language:
|
| 4 |
+
- id
|
| 5 |
+
---
|
| 6 |
+
import requests
|
| 7 |
+
|
| 8 |
+
API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0"
|
| 9 |
+
headers = {"Authorization": "Bearer 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"}
|
| 10 |
+
|
| 11 |
+
def query(payload):
|
| 12 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
| 13 |
+
return response.content
|
| 14 |
+
image_bytes = query({
|
| 15 |
+
"inputs": "Astronaut riding a horse",
|
| 16 |
+
})
|
| 17 |
+
# You can access the image with PIL.Image for example
|
| 18 |
+
import io
|
| 19 |
+
from PIL import Image
|
| 20 |
+
image = Image.open(io.BytesIO(image_bytes))
|