Spaces:
Runtime error
Runtime error
TogetherAI
commited on
Commit
•
b4d6d38
1
Parent(s):
67d44e9
Update app.py
Browse files
app.py
CHANGED
@@ -1,37 +1,42 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
|
|
|
|
|
|
3 |
|
4 |
-
|
5 |
-
title = "Prompt Dich weiter mit Einfach.Prompt"
|
6 |
-
description = """
|
7 |
-
<p>
|
8 |
-
<center>
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
return output[0]['generated_text']
|
22 |
|
23 |
-
# Erstellung der Gradio-Schnittstelle
|
24 |
interface = gr.Interface(
|
25 |
-
fn=
|
26 |
-
inputs=
|
27 |
-
outputs=
|
28 |
-
title=
|
29 |
-
description=
|
30 |
-
|
31 |
-
layout="vertical",
|
32 |
-
theme=
|
33 |
)
|
34 |
|
35 |
-
# Starten der Schnittstelle
|
36 |
interface.launch()
|
37 |
-
|
|
|
1 |
import gradio as gr
|
2 |
+
import requests
|
3 |
+
from PIL import Image
|
4 |
+
from io import BytesIO
|
5 |
+
import base64
|
6 |
|
7 |
+
api_url = "https://5cb20b40-572c-426f-9466-995256f9b6eb.id.repl.co/generate_image"
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
def generate_image(model, prompt, seed, negative_prompt, sampler, steps):
|
10 |
+
data = "?model=" + model + "&prompt=" + prompt + "&seed=" + str(seed) + "&negative_prompt=" + negative_prompt + "&sampler=" + sampler + "&steps=" + str(steps)
|
11 |
+
response = requests.post(api_url + data, timeout=400)
|
12 |
+
if response.status_code == 200:
|
13 |
+
img_base64 = response.json()["url"]
|
14 |
+
img_bytes = base64.b64decode(img_base64)
|
15 |
+
img = Image.open(BytesIO(img_bytes))
|
16 |
+
return img
|
17 |
+
else:
|
18 |
+
return None
|
19 |
|
20 |
+
dropdown_model = gr.inputs.Dropdown(['Seek.art MEGA', 'Deliberate', 'Dreamlike Photoreal', 'Realistic Vision'], label="Model", default="Seek.art MEGA")
|
21 |
+
textbox_prompt = gr.inputs.Textbox(label="Prompt")
|
22 |
+
number_seed = gr.inputs.Number(label="Seed", default=0)
|
23 |
+
textbox_negative_prompt = gr.inputs.Textbox(label="Negative Prompt", default="")
|
24 |
+
dropdown_sampler = gr.inputs.Dropdown(["k_lms", "k_heun", "k_euler", "k_euler_a", "k_dpm_2", "k_dpm_2_a", "DDIM", "k_dpm_fast", "k_dpm_adaptive", "k_dpmpp_2m", "k_dpmpp_2s_a", "k_dpmpp_sde"], label="Sampler", default="k_dpmpp_2s_a")
|
25 |
+
number_steps = gr.inputs.Number(label="Steps", default=50)
|
26 |
|
27 |
+
inputs = [dropdown_model, textbox_prompt, number_seed, textbox_negative_prompt, dropdown_sampler, number_steps]
|
28 |
+
|
29 |
+
outputs = gr.outputs.Image(label="Generated Image", type="pil")
|
|
|
30 |
|
|
|
31 |
interface = gr.Interface(
|
32 |
+
fn=generate_image,
|
33 |
+
inputs=inputs,
|
34 |
+
outputs=outputs,
|
35 |
+
title="Image Generator",
|
36 |
+
description="Select options and enter a prompt to generate an image.",
|
37 |
+
examples=[],
|
38 |
+
layout="vertical",
|
39 |
+
theme="ParityError/Interstellar" # Ihr spezifiziertes Theme
|
40 |
)
|
41 |
|
|
|
42 |
interface.launch()
|
|