new config
This commit is contained in:
parent
e17bbdbf5f
commit
316ac6fafa
|
|
@ -11,7 +11,10 @@ __pycache__
|
|||
lena.png
|
||||
lena_result.png
|
||||
lena_test.py
|
||||
config.txt
|
||||
config_modification_tutorial.txt
|
||||
user_path_config.txt
|
||||
user_path_config-deprecated.txt
|
||||
build_chb.py
|
||||
experiment.py
|
||||
/modules/*.png
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
version = '2.1.784'
|
||||
version = '2.1.785'
|
||||
|
|
|
|||
|
|
@ -7,18 +7,72 @@ import modules.sdxl_styles
|
|||
from modules.model_loader import load_file_from_url
|
||||
from modules.util import get_files_from_folder
|
||||
|
||||
config_path = "user_path_config.txt"
|
||||
|
||||
config_path = os.path.abspath("./config.txt")
|
||||
config_example_path = os.path.abspath("config_modification_tutorial.txt")
|
||||
config_dict = {}
|
||||
always_save_keys = []
|
||||
visited_keys = []
|
||||
|
||||
try:
|
||||
if os.path.exists(config_path):
|
||||
with open(config_path, "r", encoding="utf-8") as json_file:
|
||||
config_dict = json.load(json_file)
|
||||
always_save_keys = list(config_dict.keys())
|
||||
except Exception as e:
|
||||
print('Load path config failed')
|
||||
print(e)
|
||||
|
||||
|
||||
def try_load_deprecated_user_path_config():
|
||||
global config_dict
|
||||
|
||||
if not os.path.exists('user_path_config.txt'):
|
||||
return
|
||||
|
||||
try:
|
||||
deprecated_config_dict = json.load(open('user_path_config.txt', "r", encoding="utf-8"))
|
||||
|
||||
def replace_config(old_key, new_key):
|
||||
if old_key in deprecated_config_dict:
|
||||
config_dict[new_key] = deprecated_config_dict[old_key]
|
||||
del deprecated_config_dict[old_key]
|
||||
|
||||
replace_config('modelfile_path', 'path_checkpoints')
|
||||
replace_config('lorafile_path', 'path_loras')
|
||||
replace_config('embeddings_path', 'path_embeddings')
|
||||
replace_config('vae_approx_path', 'path_vae_approx')
|
||||
replace_config('upscale_models_path', 'path_upscale_models')
|
||||
replace_config('inpaint_models_path', 'path_inpaint')
|
||||
replace_config('controlnet_models_path', 'path_controlnet')
|
||||
replace_config('clip_vision_models_path', 'path_clip_vision')
|
||||
replace_config('fooocus_expansion_path', 'path_fooocus_expansion')
|
||||
replace_config('temp_outputs_path', 'path_outputs')
|
||||
|
||||
if deprecated_config_dict.get("default_model", None) == 'juggernautXL_version6Rundiffusion.safetensors':
|
||||
os.replace('user_path_config.txt', 'user_path_config-deprecated.txt')
|
||||
print('Config updated successfully in silence. '
|
||||
'A backup of previous config is written to "user_path_config-deprecated.txt".')
|
||||
return
|
||||
|
||||
if input("Newer models and configs are available. "
|
||||
"Download and update files? [Y/n]:") in ['n', 'N', 'No', 'no', 'NO']:
|
||||
config_dict.update(deprecated_config_dict)
|
||||
print('Loading using deprecated old models and deprecated old configs.')
|
||||
return
|
||||
else:
|
||||
os.replace('user_path_config.txt', 'user_path_config-deprecated.txt')
|
||||
print('Config updated successfully by user. '
|
||||
'A backup of previous config is written to "user_path_config-deprecated.txt".')
|
||||
return
|
||||
except Exception as e:
|
||||
print('Processing deprecated config failed')
|
||||
print(e)
|
||||
return
|
||||
|
||||
|
||||
try_load_deprecated_user_path_config()
|
||||
|
||||
preset = args_manager.args.preset
|
||||
|
||||
if isinstance(preset, str):
|
||||
|
|
@ -38,8 +92,14 @@ if preset is not None:
|
|||
|
||||
|
||||
def get_dir_or_set_default(key, default_value):
|
||||
global config_dict, visited_keys
|
||||
visited_keys.append(key)
|
||||
global config_dict, visited_keys, always_save_keys
|
||||
|
||||
if key not in visited_keys:
|
||||
visited_keys.append(key)
|
||||
|
||||
if key not in always_save_keys:
|
||||
always_save_keys.append(key)
|
||||
|
||||
v = config_dict.get(key, None)
|
||||
if isinstance(v, str) and os.path.exists(v) and os.path.isdir(v):
|
||||
return v
|
||||
|
|
@ -50,21 +110,24 @@ def get_dir_or_set_default(key, default_value):
|
|||
return dp
|
||||
|
||||
|
||||
path_checkpoints = get_dir_or_set_default('modelfile_path', '../models/checkpoints/')
|
||||
path_loras = get_dir_or_set_default('lorafile_path', '../models/loras/')
|
||||
path_embeddings = get_dir_or_set_default('embeddings_path', '../models/embeddings/')
|
||||
path_vae_approx = get_dir_or_set_default('vae_approx_path', '../models/vae_approx/')
|
||||
path_upscale_models = get_dir_or_set_default('upscale_models_path', '../models/upscale_models/')
|
||||
path_inpaint = get_dir_or_set_default('inpaint_models_path', '../models/inpaint/')
|
||||
path_controlnet = get_dir_or_set_default('controlnet_models_path', '../models/controlnet/')
|
||||
path_clip_vision = get_dir_or_set_default('clip_vision_models_path', '../models/clip_vision/')
|
||||
path_fooocus_expansion = get_dir_or_set_default('fooocus_expansion_path', '../models/prompt_expansion/fooocus_expansion')
|
||||
path_outputs = get_dir_or_set_default('temp_outputs_path', '../outputs/')
|
||||
path_checkpoints = get_dir_or_set_default('path_checkpoints', '../models/checkpoints/')
|
||||
path_loras = get_dir_or_set_default('path_loras', '../models/loras/')
|
||||
path_embeddings = get_dir_or_set_default('path_embeddings', '../models/embeddings/')
|
||||
path_vae_approx = get_dir_or_set_default('path_vae_approx', '../models/vae_approx/')
|
||||
path_upscale_models = get_dir_or_set_default('path_upscale_models', '../models/upscale_models/')
|
||||
path_inpaint = get_dir_or_set_default('path_inpaint', '../models/inpaint/')
|
||||
path_controlnet = get_dir_or_set_default('path_controlnet', '../models/controlnet/')
|
||||
path_clip_vision = get_dir_or_set_default('path_clip_vision', '../models/clip_vision/')
|
||||
path_fooocus_expansion = get_dir_or_set_default('path_fooocus_expansion', '../models/prompt_expansion/fooocus_expansion')
|
||||
path_outputs = get_dir_or_set_default('path_outputs', '../outputs/')
|
||||
|
||||
|
||||
def get_config_item_or_set_default(key, default_value, validator, disable_empty_as_none=False):
|
||||
global config_dict, visited_keys
|
||||
visited_keys.append(key)
|
||||
|
||||
if key not in visited_keys:
|
||||
visited_keys.append(key)
|
||||
|
||||
if key not in config_dict:
|
||||
config_dict[key] = default_value
|
||||
return default_value
|
||||
|
|
@ -184,10 +247,17 @@ default_aspect_ratio = get_config_item_or_set_default(
|
|||
validator=lambda x: x in available_aspect_ratios
|
||||
)
|
||||
|
||||
if preset is None:
|
||||
# Do not overwrite user config if preset is applied.
|
||||
with open(config_path, "w", encoding="utf-8") as json_file:
|
||||
json.dump({k: config_dict[k] for k in visited_keys}, json_file, indent=4)
|
||||
with open(config_path, "w", encoding="utf-8") as json_file:
|
||||
json.dump({k: config_dict[k] for k in always_save_keys}, json_file, indent=4)
|
||||
|
||||
with open(config_example_path, "w", encoding="utf-8") as json_file:
|
||||
cpa = config_path.replace("\\", "\\\\")
|
||||
json_file.write(f'You can modify your "{cpa}" using the below keys, formats, and examples.\n'
|
||||
f'Do not modify this file. Modifications in this file will not take effect.\n'
|
||||
f'This file is a tutorial and example. Please edit "{cpa}" to really change any settings.\n'
|
||||
f'Remember to split the paths with "\\\\" rather than "\\".\n\n\n')
|
||||
json.dump({k: config_dict[k] for k in visited_keys}, json_file, indent=4)
|
||||
|
||||
|
||||
os.makedirs(path_outputs, exist_ok=True)
|
||||
|
||||
|
|
@ -220,13 +290,6 @@ def downloading_inpaint_models(v):
|
|||
head_file = os.path.join(path_inpaint, 'fooocus_inpaint_head.pth')
|
||||
patch_file = None
|
||||
|
||||
# load_file_from_url(
|
||||
# url='https://huggingface.co/lllyasviel/Annotators/resolve/main/ControlNetLama.pth',
|
||||
# model_dir=inpaint_models_path,
|
||||
# file_name='ControlNetLama.pth'
|
||||
# )
|
||||
# lama_file = os.path.join(inpaint_models_path, 'ControlNetLama.pth')
|
||||
|
||||
if v == 'v1':
|
||||
load_file_from_url(
|
||||
url='https://huggingface.co/lllyasviel/fooocus_inpaint/resolve/main/inpaint.fooocus.patch',
|
||||
|
|
|
|||
37
readme.md
37
readme.md
|
|
@ -236,8 +236,6 @@ Given different goals, the default models and configs of Fooocus is different:
|
|||
|
||||
Note that the download is **automatic** - you do not need to do anything if the internet connection is okay. However, you can download them manually if you (or move them from somewhere else) have your own preparation.
|
||||
|
||||
Note that if your local parameters are not same with this list, then it means your Fooocus is downloaded from a relatively old version and we do not force users to re-download models. If you want Fooocus to download new models for you, you can delete `Fooocus\user_path_config.txt` and your Fooocus' default model list and configs will be refreshed as the newest version, then all newer models will be downloaded for you.
|
||||
|
||||
## List of "Hidden" Tricks
|
||||
<a name="tech_list"></a>
|
||||
|
||||
|
|
@ -260,23 +258,22 @@ Below things are already inside the software, and **users do not need to do anyt
|
|||
|
||||
## Customization
|
||||
|
||||
After the first time you run Fooocus, a config file will be generated at `Fooocus\user_path_config.txt`. This file can be edited for changing the model path. You can also change some parameters to turn Fooocus into "your Fooocus".
|
||||
After the first time you run Fooocus, a config file will be generated at `Fooocus\config.txt`. This file can be edited for changing the model path or default parameters.
|
||||
|
||||
For example ["realisticStockPhoto_v10" is a pretty good model from CivitAI](https://civitai.com/models/139565/realistic-stock-photo). This model needs a special `CFG=3.0` and probably works better with some specific styles. Below is an example config to turn Fooocus into a **"Fooocus Realistic Stock Photo Software"**:
|
||||
|
||||
`Fooocus\user_path_config.txt`:
|
||||
For example, an edited `Fooocus\config.txt` (this file will be generated after the first launch) may look like this:
|
||||
|
||||
```json
|
||||
{
|
||||
"modelfile_path": "D:\\Fooocus\\models\\checkpoints",
|
||||
"lorafile_path": "D:\\Fooocus\\models\\loras",
|
||||
"vae_approx_path": "D:\\Fooocus\\models\\vae_approx",
|
||||
"upscale_models_path": "D:\\Fooocus\\models\\upscale_models",
|
||||
"inpaint_models_path": "D:\\Fooocus\\models\\inpaint",
|
||||
"controlnet_models_path": "D:\\Fooocus\\models\\controlnet",
|
||||
"clip_vision_models_path": "D:\\Fooocus\\models\\clip_vision",
|
||||
"fooocus_expansion_path": "D:\\Fooocus\\models\\prompt_expansion\\fooocus_expansion",
|
||||
"temp_outputs_path": "D:\\Fooocus\\outputs",
|
||||
"path_checkpoints": "D:\\Fooocus\\models\\checkpoints",
|
||||
"path_loras": "D:\\Fooocus\\models\\loras",
|
||||
"path_embeddings": "D:\\Fooocus\\models\\embeddings",
|
||||
"path_vae_approx": "D:\\Fooocus\\models\\vae_approx",
|
||||
"path_upscale_models": "D:\\Fooocus\\models\\upscale_models",
|
||||
"path_inpaint": "D:\\Fooocus\\models\\inpaint",
|
||||
"path_controlnet": "D:\\Fooocus\\models\\controlnet",
|
||||
"path_clip_vision": "D:\\Fooocus\\models\\clip_vision",
|
||||
"path_fooocus_expansion": "D:\\Fooocus\\models\\prompt_expansion\\fooocus_expansion",
|
||||
"path_outputs": "D:\\Fooocus\\outputs",
|
||||
"default_model": "realisticStockPhoto_v10.safetensors",
|
||||
"default_refiner": "",
|
||||
"default_lora": "",
|
||||
|
|
@ -288,16 +285,20 @@ For example ["realisticStockPhoto_v10" is a pretty good model from CivitAI](http
|
|||
"default_positive_prompt": "",
|
||||
"default_styles": [
|
||||
"Fooocus V2",
|
||||
"Default (Slightly Cinematic)",
|
||||
"SAI Photographic"
|
||||
"Fooocus Photograph",
|
||||
"Fooocus Negative"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Consider twice before you really change the config. If you find yourself breaking things, just delete `Fooocus\user_path_config.txt`. Fooocus will go back to default.
|
||||
Many other keys, formats, and examples are in `Fooocus\config_modification_tutorial.txt` (this file will be generated after the first launch).
|
||||
|
||||
Consider twice before you really change the config. If you find yourself breaking things, just delete `Fooocus\config.txt`. Fooocus will go back to default.
|
||||
|
||||
A safter way is just to try "run_anime.bat" or "run_realistic.bat" - they should be already good enough for different tasks.
|
||||
|
||||
Note that `user_path_config.txt` is deprecated and will be removed soon.
|
||||
|
||||
## Advanced Features
|
||||
|
||||
[Click here to browse the advanced features.](https://github.com/lllyasviel/Fooocus/discussions/117)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,10 @@
|
|||
# 2.1.785
|
||||
|
||||
* The `user_path_config.txt` is deprecated since 2.1.785. If you are using it right now, please use the new `config.txt` instead. See also the new documentation in the Readme.
|
||||
* The paths in `user_path_config.txt` will still be loaded in recent versions, but it will be removed soon.
|
||||
* We use very user-friendly method to automatically transfer your path settings from `user_path_config.txt` to `config.txt` and usually you do not need to do anything.
|
||||
* The new `config.txt` will never save default values so the default value changes in scripts will not be prevented by old config files.
|
||||
|
||||
# 2.1.782
|
||||
|
||||
2.1.782 is mainly an update for a new LoRA system that supports both SDXL loras and SD1.5 loras.
|
||||
|
|
|
|||
Loading…
Reference in New Issue