allow users to choose path of models (#446)
* allow users to choose path of models * allow users to choose path of models * allow users to choose path of models * allow users to choose path of models * allow users to choose path of models
This commit is contained in:
parent
098d08cd22
commit
b89192162d
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,6 +7,7 @@ __pycache__
|
|||||||
lena.png
|
lena.png
|
||||||
lena_result.png
|
lena_result.png
|
||||||
lena_test.py
|
lena_test.py
|
||||||
|
user_path_config.txt
|
||||||
/modules/*.png
|
/modules/*.png
|
||||||
/repositories
|
/repositories
|
||||||
/venv
|
/venv
|
||||||
|
@ -1 +1 @@
|
|||||||
version = '2.0.71'
|
version = '2.0.72'
|
||||||
|
@ -1,16 +1,46 @@
|
|||||||
import os
|
import os
|
||||||
|
import json
|
||||||
from modules.model_loader import load_file_from_url
|
from modules.model_loader import load_file_from_url
|
||||||
|
|
||||||
|
|
||||||
modelfile_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../models/checkpoints/'))
|
config_path = "user_path_config.txt"
|
||||||
lorafile_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../models/loras/'))
|
config_dict = {}
|
||||||
vae_approx_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../models/vae_approx/'))
|
|
||||||
upscale_models_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../models/upscale_models/'))
|
|
||||||
inpaint_models_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../models/inpaint/'))
|
try:
|
||||||
temp_outputs_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../outputs/'))
|
if os.path.exists(config_path):
|
||||||
|
with open(config_path, "r", encoding="utf-8") as json_file:
|
||||||
|
config_dict = json.load(json_file)
|
||||||
|
except Exception as e:
|
||||||
|
print('Load path config failed')
|
||||||
|
print(e)
|
||||||
|
|
||||||
|
|
||||||
|
def get_config_or_set_default(key, default):
|
||||||
|
global config_dict
|
||||||
|
v = config_dict.get(key, None)
|
||||||
|
if isinstance(v, str) and os.path.exists(v) and os.path.isdir(v):
|
||||||
|
return v
|
||||||
|
else:
|
||||||
|
dp = os.path.abspath(os.path.join(os.path.dirname(__file__), default))
|
||||||
|
os.makedirs(dp, exist_ok=True)
|
||||||
|
config_dict[key] = dp
|
||||||
|
return dp
|
||||||
|
|
||||||
|
|
||||||
|
modelfile_path = get_config_or_set_default('modelfile_path', '../models/checkpoints/')
|
||||||
|
lorafile_path = get_config_or_set_default('lorafile_path', '../models/loras/')
|
||||||
|
vae_approx_path = get_config_or_set_default('vae_approx_path', '../models/vae_approx/')
|
||||||
|
upscale_models_path = get_config_or_set_default('upscale_models_path', '../models/upscale_models/')
|
||||||
|
inpaint_models_path = get_config_or_set_default('inpaint_models_path', '../models/inpaint/')
|
||||||
|
fooocus_expansion_path = get_config_or_set_default('fooocus_expansion_path',
|
||||||
|
'../models/prompt_expansion/fooocus_expansion')
|
||||||
|
|
||||||
|
temp_outputs_path = get_config_or_set_default('temp_outputs_path', '../outputs/')
|
||||||
|
|
||||||
|
with open(config_path, "w", encoding="utf-8") as json_file:
|
||||||
|
json.dump(config_dict, json_file, indent=4)
|
||||||
|
|
||||||
fooocus_expansion_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
|
||||||
'../models/prompt_expansion/fooocus_expansion'))
|
|
||||||
|
|
||||||
os.makedirs(temp_outputs_path, exist_ok=True)
|
os.makedirs(temp_outputs_path, exist_ok=True)
|
||||||
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
### 2.0.72
|
||||||
|
|
||||||
|
* Allow users to choose path of models.
|
||||||
|
|
||||||
### 2.0.65
|
### 2.0.65
|
||||||
|
|
||||||
* Inpaint model released.
|
* Inpaint model released.
|
||||||
|
Loading…
Reference in New Issue
Block a user