TogetherAI commited on
Commit
b4d6d38
1 Parent(s): 67d44e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -27
app.py CHANGED
@@ -1,37 +1,42 @@
1
  import gradio as gr
2
- from transformers import pipeline
 
 
 
3
 
4
- # Titel, Beschreibung und Artikel für die Schnittstelle
5
- title = "Prompt Dich weiter mit Einfach.Prompt"
6
- description = """
7
- <p>
8
- <center>
9
 
10
- </center>
11
- </p>
12
- """
13
- article = "<p style='text-align: center'><a href='https://arxiv.org/abs/1907.06616' target='_blank'>Recipes for building an open-domain chatbot</a></p><p style='text-align: center'><a href='https://parl.ai/projects/recipes/' target='_blank'>Original PARLAI Code</a></p>"
 
 
 
 
 
 
14
 
15
- # Text-to-text generation pipeline
16
- generator = pipeline("text2text-generation", model="merve/chatgpt-prompts-bart-long")
 
 
 
 
17
 
18
- # Funktion, die die Textgenerierung durchführt
19
- def generate_prompt(prompt):
20
- output = generator(prompt, max_length=250)
21
- return output[0]['generated_text']
22
 
23
- # Erstellung der Gradio-Schnittstelle
24
  interface = gr.Interface(
25
- fn=generate_prompt,
26
- inputs=gr.inputs.Textbox(lines=2, placeholder="Enter your prompt here..."),
27
- outputs="text",
28
- title=title,
29
- description=description,
30
- article=article,
31
- layout="vertical", # Setzt die Anordnung der Elemente auf vertikal
32
- theme='ParityError/Interstellar'
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()