File size: 1,882 Bytes
f36e497
 
 
 
9f5732f
f36e497
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9f5732f
f36e497
 
 
 
 
 
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
import gradio as gr
from core.settings import MODEL_MAP_CHECKPOINT
from .ui_components import (
    create_base_parameter_ui, create_lora_settings_ui,
    create_controlnet_ui, create_diffsynth_controlnet_ui, create_embedding_ui,
    create_conditioning_ui, create_vae_override_ui, create_api_key_ui
)

def create_ui():
    """Creates the UI components for the Txt2Img tab."""
    prefix = "txt2img"
    components = {}
    
    with gr.Column():
        with gr.Row():
            components[f'base_model_{prefix}'] = gr.Dropdown(label="Base Model", choices=list(MODEL_MAP_CHECKPOINT.keys()), value=list(MODEL_MAP_CHECKPOINT.keys())[0], scale=3)
            with gr.Column(scale=1): 
                components[f'run_{prefix}'] = gr.Button("Run", variant="primary")
        
        components[f'prompt_{prefix}'] = gr.Text(label="Prompt", lines=3, placeholder="Enter your prompt")
        components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=3, value="")
        
        with gr.Row():
            with gr.Column(scale=1):
                param_defaults = {'w': 1024, 'h': 1024, 'cs_vis': False, 'cs_val': 1}
                components.update(create_base_parameter_ui(prefix, param_defaults))
            with gr.Column(scale=1):
                components[f'result_{prefix}'] = gr.Gallery(label="Result", show_label=False, columns=2, object_fit="contain", height=627)
        
        components.update(create_api_key_ui(prefix))
        components.update(create_lora_settings_ui(prefix))
        components.update(create_diffsynth_controlnet_ui(prefix))
        # components.update(create_controlnet_ui(prefix))
        # components.update(create_embedding_ui(prefix))
        components.update(create_conditioning_ui(prefix))
        # components.update(create_vae_override_ui(prefix))
        
    return components