스테블 디뷰전 Web UI 분석

ui.py 파일에서 txt2img 를 실행 시키는 부분을 정의함

with gr.Blocks(analytics_enabled=False) as txt2img_interface:
        txt2img_prompt

txt2img.py 파일에서 실질적으로 스테블 디퓨전 모듈을 실행

def txt2img(id_task: str, prompt: str, negative_prompt: str, prompt_styles, steps: int, sampler_index: int, restore_faces: bool, tiling: bool, n_iter: int, batch_size: int, cfg_scale: float, seed: int, subseed: int, subseed_strength: float, seed_resize_from_h: int, seed_resize_from_w: int, seed_enable_extras: bool, height: int, width: int, enable_hr: bool, denoising_strength: float, hr_scale: float, hr_upscaler: str, hr_second_pass_steps: int, hr_resize_x: int, hr_resize_y: int, override_settings_texts, *args):
    override_settings = create_override_settings_dict(override_settings_texts)

API 만들기

def webui():

내부에 라우터 추가 하기

app.add_api_route("/apiTest", apiInput, methods=["POST"])

변수를 받는 것을 구현 하여 txt2img 모듈 실행

def apiInput():
    id_task = "task(hax8n63lb6m11dd)" 
    prompt = "1girl, blue eyes, blonde hair, long hair, looking at viewer, open mouth, smiling, solo, thighhighs" 
    negative_prompt = ""
    prompt_styles = []
    steps = 20
    sampler_index = 0
    restore_faces = False
    tiling = False
    n_iter = 1 
    batch_size = 1  
    cfg_scale = 7.0 
    seed = -1.0
    subseed = -1.0 
    subseed_strength = 0 
    seed_resize_from_h = 0 
    seed_resize_from_w = 0 
    seed_enable_extras = False 
    height = 512
    width = 512 
    enable_hr = False
    denoising_strength = 0.7
    hr_scale = 2.0 
    hr_upscaler = "Latent"
    hr_second_pass_steps =0  
    hr_resize_x =0  
    hr_resize_y =0  
    override_settings_texts = [] 
    
    args = 0, False, False, 'positive', 'comma', 0, False, False, '', 1, '', 0, '', 0, '', True, False, False, False, 0
   
    modules.txt2img.txt2img(id_task, prompt, negative_prompt, prompt_styles, steps, sampler_index, restore_faces, tiling, n_iter, batch_size, cfg_scale, seed, subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w, seed_enable_extras, height, width, enable_hr, denoising_strength, hr_scale, hr_upscaler, hr_second_pass_steps, hr_resize_x, hr_resize_y, override_settings_texts, *args)
    return {"message": "Hello World"}