File size: 1,834 Bytes
4b645a5 f132d01 4b645a5 a501d08 f132d01 4b645a5 f132d01 4b645a5 f132d01 4b645a5 f132d01 8457e79 f132d01 8457e79 02a4a22 f132d01 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
import gradio as gr
import requests
from PIL import Image
from io import BytesIO
import base64
api_url = "https://5cb20b40-572c-426f-9466-995256f9b6eb.id.repl.co/generate_image"
def generate_image(model, prompt, seed, negative_prompt, sampler, steps):
data = "?model=" + model + "&prompt=" + prompt + "&seed=" + str(seed) + "&negative_prompt=" + negative_prompt + "&sampler=" + sampler + "&steps=" + str(steps)
response = requests.post(api_url + data, timeout=400)
if response.status_code == 200:
img_base64 = response.json()["url"]
img_bytes = base64.b64decode(img_base64)
img = Image.open(BytesIO(img_bytes))
return img
else:
return None
dropdown_model = gr.inputs.Dropdown(['Seek.art MEGA', 'Deliberate', 'Dreamlike Photoreal', 'Realistic Vision'], label="Model", default="Seek.art MEGA")
textbox_prompt = gr.inputs.Textbox(label="Prompt")
number_seed = gr.inputs.Number(label="Seed", default=0)
textbox_negative_prompt = gr.inputs.Textbox(label="Negative Prompt", default="")
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")
number_steps = gr.inputs.Number(label="Steps", default=50)
inputs = [dropdown_model, textbox_prompt, number_seed, textbox_negative_prompt, dropdown_sampler, number_steps]
outputs = gr.outputs.Image(label="Generated Image", type="pil")
interface = gr.Interface(
fn=generate_image,
inputs=inputs,
outputs=outputs,
title="Image Generator",
description="Select options and enter a prompt to generate an image.",
examples=[],
layout="vertical",
theme="ParityError/Interstellar" # Eines der Standard-Themes
)
interface.launch()
|