未验证 提交 23bcf966 编写于 作者: S Steffy-zxf 提交者: GitHub

update release/v1.8 (#867)

上级 186276d4
......@@ -294,4 +294,3 @@ print("情感分析结果:", res)
## 总结
PaddleHub提供了丰富的预训练模型,包括图像分类、语义模型、视频分类、图像生成、图像分割、文本审核、关键点检测等主流模型,只需要3行Python代码即可快速调用,即时输出预测结果,非常方便。您可以尝试一下,从[预训练模型列表](https://www.paddlepaddle.org.cn/hublist)中选择一些模型体验一下。
......@@ -374,5 +374,3 @@ for batch_result in results:
交通方便;环境很好;服务态度很好 房间较小 predict=1
19天硬盘就罢工了,算上运来的一周都没用上15天,可就是不能换了。唉,你说这算什么事呀! predict=0
```
......@@ -71,4 +71,3 @@ label_list.txt内容如下:
cat
dog
```
......@@ -43,10 +43,8 @@ class ConvertCommand(BaseCommand):
add_help=True)
self.parser.add_argument('command')
self.parser.add_argument('--module_name', '-n')
self.parser.add_argument('--module_version',
'-v',
nargs='?',
default='1.0.0')
self.parser.add_argument(
'--module_version', '-v', nargs='?', default='1.0.0')
self.parser.add_argument('--model_dir', '-d')
self.parser.add_argument('--output_dir', '-o')
......@@ -62,27 +60,28 @@ class ConvertCommand(BaseCommand):
arcname = os.path.join(self.module, 'assets', file)
tfp.add(fullpath, arcname=arcname)
tfp.add(self.model_file,
arcname=os.path.join(self.module, MODULE_FILE))
tfp.add(self.serving_file,
arcname=os.path.join(self.module, SERVING_FILE))
tfp.add(self.init_file,
arcname=os.path.join(self.module, INIT_FILE))
tfp.add(
self.model_file, arcname=os.path.join(self.module, MODULE_FILE))
tfp.add(
self.serving_file,
arcname=os.path.join(self.module, SERVING_FILE))
tfp.add(
self.init_file, arcname=os.path.join(self.module, INIT_FILE))
def create_module_py(self):
template_file = open(os.path.join(TMPL_DIR, 'x_model.tmpl'),
'r',
encoding='utf-8')
template_file = open(
os.path.join(TMPL_DIR, 'x_model.tmpl'), 'r', encoding='utf-8')
tmpl = Template(template_file.read())
lines = []
lines.append(
tmpl.substitute(NAME="'{}'".format(self.module),
TYPE="'CV'",
AUTHOR="'Baidu'",
SUMMARY="''",
VERSION="'{}'".format(self.version),
EMAIL="''"))
tmpl.substitute(
NAME="'{}'".format(self.module),
TYPE="'CV'",
AUTHOR="'Baidu'",
SUMMARY="''",
VERSION="'{}'".format(self.version),
EMAIL="''"))
# self.model_file = os.path.join(self.dest, MODULE_FILE)
self.model_file = os.path.join(self._tmp_dir, MODULE_FILE)
if os.path.exists(self.model_file):
......@@ -101,9 +100,8 @@ class ConvertCommand(BaseCommand):
shutil.copyfile(os.path.join(TMPL_DIR, 'init_py.tmpl'), self.init_file)
def create_serving_demo_py(self):
template_file = open(os.path.join(TMPL_DIR, 'serving_demo.tmpl'),
'r',
encoding='utf-8')
template_file = open(
os.path.join(TMPL_DIR, 'serving_demo.tmpl'), 'r', encoding='utf-8')
tmpl = Template(template_file.read())
lines = []
......
......@@ -78,11 +78,7 @@ class CustomTokenizer(object):
def _convert_token_to_id(self, token):
""" Converts a token (str) in an id using the vocab. """
v = self.vocab.get(token, None)
if v:
return v
else:
return 0
return self.vocab.get(token, None)
def _convert_id_to_token(self, index):
"""Converts an index (integer) in a token (str) using the vocab."""
......@@ -211,11 +207,11 @@ class CustomTokenizer(object):
return ids
elif isinstance(text,
(list, tuple)) and len(text) > 0 and isinstance(
text[0], str):
text[0], str):
return self.convert_tokens_to_ids(text)
elif isinstance(text,
(list, tuple)) and len(text) > 0 and isinstance(
text[0], int):
text[0], int):
return text
else:
raise ValueError(
......@@ -354,7 +350,7 @@ class CustomTokenizer(object):
"""
out_string = (out_string.replace(" .", ".").replace(" ?", "?").replace(
" !", "!").replace(" ,", ",").replace(" ' ", "'").replace(
" n't",
"n't").replace(" 'm", "'m").replace(" 's", "'s").replace(
" 've", "'ve").replace(" 're", "'re"))
" n't",
"n't").replace(" 'm", "'m").replace(" 's", "'s").replace(
" 've", "'ve").replace(" 're", "'re"))
return out_string
......@@ -10,9 +10,10 @@ sentencepiece
colorlog
tqdm
nltk
opencv-python
# pandas no longer support python2 in version 0.25 and above
pandas ; python_version >= "3"
pandas
# gunicorn not support windows
gunicorn >= 19.10.0; sys_platform != "win32"
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册