Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added custom models list to the txt2img tab. #1136

Merged
merged 1 commit into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions scripts/TextualInversion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# base webui import and utils.
from webui_streamlit import st
from sd_utils import *

# streamlit imports


#other imports

# Temp imports


# end of imports
#---------------------------------------------------------------------------------------------------------------

def layout():
st.write("Textual Inversion")
10 changes: 10 additions & 0 deletions scripts/txt2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,16 @@ def layout():
message = st.empty()

with col3:
# If we have custom models available on the "models/custom"
#folder then we show a menu to select which model we want to use, otherwise we use the main model for SD
#if CustomModel_available:
custom_model = st.selectbox("Custom Model:", st.session_state['defaults'].txt2vid.custom_models_list,
index=st.session_state['defaults'].txt2vid.custom_models_list.index(st.session_state['defaults'].txt2vid.default_model),
help="Select the model you want to use. This option is only available if you have custom models \
on your 'models/custom' folder. The model name that will be shown here is the same as the name\
the file for the model has on said folder, it is recommended to give the .ckpt file a name that \
will make it easier for you to distinguish it from other models. Default: Stable Diffusion v1.4")

st.session_state.sampling_steps = st.slider("Sampling Steps", value=st.session_state['defaults'].txt2img.sampling_steps, min_value=1, max_value=250)

sampler_name_list = ["k_lms", "k_euler", "k_euler_a", "k_dpm_2", "k_dpm_2_a", "k_heun", "PLMS", "DDIM"]
Expand Down
18 changes: 10 additions & 8 deletions scripts/txt2vid.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,13 +598,15 @@ def layout():
with col3:
# If we have custom models available on the "models/custom"
#folder then we show a menu to select which model we want to use, otherwise we use the main model for SD
#if CustomModel_available:
custom_model = st.selectbox("Custom Model:", st.session_state['defaults'].txt2vid.custom_models_list,
index=st.session_state['defaults'].txt2vid.custom_models_list.index(st.session_state['defaults'].txt2vid.default_model),
help="Select the model you want to use. This option is only available if you have custom models \
on your 'models/custom' folder. The model name that will be shown here is the same as the name\
the file for the model has on said folder, it is recommended to give the .ckpt file a name that \
will make it easier for you to distinguish it from other models. Default: Stable Diffusion v1.4")
if st.session_state["CustomModel_available"]:
custom_model = st.selectbox("Custom Model:", st.session_state["custom_models"],
index=st.session_state["custom_models"].index(st.session_state["defaults"].general.default_model),
help="Select the model you want to use. This option is only available if you have custom models \
on your 'models/custom' folder. The model name that will be shown here is the same as the name\
the file for the model has on said folder, it is recommended to give the .ckpt file a name that \
will make it easier for you to distinguish it from other models. Default: Stable Diffusion v1.4")
else:
custom_model = "Stable Diffusion v1.4"

#st.session_state["weights_path"] = custom_model
#else:
Expand Down Expand Up @@ -674,7 +676,7 @@ def layout():
if generate_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.
#load_models(False, False, False, RealESRGAN_model, CustomModel_available=CustomModel_available, custom_model=custom_model)
load_models(False, False, False, RealESRGAN_model, CustomModel_available=CustomModel_available, custom_model=custom_model)

# run video generation
image, seed, info, stats = txt2vid(prompts=prompt, gpu=st.session_state['defaults'].general.gpu,
Expand Down
4 changes: 4 additions & 0 deletions scripts/webui_streamlit.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,9 @@ def layout():
from ModelManager import layout
layout()

elif tabs == 'Textual Inversion':
from TextualInversion import layout
layout()

if __name__ == '__main__':
layout()