Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,4 +4,20 @@ def greet(name):
|
|
4 |
return "Hello " + name + "!!"
|
5 |
|
6 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
iface.launch()
|
|
|
4 |
return "Hello " + name + "!!"
|
5 |
|
6 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
+
|
8 |
+
import requests
|
9 |
+
|
10 |
+
API_URL = "https://api-inference.huggingface.co/models/Cacau/heart-of-painting"
|
11 |
+
headers = {"Authorization": "Bearer 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"}
|
12 |
+
|
13 |
+
def query(payload):
|
14 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
15 |
+
return response.content
|
16 |
+
image_bytes = query({
|
17 |
+
"inputs": "Astronaut riding a horse",
|
18 |
+
})
|
19 |
+
# You can access the image with PIL.Image for example
|
20 |
+
import io
|
21 |
+
from PIL import Image
|
22 |
+
image = Image.open(io.BytesIO(image_bytes))
|
23 |
iface.launch()
|