"scripts/vscode:/vscode.git/clone" did not exist on "e0396a4e123a5c58c3d50150b49e3d69ab3a07ce"
set_config.py 1.11 KB
Newer Older
1
import json
2
import os
3
4
5
from easydict import EasyDict


helloyongyang's avatar
helloyongyang committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
def get_default_config():
    default_config = {
        "do_mm_calib": False,
        "cpu_offload": False,
        "parallel_attn_type": None,  # [None, "ulysses", "ring"]
        "parallel_vae": False,
        "max_area": False,
        "vae_stride": (4, 8, 8),
        "patch_size": (1, 2, 2),
        "feature_caching": "NoCaching",  # ["NoCaching", "TaylorSeer", "Tea"]
        "teacache_thresh": 0.26,
        "use_ret_steps": False,
        "use_bfloat16": True,
        "lora_path": None,
        "strength_model": 1.0,
21
        "mm_config": {},
helloyongyang's avatar
helloyongyang committed
22
23
24
25
    }
    return default_config


26
def set_config(args):
helloyongyang's avatar
helloyongyang committed
27
28
    config = get_default_config()
    config.update({k: v for k, v in vars(args).items()})
29
30
    config = EasyDict(config)

helloyongyang's avatar
helloyongyang committed
31
    with open(config.config_json, "r") as f:
helloyongyang's avatar
helloyongyang committed
32
33
        config_json = json.load(f)
    config.update(config_json)
34

helloyongyang's avatar
helloyongyang committed
35
36
    if os.path.exists(os.path.join(config.model_path, "config.json")):
        with open(os.path.join(config.model_path, "config.json"), "r") as f:
37
38
39
40
            model_config = json.load(f)
        config.update(model_config)

    return config