import os from os.path import join import collections import logging from dotenv import load_dotenv import yaml from app.settings import types # from app.models import types from pathlib import Path import codecs codecs.register(lambda name: codecs.lookup('utf8') if name == 'utf8mb4' else None) load_dotenv() # ----------------------------------------------------------------------------- # Click config # ----------------------------------------------------------------------------- CLICK_GROUPS = { 'biggan': 'app/commands/biggan', 'bigbigan': 'app/commands/bigbigan', 'cortex': 'app/commands/cortex', } # ----------------------------------------------------------------------------- # File I/O # ----------------------------------------------------------------------------- SELF_CWD = os.path.dirname(os.path.realpath(__file__)) # Script CWD DIR_APP = str(Path(SELF_CWD).parent.parent.parent) DIR_IMAGENET = join(DIR_APP, 'data_store/imagenet') DIR_INVERSES = join(DIR_APP, 'data_store/inverses') DIR_VECTORS = join(DIR_APP, 'data_store/vectors') DIR_INPUTS = join(DIR_APP, 'data_store/inputs') DIR_OUTPUTS = join(DIR_APP, 'data_store/outputs') DIR_RESULTS = join(DIR_APP, 'data_store/results') DIR_RENDERS = join(DIR_APP, 'data_store/renders') DIR_DISENTANGLED = join(DIR_APP, 'data_store/disentangled') FP_MODELZOO = join(DIR_APP, 'modelzoo/modelzoo.yaml') os.makedirs(DIR_INVERSES, exist_ok=True) os.makedirs(DIR_VECTORS, exist_ok=True) os.makedirs(DIR_INPUTS, exist_ok=True) os.makedirs(DIR_OUTPUTS, exist_ok=True) os.makedirs(DIR_RESULTS, exist_ok=True) os.makedirs(DIR_RENDERS, exist_ok=True) # ----------------------------------------------------------------------------- # Cortex # ----------------------------------------------------------------------------- API_REMOTE = os.environ['API_REMOTE'] or 'https://lens.neural.garden' # ----------------------------------------------------------------------------- # Model config # ----------------------------------------------------------------------------- with open(FP_MODELZOO, 'r') as fp: MODELZOO_CFG = yaml.load(fp, Loader=yaml.Loader) # ----------------------------------------------------------------------------- # Imagenet # ----------------------------------------------------------------------------- IMAGENET_IMAGES_PER_CLASS = 200 FP_IMAGENET_WORDS = join(DIR_IMAGENET, 'words.txt') FP_IMAGENET_CLASSES = join(DIR_IMAGENET, 'classes_in_imagenet.csv') # ----------------------------------------------------------------------------- # Logging options exposed for custom click Params # ----------------------------------------------------------------------------- LOGGER_NAME = 'app' LOGLEVELS = { types.LogLevel.DEBUG: logging.DEBUG, types.LogLevel.INFO: logging.INFO, types.LogLevel.WARN: logging.WARN, types.LogLevel.ERROR: logging.ERROR, types.LogLevel.CRITICAL: logging.CRITICAL } LOGLEVEL_OPT_DEFAULT = types.LogLevel.DEBUG.name #LOGFILE_FORMAT = "%(asctime)s: %(levelname)s: %(message)s" #LOGFILE_FORMAT = "%(levelname)s:%(name)s: %(message)s" #LOGFILE_FORMAT = "%(levelname)s: %(message)s" #LOGFILE_FORMAT = "%(filename)s:%(lineno)s %(funcName)s() %(message)s" # colored logs """ black, red, green, yellow, blue, purple, cyan and white. {color}, fg_{color}, bg_{color}: Foreground and background colors. bold, bold_{color}, fg_bold_{color}, bg_bold_{color}: Bold/bright colors. reset: Clear all formatting (both foreground and background colors). """ LOGFILE_FORMAT = "%(log_color)s%(levelname)-8s%(reset)s %(cyan)s%(filename)s:%(lineno)s:%(bold_cyan)s%(funcName)s() %(reset)s%(message)s" # ----------------------------------------------------------------------------- # Filesystem settings # hash trees enforce a maximum number of directories per directory # ----------------------------------------------------------------------------- ZERO_PADDING = 6 # padding for enumerated image filenames #FRAME_NAME_ZERO_PADDING = 6 # is this active?? CKPT_ZERO_PADDING = 9 HASH_TREE_DEPTH = 3 HASH_BRANCH_SIZE = 3