Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
f87e4709
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
大约 2 年 前同步成功
通知
285
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看板
提交
f87e4709
编写于
11月 11, 2020
作者:
W
wuzewu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix the problem that new models such as openpose cannot use command line prediction
上级
f40cdd8e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
16 deletion
+16
-16
demo/image_classification/predict.py
demo/image_classification/predict.py
+5
-2
paddlehub/module/module.py
paddlehub/module/module.py
+11
-14
未找到文件。
demo/image_classification/predict.py
浏览文件 @
f87e4709
...
@@ -2,5 +2,8 @@ import paddle
...
@@ -2,5 +2,8 @@ import paddle
import
paddlehub
as
hub
import
paddlehub
as
hub
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
model
=
hub
.
Module
(
name
=
'resnet50_vd_imagenet_ssld'
,
label_list
=
[
"roses"
,
"tulips"
,
"daisy"
,
"sunflowers"
,
"dandelion"
],
load_checkpoint
=
None
)
model
=
hub
.
Module
(
result
,
feature
=
model
.
predict
(
'flower.jpg'
)
name
=
'resnet50_vd_imagenet_ssld'
,
\ No newline at end of file
label_list
=
[
"roses"
,
"tulips"
,
"daisy"
,
"sunflowers"
,
"dandelion"
],
load_checkpoint
=
None
)
result
=
model
.
predict
(
'flower.jpg'
)
paddlehub/module/module.py
浏览文件 @
f87e4709
...
@@ -66,17 +66,6 @@ def serving(func: Callable) -> Callable:
...
@@ -66,17 +66,6 @@ def serving(func: Callable) -> Callable:
class
RunModule
(
object
):
class
RunModule
(
object
):
'''The base class of PaddleHub Module, users can inherit this class to implement to realize custom class.'''
'''The base class of PaddleHub Module, users can inherit this class to implement to realize custom class.'''
def
__init__
(
self
,
*
args
,
**
kwargs
):
# Avoid module being initialized multiple times
if
'_is_initialize'
in
self
.
__dict__
and
self
.
_is_initialize
:
return
super
(
RunModule
,
self
).
__init__
()
_run_func_name
=
self
.
_get_func_name
(
self
.
__class__
,
_module_runnable_func
)
self
.
_run_func
=
getattr
(
self
,
_run_func_name
)
if
_run_func_name
else
None
self
.
_serving_func_name
=
self
.
_get_func_name
(
self
.
__class__
,
_module_serving_func
)
self
.
_is_initialize
=
True
def
_get_func_name
(
self
,
current_cls
:
Generic
,
module_func_dict
:
dict
)
->
Optional
[
str
]:
def
_get_func_name
(
self
,
current_cls
:
Generic
,
module_func_dict
:
dict
)
->
Optional
[
str
]:
mod
=
current_cls
.
__module__
+
'.'
+
current_cls
.
__name__
mod
=
current_cls
.
__module__
+
'.'
+
current_cls
.
__name__
if
mod
in
module_func_dict
:
if
mod
in
module_func_dict
:
...
@@ -116,17 +105,25 @@ class RunModule(object):
...
@@ -116,17 +105,25 @@ class RunModule(object):
with
open
(
req_file
,
'r'
)
as
file
:
with
open
(
req_file
,
'r'
)
as
file
:
return
file
.
read
().
split
(
'
\n
'
)
return
file
.
read
().
split
(
'
\n
'
)
@
property
def
_run_func_name
(
self
):
return
self
.
_get_func_name
(
self
.
__class__
,
_module_runnable_func
)
@
property
def
_run_func
(
self
):
return
getattr
(
self
,
self
.
_run_func_name
)
if
self
.
_run_func_name
else
None
@
property
@
property
def
is_runnable
(
self
)
->
bool
:
def
is_runnable
(
self
)
->
bool
:
'''
'''
Whether the Module is runnable, in other words, whether can we execute the Module through the
Whether the Module is runnable, in other words, whether can we execute the Module through the
`hub run` command.
`hub run` command.
'''
'''
return
self
.
_run_func
!=
Non
e
return
True
if
self
.
_run_func
else
Fals
e
@
property
@
property
def
serving_func_name
(
self
):
def
serving_func_name
(
self
):
return
self
.
_
serving_func_name
return
self
.
_
get_func_name
(
self
.
__class__
,
_module_serving_func
)
class
Module
(
object
):
class
Module
(
object
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录