Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
7d37cfb5
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
7d37cfb5
编写于
4月 09, 2019
作者:
W
wuzewu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update run commmand
上级
e216f355
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
38 addition
and
27 deletion
+38
-27
demo/lac/infer.sh
demo/lac/infer.sh
+1
-1
demo/lac/infer_by_code.py
demo/lac/infer_by_code.py
+3
-3
demo/lac/resources/test/test.txt
demo/lac/resources/test/test.txt
+0
-1
demo/senta/infer.sh
demo/senta/infer.sh
+1
-1
demo/senta/infer_by_code.py
demo/senta/infer_by_code.py
+2
-2
demo/senta/resources/test/test.txt
demo/senta/resources/test/test.txt
+0
-1
demo/ssd/infer.sh
demo/ssd/infer.sh
+1
-1
demo/ssd/infer_by_code.py
demo/ssd/infer_by_code.py
+2
-2
demo/ssd/resources/test/test.txt
demo/ssd/resources/test/test.txt
+0
-1
paddlehub/commands/run.py
paddlehub/commands/run.py
+4
-3
paddlehub/common/downloader.py
paddlehub/common/downloader.py
+0
-1
paddlehub/common/hub_server.py
paddlehub/common/hub_server.py
+2
-2
paddlehub/io/parser.py
paddlehub/io/parser.py
+20
-6
paddlehub/module/module.py
paddlehub/module/module.py
+2
-2
未找到文件。
demo/lac/infer.sh
浏览文件 @
7d37cfb5
python ../../paddlehub/commands/hub.py run hub_module_lac/
--signature
lexical_analysis
--config
resources/test/test.yml
--input_file
resources/test/test.
csv
python ../../paddlehub/commands/hub.py run hub_module_lac/
--signature
lexical_analysis
--config
resources/test/test.yml
--input_file
resources/test/test.
txt
demo/lac/infer_by_code.py
浏览文件 @
7d37cfb5
...
...
@@ -31,8 +31,8 @@ def infer_with_input_file():
key
=
list
(
data_format
.
keys
())[
0
]
# parse input file
test_
csv
=
os
.
path
.
join
(
"resources"
,
"test"
,
"test.csv
"
)
test_text
=
hub
.
io
.
reader
.
csv_reader
.
read
(
test_csv
)[
"TEXT_INPUT"
]
test_
file
=
os
.
path
.
join
(
"resources"
,
"test"
,
"test.txt
"
)
test_text
=
hub
.
io
.
parser
.
txt_parser
.
parse
(
test_file
)
# set input dict
input_dict
=
{
key
:
test_text
}
...
...
@@ -43,4 +43,4 @@ def infer_with_input_file():
if
__name__
==
"__main__"
:
infer_with_input_
text
()
infer_with_input_
file
()
demo/lac/resources/test/test.
csv
→
demo/lac/resources/test/test.
txt
浏览文件 @
7d37cfb5
TEXT_INPUT
今天是个好日子
demo/senta/infer.sh
浏览文件 @
7d37cfb5
python ../../paddlehub/commands/hub.py run hub_module_senta/
--signature
sentiment_classify
--config
resources/test/test.yml
--
dataset
resources/test/test.csv
python ../../paddlehub/commands/hub.py run hub_module_senta/
--signature
sentiment_classify
--config
resources/test/test.yml
--
input_file
resources/test/test.txt
demo/senta/infer_by_code.py
浏览文件 @
7d37cfb5
...
...
@@ -31,8 +31,8 @@ def infer_with_input_file():
key
=
list
(
data_format
.
keys
())[
0
]
# parse input file
test_
csv
=
os
.
path
.
join
(
"resources"
,
"test"
,
"test.csv
"
)
test_text
=
hub
.
io
.
reader
.
csv_reader
.
read
(
test_csv
)[
"TEXT_INPUT"
]
test_
file
=
os
.
path
.
join
(
"resources"
,
"test"
,
"test.txt
"
)
test_text
=
hub
.
io
.
parser
.
txt_parser
.
parse
(
test_file
)
# set input dict
input_dict
=
{
key
:
test_text
}
...
...
demo/senta/resources/test/test.
csv
→
demo/senta/resources/test/test.
txt
浏览文件 @
7d37cfb5
TEXT_INPUT
这部电影真的很赞
售后太差!
demo/ssd/infer.sh
浏览文件 @
7d37cfb5
python ../../paddlehub/commands/hub.py run hub_module_ssd/
--signature
object_detection
--config
resources/test/test.yml
--
dataset
resources/test/test.csv
python ../../paddlehub/commands/hub.py run hub_module_ssd/
--signature
object_detection
--config
resources/test/test.yml
--
input_file
resources/test/test.txt
demo/ssd/infer_by_code.py
浏览文件 @
7d37cfb5
...
...
@@ -30,8 +30,8 @@ def infer_with_input_file():
key
=
list
(
data_format
.
keys
())[
0
]
# parse input file
test_
csv
=
os
.
path
.
join
(
"resources"
,
"test"
,
"test.csv
"
)
test_images
=
hub
.
io
.
reader
.
csv_reader
.
read
(
test_csv
)[
"IMAGE_PATH"
]
test_
file
=
os
.
path
.
join
(
"resources"
,
"test"
,
"test.txt
"
)
test_images
=
hub
.
io
.
parser
.
txt_parser
.
parse
(
test_file
)
# set input dict
input_dict
=
{
key
:
test_images
}
...
...
demo/ssd/resources/test/test.
csv
→
demo/ssd/resources/test/test.
txt
浏览文件 @
7d37cfb5
IMAGE_PATH
./resources/test/test_img_sheep.jpg
./resources/test/test_img_cat.jpg
./resources/test/test_img_bird.jpg
paddlehub/commands/run.py
浏览文件 @
7d37cfb5
...
...
@@ -21,7 +21,7 @@ import os
from
paddlehub.common.logger
import
logger
from
paddlehub.commands.base_command
import
BaseCommand
,
ENTRY
from
paddlehub.io.
reader
import
csv_reader
,
yaml_read
er
from
paddlehub.io.
parser
import
yaml_parser
,
txt_pars
er
from
paddlehub.module.manager
import
default_module_manager
from
paddlehub.common
import
utils
from
paddlehub.common.arg_helper
import
add_argument
,
print_arguments
...
...
@@ -112,7 +112,8 @@ class RunCommand(BaseCommand):
input_data_key
=
list
(
expect_data_format
.
keys
())[
0
]
origin_data
=
{
input_data_key
:
[
self
.
args
.
data
]}
elif
self
.
args
.
dataset
:
origin_data
=
csv_reader
.
read
(
self
.
args
.
dataset
)
input_data_key
=
list
(
expect_data_format
.
keys
())[
0
]
origin_data
=
{
input_data_key
:
txt_parser
.
parse
(
self
.
args
.
dataset
)}
else
:
print
(
"ERROR! Please specify data to predict.
\n
"
)
print
(
"Summary:
\n
%s
\n
"
%
module
.
summary
)
...
...
@@ -127,7 +128,7 @@ class RunCommand(BaseCommand):
input_data
=
{
input_data_key
:
origin_data
[
origin_data_key
]}
config
=
{}
else
:
yaml_config
=
yaml_
reader
.
read
(
self
.
args
.
config
)
yaml_config
=
yaml_
parser
.
parse
(
self
.
args
.
config
)
if
len
(
expect_data_format
)
==
1
:
origin_data_key
=
list
(
origin_data
.
keys
())[
0
]
input_data_key
=
list
(
expect_data_format
.
keys
())[
0
]
...
...
paddlehub/common/downloader.py
浏览文件 @
7d37cfb5
...
...
@@ -28,7 +28,6 @@ import tarfile
from
paddlehub.common
import
utils
from
paddlehub.common.logger
import
logger
from
paddlehub.io.reader
import
csv_reader
__all__
=
[
'Downloader'
]
FLUSH_INTERVAL
=
0.1
...
...
paddlehub/common/hub_server.py
浏览文件 @
7d37cfb5
...
...
@@ -22,7 +22,7 @@ import re
from
paddlehub.common
import
utils
from
paddlehub.common.downloader
import
default_downloader
from
paddlehub.io.
reader
import
yaml_read
er
from
paddlehub.io.
parser
import
yaml_pars
er
import
paddlehub
as
hub
RESOURCE_LIST_FILE
=
"resource_list_file.yml"
...
...
@@ -51,7 +51,7 @@ class HubServer:
if
now_time
-
file_create_time
>=
CACHE_TIME
:
os
.
remove
(
self
.
resource_list_file_path
())
return
False
for
resource
in
yaml_
reader
.
read
(
for
resource
in
yaml_
parser
.
parse
(
self
.
resource_list_file_path
())[
'resource_list'
]:
for
key
in
resource
:
if
key
not
in
self
.
resource_list_file
:
...
...
paddlehub/io/
read
er.py
→
paddlehub/io/
pars
er.py
浏览文件 @
7d37cfb5
...
...
@@ -15,14 +15,14 @@
import
yaml
class
CSV
Read
er
:
class
CSV
FilePars
er
:
def
__init__
(
self
):
pass
def
_check
(
self
):
pass
def
read
(
self
,
csv_file
):
def
parse
(
self
,
csv_file
):
with
open
(
csv_file
,
"r"
)
as
file
:
content
=
file
.
read
()
content
=
content
.
split
(
'
\n
'
)
...
...
@@ -42,18 +42,32 @@ class CSVReader:
return
self
.
content
class
YAML
Read
er
:
class
YAML
FilePars
er
:
def
__init__
(
self
):
pass
def
_check
(
self
):
pass
def
read
(
self
,
yaml_file
):
def
parse
(
self
,
yaml_file
):
with
open
(
yaml_file
,
"r"
)
as
file
:
content
=
file
.
read
()
return
yaml
.
load
(
content
)
yaml_reader
=
YAMLReader
()
csv_reader
=
CSVReader
()
class
TextFileParser
:
def
__init__
(
self
):
pass
def
_check
(
self
):
pass
def
parse
(
self
,
yaml_file
):
with
open
(
yaml_file
,
"r"
)
as
file
:
contents
=
file
.
read
().
split
(
"
\n
"
)
return
[
content
for
content
in
contents
if
content
]
csv_parser
=
CSVFileParser
()
yaml_parser
=
YAMLFileParser
()
txt_parser
=
TextFileParser
()
paddlehub/module/module.py
浏览文件 @
7d37cfb5
...
...
@@ -35,7 +35,7 @@ from paddlehub.module.signature import Signature, create_signature
from
paddlehub.module.checker
import
ModuleChecker
from
paddlehub.module.manager
import
default_module_manager
from
paddlehub.module.base_processor
import
BaseProcessor
from
paddlehub.io.
reader
import
yaml_read
er
from
paddlehub.io.
parser
import
yaml_pars
er
from
paddlehub
import
version
__all__
=
[
'Module'
,
'create_module'
]
...
...
@@ -267,7 +267,7 @@ class Module(object):
if
not
utils
.
is_yaml_file
(
module_info
):
logger
.
critical
(
"module info file should in yaml format"
)
exit
(
1
)
self
.
module_info
=
yaml_
reader
.
read
(
module_info
)
self
.
module_info
=
yaml_
parser
.
parse
(
module_info
)
self
.
author
=
self
.
module_info
.
get
(
'author'
,
'UNKNOWN'
)
self
.
author_email
=
self
.
module_info
.
get
(
'author_email'
,
'UNKNOWN'
)
self
.
summary
=
self
.
module_info
.
get
(
'summary'
,
'UNKNOWN'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录