代码拉取完成,页面将自动刷新
import logging
import os
class Config:
class AppEnvType:
DEV = 'dev'
PRODUCTION = 'production'
TEST = 'test'
APP_NAME = '12306-ocr'
APP_ENV = AppEnvType.PRODUCTION
LOADED = False
PROJECT_DIR = os.path.abspath(__file__ + '/../') + '/'
CONFIG_FILE = PROJECT_DIR + 'config.toml'
IMAGE_MODEL_FILE = PROJECT_DIR + 'ocr/image.model.h5'
TEXT_MODEL_FILE = PROJECT_DIR + 'ocr/text.model.h5'
TEXTS_FILE = PROJECT_DIR + 'ocr/texts.txt'
WEB = {
'host': '0.0.0.0',
'port': 8000
}
OCR = {
}
@classmethod
def load(cls):
"""
Load configs from toml file
:return:
"""
import toml
configs = toml.load(cls.CONFIG_FILE)
web = configs.get('web', {})
cls.WEB.update(web)
ocr = configs.get('ocr', {})
cls.OCR.update(ocr)
if not Config.LOADED:
Config.load()
# Logger
def set_up_logger():
logger = logging.getLogger(Config.APP_NAME)
logger.setLevel(logging.DEBUG if Config.APP_ENV == Config.AppEnvType.DEV else logging.INFO)
handler = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s %(levelname)s: %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
return logger
Logger = set_up_logger()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。