Spaces:
Running
Running
File size: 3,877 Bytes
360d274 44a51c4 360d274 693724d 1f3e512 9fb441b 4b0b6eb ada75fc 38e0740 87ea007 360d274 2abf3af 360d274 2abf3af 360d274 98c9fca 360d274 7c84a46 da8cb40 9922d23 2abf3af a980aca 2abf3af ad4bdae 2abf3af 3629275 2abf3af ada75fc 360d274 5df1c2c 360d274 44a51c4 5df1c2c 360d274 |
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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
import gradio as gr
from constants import APP_VERSION
from frontend.webui.text_to_image_ui import get_text_to_image_ui
from frontend.webui.image_to_image_ui import get_image_to_image_ui
from frontend.webui.generation_settings_ui import get_generation_settings_ui
from frontend.webui.models_ui import get_models_ui
from frontend.webui.image_variations_ui import get_image_variations_ui
from paths import FastStableDiffusionPaths
from state import get_settings
app_settings = get_settings()
pony_models = [
"Lykon/Pony-Diffusion",
"andite/anything-v4.0",
"stablediffusionapi/pony-lcm-turbo",
]
standard_models = [
"runwayml/stable-diffusion-v1-5",
"stabilityai/stable-diffusion-2-1-base",
"SG161222/Realistic_Vision_V5.1_noVAE",
]
model_list= pony_models + standard_models
def update_model_array(text_input):
model_list.append(text_input)
updated = model_list
return gr.update(choices=updated, value=updated[0] if updated else None), "\n".join(updated)
def update_choice():
print(f"helloo")
def _get_footer_message() -> str:
version = f"<center><p> {APP_VERSION} "
footer_msg = version + (
' © 2023 <a href="https://github.com/rupeshs">'
" Rupesh Sreeraman</a></p></center>"
)
return footer_msg
mycss=""" #snake1 div label span{display:none;}"""
def get_web_ui() -> gr.Blocks:
def change_mode(mode):
global app_settings
app_settings.settings.lcm_diffusion_setting.use_lcm_lora = False
app_settings.settings.lcm_diffusion_setting.use_openvino = False
if mode == "LCM-LoRA":
app_settings.settings.lcm_diffusion_setting.use_lcm_lora = True
elif mode == "LCM-OpenVINO":
app_settings.settings.lcm_diffusion_setting.use_openvino = True
with gr.Blocks(
css=mycss,
title="FastSD CPU",
) as fastsd_web_ui:
gr.HTML("<center><H1>FastSD CPU</H1></center>")
current_mode = "LCM"
if app_settings.settings.lcm_diffusion_setting.use_openvino:
current_mode = "LCM-OpenVINO"
elif app_settings.settings.lcm_diffusion_setting.use_lcm_lora:
current_mode = "LCM-LoRA"
with gr.Column(scale=1):
with gr.Row(elem_id="snake1"):
model_text_area2 = gr.Textbox(value=" ", lines=1, placeholder="Enter a new model")
update_button = gr.Button("Update Dropdown" )
model_dropdown = gr.Dropdown(choices=model_list, label="models" )
model_dropdown.change( fn=update_choice, inputs=[], outputs=[], )
model_text_area = gr.Textbox(visible=False, value="\n".join(model_list), lines=10, label="")
with gr.Row(elem_id="snake"):
update_button.click( fn=update_model_array, inputs=model_text_area2, outputs=[model_dropdown, model_text_area], )
mode = gr.Radio(choices=["LCM", "LCM-LoRA", "LCM-OpenVINO"], label="Mode", info="Current working mode", value=current_mode,
)
mode.change(change_mode, inputs=mode)
with gr.Tabs():
with gr.TabItem("Text to Image"):
get_text_to_image_ui()
get_generation_settings_ui()
with gr.TabItem("Image to Image"):
get_image_to_image_ui()
with gr.TabItem("Image Variations"):
get_image_variations_ui()
#with gr.TabItem("Generation Settings"):
# get_generation_settings_ui()
with gr.TabItem("Models"):
get_models_ui()
gr.HTML(_get_footer_message())
return fastsd_web_ui
def start_webui(
share: bool = False,
):
webui = get_web_ui()
webui.launch(share=share)
|