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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
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)
# -----------------------------------------------------------------------------
# Click config
# -----------------------------------------------------------------------------
CLICK_GROUPS = {
'process': 'app/commands/process',
}
# -----------------------------------------------------------------------------
# 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_OUTPUTS = join(DIR_APP, 'data_store/outputs')
FP_MODELZOO = join(DIR_APP, 'modelzoo/modelzoo.yaml')
# -----------------------------------------------------------------------------
# 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"
|