-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitialization.py
More file actions
34 lines (28 loc) · 1.12 KB
/
initialization.py
File metadata and controls
34 lines (28 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
import pathlib
from config.load import load_config
from model_selection import supported_clip_models, supported_joycaption_models
from state import APP_STATE
# File: initialization.py
# Author: nflamously
# Original License: Apache License 2.0
def setup_config(model_type: str = "alpha"):
APP_STATE["model_type"] = model_type
app_config = load_config("config/config.json")["model"][model_type]
APP_STATE["checkpoint_path"] = (
pathlib.Path(app_config["checkpoint_path"])
if os.path.exists(app_config["checkpoint_path"])
else app_config["checkpoint_path"]
)
if model_type == "alpha":
APP_STATE["clip_model_name"] = app_config["clip_model"]
APP_STATE["caption_map"] = app_config["caption_types"]
elif model_type == "beta":
APP_STATE["text_model"] = app_config["checkpoint_path"]
APP_STATE["caption_map"] = app_config["caption_types"]
elif model_type == "clip":
pass
else:
raise Exception(
f"model_type {model_type} is not supported, available: {[*supported_joycaption_models(), *supported_clip_models()]}"
)