提交 20a9b9ac 编写于 作者: K kinghuin 提交者: wuzewu

fix logger and enum issue(#119)

* fix logger and enum issue
上级 80bac318
......@@ -88,7 +88,6 @@ PaddleHub 1.1.1版本已支持离线运行Module
参考[PaddleHub Finetune适配自定义数据集完成Finetune](https://github.com/PaddlePaddle/PaddleHub/wiki/PaddleHub%E9%80%82%E9%85%8D%E8%87%AA%E5%AE%9A%E4%B9%89%E6%95%B0%E6%8D%AE%E5%AE%8C%E6%88%90FineTune)
## 答疑
当安装或者使用遇到问题时,可以通过[FAQ](https://github.com/PaddlePaddle/PaddleHub/wiki/PaddleHub-FAQ)查找解决方案。
......
......@@ -26,13 +26,16 @@ class Logger(object):
NOLOG = "NOLOG"
def __init__(self, name=None):
logging.basicConfig(
format='[%(asctime)-15s] [%(levelname)8s] - %(message)s')
if not name:
name = "PaddleHub"
self.logger = logging.getLogger(name)
self.handler = logging.StreamHandler()
self.format = logging.Formatter(
'[%(asctime)-15s] [%(levelname)8s] - %(message)s')
self.handler.setFormatter(self.format)
self.logger.addHandler(self.handler)
self.logLevel = "DEBUG"
self.logger.setLevel(self._get_logging_level())
......
......@@ -17,48 +17,11 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from enum import Enum
from PIL import Image
from paddlehub.common.logger import logger
from paddlehub.common import utils
class DataType(Enum):
class DataType(object):
IMAGE = 0
TEXT = 1
AUDIO = 2
VIDEO = 3
INT = 4
FLOAT = 5
@classmethod
def type(cls, data_type):
if data_type in DataType:
return data_type
data_type = data_type.upper()
if data_type in DataType.__dict__:
return DataType.__dict__[data_type]
return None
@classmethod
def str(cls, data_type):
if data_type == DataType.IMAGE:
return "IMAGE"
elif data_type == DataType.TEXT:
return "TEXT"
elif data_type == DataType.AUDIO:
return "AUDIO"
elif data_type == DataType.VIDEO:
return "VIDEO"
elif data_type == DataType.INT:
return "INT"
elif data_type == DataType.FLOAT:
return "FLOAT"
return None
@classmethod
def is_valid_type(cls, data_type):
data_type = DataType.type(data_type)
return data_type in DataType
......@@ -36,7 +36,7 @@ REQUIRED_PACKAGES = [
]
if max_version < 3:
REQUIRED_PACKAGES += ["enum", "numpy == 1.16.0", "pandas == 0.24.0"]
REQUIRED_PACKAGES += ["numpy == 1.16.0", "pandas == 0.24.0"]
else:
REQUIRED_PACKAGES += ["numpy", "pandas"]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册