File size: 2,607 Bytes
645a646
 
bdc1000
645a646
 
1e9186f
65b9940
082714d
 
 
08c6b22
f158749
645a646
5c44832
645a646
2a151c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0a0f56d
2a151c5
 
 
988fab5
645a646
1e9186f
645a646
 
 
 
 
9f4a4c7
 
a428c62
2a151c5
9f4a4c7
a428c62
 
 
 
 
2a151c5
4e262af
 
 
370b31e
2a151c5
9f4a4c7
 
2a151c5
370b31e
2a151c5
9f4a4c7
 
 
 
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import gradio as gr
import requests
import os

# API ссылка
url = "https://stablediffusionapi.com/api/v4/dreambooth"

# API ключ
api_key = os.getenv("KEY")

model_list = ["AbsoluteReality 1.8.1", "Elldreth's Vivid Mix", "Anything V5", "Openjourney V4", "Analog Diffusion", "Lyriel 1.6", "Realistic Vision 5.0", "Dreamshaper 8", "epiCRealism v5", "CyberRealistic 3.3", "ToonYou 6", "Deliberate 3"]

# Функция для отправки запроса
def render(prompt, model, negative_prompt, width, height, guidance, seed, upscale):
    data = {
        "key": api_key,
        "model_id": model,
        "prompt": prompt,
        "negative_prompt": negative_prompt,
        "width": width,
        "height": height,
        "samples": "1",
        "num_inference_steps": "40",
        "safety_checker": "no",
        "enhance_prompt": "yes",
        "seed": seed,
        "guidance_scale": guidance,
        "multi_lingual": "no",
        "panorama": "no",
        "self_attention": "no",
        "upscale": upscale,
        "embeddings": "embeddings_model_id",
        "lora": "lora_model_id",
        "webhook": None,
        "track_id": None,
    }
    response = requests.post(url, json=data)
    if response.status_code == 200:
        return response.content
    else:
        return None

# Создаем компоненты для ввода данных
prompt_textbox = gr.Textbox(lines=3, placeholder="Введите описание изображения", label="Описание изображения:")
model_radio = gr.Radio(choices=model_list, label="Модель:", value="Anything V5", type="value")

negative_prompt_textbox = gr.Textbox(lines=3, placeholder="Введите Negative Prompt", label="Negative Prompt:")
width_slider = gr.Slider(minimum=256, maximum=2048, value=512, label="Ширина:")
height_slider = gr.Slider(minimum=256, maximum=2048, value=512, label="Высота:")
guidance_slider = gr.Slider(minimum=1, maximum=20, value=7.5, label="CFG Scale:")
seed_slider = gr.Slider(minimum=-1, maximum=1000000, value=-1, label="Seed:")
upscale_dropdown = gr.Dropdown(choices=["yes", "no"], label="Upscale", value="no")

input_component_1 = [prompt_textbox, model_radio]
input_component_2 = [negative_prompt_textbox, width_slider, height_slider, guidance_slider, seed_slider, upscale_dropdown]

tabs = {"Basic Settings": input_component_1, "Advanced Settings": input_component_2}

# Создаем интерфейс
iface = gr.Interface(
    fn=render,
    inputs=tabs,
    outputs=gr.Image(),
)

# Запускаем интерфейс
iface.launch()