mirror of
https://github.com/Sygil-Dev/sygil-webui.git
synced 2024-12-15 06:21:34 +03:00
Walk the directory for GFPGAN so we can also get the older models in case we have more than one, this allow us to compare multiple versions to see how they perform against each other.
This commit is contained in:
parent
173d527979
commit
a4b7efe04d
@ -1761,21 +1761,32 @@ def custom_models_available():
|
||||
def GFPGAN_available():
|
||||
#with server_state_lock["GFPGAN_models"]:
|
||||
#
|
||||
# Allow for custom models to be used instead of the default one,
|
||||
# an example would be Waifu-Diffusion or any other fine tune of stable diffusion
|
||||
|
||||
st.session_state["GFPGAN_models"]:sorted = []
|
||||
model = st.session_state["defaults"].model_manager.models.gfpgan
|
||||
|
||||
files_available = 0
|
||||
|
||||
for file in model['files']:
|
||||
if "save_location" in model['files'][file]:
|
||||
if os.path.exists(os.path.join(model['files'][file]['save_location'], model['files'][file]['file_name'] )):
|
||||
files_available += 1
|
||||
|
||||
elif os.path.exists(os.path.join(model['save_location'], model['files'][file]['file_name'] )):
|
||||
base_name = os.path.splitext(model['files'][file]['file_name'])[0]
|
||||
if "GFPGANv" in base_name:
|
||||
st.session_state["GFPGAN_models"].append(base_name)
|
||||
files_available += 1
|
||||
|
||||
# we need to show the other models from previous verions that we have on the
|
||||
# same directory in case we want to see how they perform vs each other.
|
||||
for root, dirs, files in os.walk(st.session_state['defaults'].general.GFPGAN_dir):
|
||||
for file in files:
|
||||
if os.path.splitext(file)[1] == '.pth':
|
||||
if os.path.splitext(file)[0] not in st.session_state["GFPGAN_models"]:
|
||||
st.session_state["GFPGAN_models"].append(os.path.splitext(file)[0])
|
||||
|
||||
|
||||
if len(st.session_state["GFPGAN_models"]) > 0 and files_available == len(model['files']):
|
||||
st.session_state["GFPGAN_available"] = True
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user