Spaces:
Runtime error
Runtime error
Commit
·
ec0bf9c
1
Parent(s):
90c26be
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,22 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
inputs = [
|
| 9 |
gr.inputs.Textbox(label="Prompt"),
|
|
@@ -14,9 +27,9 @@ inputs = [
|
|
| 14 |
gr.inputs.Number(label="Steps", default=50)
|
| 15 |
]
|
| 16 |
|
| 17 |
-
outputs = gr.outputs.Image(type="pil")
|
| 18 |
|
| 19 |
-
interface = gr.Interface(
|
| 20 |
description="Enter a prompt and generate an image using this API.",
|
| 21 |
examples=[["A cat sitting on a chair"],
|
| 22 |
["A landscape with mountains and a lake"],
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
|
| 4 |
+
api_url = "https://5cb20b40-572c-426f-9466-995256f9b6eb.id.repl.co/generate_image"
|
| 5 |
+
|
| 6 |
+
def generate_image(prompt, seed=0, negative_prompt="", model="Deliberate", sampler="k_dpmpp_2s_a", steps=50):
|
| 7 |
+
data = {
|
| 8 |
+
"prompt": prompt,
|
| 9 |
+
"seed": seed,
|
| 10 |
+
"negative_prompt": negative_prompt,
|
| 11 |
+
"model": model,
|
| 12 |
+
"sampler": sampler,
|
| 13 |
+
"steps": steps
|
| 14 |
+
}
|
| 15 |
+
response = requests.post(api_url, data=data)
|
| 16 |
+
if response.status_code == 200:
|
| 17 |
+
return response.json()["url"]
|
| 18 |
+
else:
|
| 19 |
+
return None
|
| 20 |
|
| 21 |
inputs = [
|
| 22 |
gr.inputs.Textbox(label="Prompt"),
|
|
|
|
| 27 |
gr.inputs.Number(label="Steps", default=50)
|
| 28 |
]
|
| 29 |
|
| 30 |
+
outputs = gr.outputs.Image(label="Generated Image", type="pil")
|
| 31 |
|
| 32 |
+
interface = gr.Interface(generate_image, inputs, outputs, title="Generate Images from Prompts",
|
| 33 |
description="Enter a prompt and generate an image using this API.",
|
| 34 |
examples=[["A cat sitting on a chair"],
|
| 35 |
["A landscape with mountains and a lake"],
|