#err_msg = f'CRASHED:<br><textarea rows="5" style="color:white;background: black;width: -webkit-fill-available;font-family: monospace;font-size: small;font-weight: bold;">{str(e)}</textarea><br><br>Please wait while the program restarts.'
#stats = err_msg
#return [], seed, 'err', stats
deflayout():
withst.form("txt2img-inputs"):
st.session_state["generation_mode"]="txt2img"
input_col1,generate_col1=st.columns([10,1])
withinput_col1:
#prompt = st.text_area("Input Text","")
prompt=st.text_input("Input Text","",placeholder="A corgi wearing a top hat as an oil painting.")
# Every form must have a submit button, the extra blank spaces is a temp way to align it with the input field. Needs to be done in CSS or some other way.
cfg_scale=st.slider("CFG (Classifier Free Guidance Scale):",min_value=1.0,max_value=30.0,value=defaults.txt2img.cfg_scale,step=0.5,help="How strongly the image should follow the prompt.")
seed=st.text_input("Seed:",value=defaults.txt2img.seed,help=" The seed to use, if left blank a random seed will be generated.")
batch_count=st.slider("Batch count.",min_value=1,max_value=100,value=defaults.txt2img.batch_count,step=1,help="How many iterations or batches of images to generate in total.")
#It increases the VRAM usage a lot but if you have enough VRAM it can reduce the time it takes to finish generation as more images are generated at once.\
#summit_on_enter = st.radio("Submit on enter?", ("Yes", "No"), horizontal=True,
#help="Press the Enter key to summit, when 'No' is selected you can use the Enter key to write multiple lines.")
withst.expander("Advanced"):
separate_prompts=st.checkbox("Create Prompt Matrix.",value=False,help="Separate multiple prompts using the `|` character, and get all combinations of them.")
normalize_prompt_weights=st.checkbox("Normalize Prompt Weights.",value=True,help="Ensure the sum of all weights add up to 1.0")
save_individual_images=st.checkbox("Save individual images.",value=True,help="Save each image generated before any filter or enhancement is applied.")
save_grid=st.checkbox("Save grid",value=True,help="Save a grid with all the images generated into a single image.")
group_by_prompt=st.checkbox("Group results by prompt",value=True,
help="Saves all the images with the same prompt into the same folder. When using a prompt matrix each prompt combination will have its own folder.")
write_info_files=st.checkbox("Write Info file",value=True,help="Save a file next to the image with informartion about the generation.")
save_as_jpg=st.checkbox("Save samples as jpg",value=False,help="Saves the images as jpg instead of png.")
ifGFPGAN_available:
use_GFPGAN=st.checkbox("Use GFPGAN",value=defaults.txt2img.use_GFPGAN,help="Uses the GFPGAN model to improve faces after the generation. This greatly improve the quality and consistency of faces but uses extra VRAM. Disable if you need the extra VRAM.")
else:
use_GFPGAN=False
ifRealESRGAN_available:
use_RealESRGAN=st.checkbox("Use RealESRGAN",value=defaults.txt2img.use_RealESRGAN,help="Uses the RealESRGAN model to upscale the images after the generation. This greatly improve the quality and lets you have high resolution images but uses extra VRAM. Disable if you need the extra VRAM.")
variant_seed=st.text_input("Variant Seed:",value=defaults.txt2img.seed,help="The seed to use when generating a variant, if left blank a random seed will be generated.")
galleryCont=st.empty()
ifgenerate_button:
#print("Loading models")
# load the models when we hit the generate button for the first time, it wont be loaded after that so dont worry.