Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
23bcf966
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
8 个月 前同步成功
通知
280
Star
12117
Fork
2091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
200
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleHub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
200
Issue
200
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
23bcf966
编写于
9月 01, 2020
作者:
S
Steffy-zxf
提交者:
GitHub
9月 01, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update release/v1.8 (#867)
上级
186276d4
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
28 addition
and
37 deletion
+28
-37
docs/quick_experience/python_use_hub.md
docs/quick_experience/python_use_hub.md
+0
-1
docs/tutorial/how_to_finetune.md
docs/tutorial/how_to_finetune.md
+0
-2
docs/tutorial/how_to_load_data.md
docs/tutorial/how_to_load_data.md
+0
-1
paddlehub/commands/convert.py
paddlehub/commands/convert.py
+20
-22
paddlehub/tokenizer/tokenizer.py
paddlehub/tokenizer/tokenizer.py
+6
-10
requirements.txt
requirements.txt
+2
-1
未找到文件。
docs/quick_experience/python_use_hub.md
浏览文件 @
23bcf966
...
...
@@ -294,4 +294,3 @@ print("情感分析结果:", res)
## 总结
PaddleHub提供了丰富的预训练模型,包括图像分类、语义模型、视频分类、图像生成、图像分割、文本审核、关键点检测等主流模型,只需要3行Python代码即可快速调用,即时输出预测结果,非常方便。您可以尝试一下,从
[
预训练模型列表
](
https://www.paddlepaddle.org.cn/hublist
)
中选择一些模型体验一下。
docs/tutorial/how_to_finetune.md
浏览文件 @
23bcf966
...
...
@@ -374,5 +374,3 @@ for batch_result in results:
交通方便;环境很好;服务态度很好 房间较小 predict=1
19天硬盘就罢工了,算上运来的一周都没用上15天,可就是不能换了。唉,你说这算什么事呀! predict=0
```
docs/tutorial/how_to_load_data.md
浏览文件 @
23bcf966
...
...
@@ -71,4 +71,3 @@ label_list.txt内容如下:
cat
dog
```
paddlehub/commands/convert.py
浏览文件 @
23bcf966
...
...
@@ -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
=
[]
...
...
paddlehub/tokenizer/tokenizer.py
浏览文件 @
23bcf966
...
...
@@ -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
requirements.txt
浏览文件 @
23bcf966
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录