Commit
·
019e7d3
1
Parent(s):
34e9fcd
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,24 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
gr.Interface.load("models/runwayml/stable-diffusion-v1-5").launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
# gr.Interface.load("models/runwayml/stable-diffusion-v1-5").launch()
|
4 |
+
|
5 |
+
import requests
|
6 |
+
|
7 |
+
API_URL = "https://api-inference.huggingface.co/models/runwayml/stable-diffusion-v1-5"
|
8 |
+
headers = {"Authorization": "Bearer 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"}
|
9 |
+
|
10 |
+
def query(payload):
|
11 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
12 |
+
return response.content
|
13 |
+
|
14 |
+
# 创建Gradio界面
|
15 |
+
iface = gr.Interface(
|
16 |
+
fn=query,
|
17 |
+
inputs="text",
|
18 |
+
outputs="image",
|
19 |
+
# live=True,
|
20 |
+
title="text to image"
|
21 |
+
)
|
22 |
+
|
23 |
+
# 启动Gradio应用
|
24 |
+
iface.launch()
|