Spaces:
Runtime error
Runtime error
Commit
·
d0d0e6f
1
Parent(s):
dca1c6a
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,9 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 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,9 +14,9 @@ inputs = [
|
|
| 27 |
gr.inputs.Number(label="Steps", default=50)
|
| 28 |
]
|
| 29 |
|
| 30 |
-
outputs = gr.outputs.Image(
|
| 31 |
|
| 32 |
-
interface = gr.Interface(
|
| 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"],
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from generate import generate_image
|
| 3 |
|
| 4 |
+
def generate_image_wrapper(prompt, seed=0, negative_prompt="", model="Deliberate", sampler="k_dpmpp_2s_a", steps=50):
|
| 5 |
+
url = generate_image(prompt, seed=seed, negative_prompt=negative_prompt, model=model, sampler=sampler, steps=steps)
|
| 6 |
+
return {"image": url}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
inputs = [
|
| 9 |
gr.inputs.Textbox(label="Prompt"),
|
|
|
|
| 14 |
gr.inputs.Number(label="Steps", default=50)
|
| 15 |
]
|
| 16 |
|
| 17 |
+
outputs = gr.outputs.Image(type="pil")
|
| 18 |
|
| 19 |
+
interface = gr.Interface(generate_image_wrapper, inputs, outputs, title="Generate Images from Prompts",
|
| 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"],
|