TenPoisk commited on
Commit
9085f73
·
1 Parent(s): f55a1ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -1,3 +1,15 @@
1
- import gradio as gr
2
 
3
- gr.Interface.load("models/stabilityai/stable-diffusion-2-1").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
 
3
+ API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-2-1"
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))