File size: 1,895 Bytes
645a646
 
bdc1000
645a646
 
1e9186f
65b9940
645a646
 
1e9186f
645a646
76109aa
 
406fedb
 
988fab5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
645a646
1e9186f
645a646
 
 
 
 
 
dd7838a
 
 
15efd83
 
70dd14d
 
15efd83
1e9186f
dd7838a
 
 
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
import gradio as gr
import requests
import os

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


# Функция для отправки запроса
def render(prompt, negative_prompt, width, height, upscale, api_key):
    data = {
        "key":  api_key,  
        "model_id": "realistic-vision-51",  
        "prompt": prompt, 
        "negative_prompt": negative_prompt,  
        "width": width,  
        "height": height,  
        "samples": "1",  
        "num_inference_steps": "40",  
        "safety_checker": "no",  
        "enhance_prompt": "yes",  
        "seed": None,  
        "guidance_scale": 7.5,  
        "multi_lingual": "no",  
        "panorama": "no",  
        "self_attention": "no",  
        "upscale": "no",  
        "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

# UI
gr.Interface(
    render,
    inputs=[
        gr.Textbox(label="Описание изображения:", placeholder="Введите описание изображения", lines=3),
        gr.Textbox(label="Negative Prompt:", placeholder="Введите Negative Prompt", value="[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry"),
        gr.Slider(show_label=True, minimum=256, maximum=2048, label="Ширина:", value="512", step=1),
        gr.Slider(show_label=True, minimum=256, maximum=2048, label="Высота:", value="512", step=1),
        gr.Dropdown(["yes", "no"], label="Upscale", value="no"),
        gr.Textbox(label="Ваш API ключ", placeholder="API_KEY"),
    ],
    outputs=gr.Image()
).launch()