Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
92479760
P
PaddleClas
项目概览
PaddlePaddle
/
PaddleClas
大约 2 年 前同步成功
通知
118
Star
4999
Fork
1114
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
6
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleClas
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
6
合并请求
6
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
92479760
编写于
6月 07, 2022
作者:
G
gaotingquan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
print -> logger
上级
1e78e71c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
7 addition
and
8 deletion
+7
-8
paddleclas.py
paddleclas.py
+7
-8
未找到文件。
paddleclas.py
浏览文件 @
92479760
...
@@ -24,7 +24,6 @@ import shutil
...
@@ -24,7 +24,6 @@ import shutil
import
textwrap
import
textwrap
import
tarfile
import
tarfile
import
requests
import
requests
import
warnings
from
functools
import
partial
from
functools
import
partial
from
difflib
import
SequenceMatcher
from
difflib
import
SequenceMatcher
...
@@ -38,10 +37,10 @@ from deploy.utils.get_image_list import get_image_list
...
@@ -38,10 +37,10 @@ from deploy.utils.get_image_list import get_image_list
from
deploy.utils
import
config
from
deploy.utils
import
config
import
ppcls.arch.backbone
as
backbone
import
ppcls.arch.backbone
as
backbone
from
ppcls.utils
.logger
import
init_
logger
from
ppcls.utils
import
logger
# for building model with loading pretrained weights from backbone
# for building model with loading pretrained weights from backbone
init_logger
()
logger
.
init_logger
()
__all__
=
[
"PaddleClas"
]
__all__
=
[
"PaddleClas"
]
...
@@ -400,7 +399,7 @@ def check_model_file(model_type, model_name):
...
@@ -400,7 +399,7 @@ def check_model_file(model_type, model_name):
if
not
os
.
path
.
exists
(
model_file_path
)
or
not
os
.
path
.
exists
(
if
not
os
.
path
.
exists
(
model_file_path
)
or
not
os
.
path
.
exists
(
params_file_path
):
params_file_path
):
tmp_path
=
storage_directory
(
url
.
split
(
"/"
)[
-
1
])
tmp_path
=
storage_directory
(
url
.
split
(
"/"
)[
-
1
])
print
(
f
"download
{
url
}
to
{
tmp_path
}
"
)
logger
.
info
(
f
"download
{
url
}
to
{
tmp_path
}
"
)
os
.
makedirs
(
storage_directory
(),
exist_ok
=
True
)
os
.
makedirs
(
storage_directory
(),
exist_ok
=
True
)
download_with_progressbar
(
url
,
tmp_path
)
download_with_progressbar
(
url
,
tmp_path
)
with
tarfile
.
open
(
tmp_path
,
"r"
)
as
tarObj
:
with
tarfile
.
open
(
tmp_path
,
"r"
)
as
tarObj
:
...
@@ -522,7 +521,7 @@ class PaddleClas(object):
...
@@ -522,7 +521,7 @@ class PaddleClas(object):
os
.
makedirs
(
image_storage_dir
())
os
.
makedirs
(
image_storage_dir
())
image_save_path
=
image_storage_dir
(
"tmp.jpg"
)
image_save_path
=
image_storage_dir
(
"tmp.jpg"
)
download_with_progressbar
(
input_data
,
image_save_path
)
download_with_progressbar
(
input_data
,
image_save_path
)
warnings
.
warn
(
logger
.
info
(
f
"Image to be predicted from Internet:
{
input_data
}
, has been saved to:
{
image_save_path
}
"
f
"Image to be predicted from Internet:
{
input_data
}
, has been saved to:
{
image_save_path
}
"
)
)
input_data
=
image_save_path
input_data
=
image_save_path
...
@@ -536,7 +535,7 @@ class PaddleClas(object):
...
@@ -536,7 +535,7 @@ class PaddleClas(object):
for
idx_img
,
img_path
in
enumerate
(
image_list
):
for
idx_img
,
img_path
in
enumerate
(
image_list
):
img
=
cv2
.
imread
(
img_path
)
img
=
cv2
.
imread
(
img_path
)
if
img
is
None
:
if
img
is
None
:
warnings
.
warn
(
logger
.
warning
(
f
"Image file failed to read and has been skipped. The path:
{
img_path
}
"
f
"Image file failed to read and has been skipped. The path:
{
img_path
}
"
)
)
continue
continue
...
@@ -552,7 +551,7 @@ class PaddleClas(object):
...
@@ -552,7 +551,7 @@ class PaddleClas(object):
for
idx_pred
,
pred
in
enumerate
(
preds
):
for
idx_pred
,
pred
in
enumerate
(
preds
):
pred
[
"filename"
]
=
img_path_list
[
idx_pred
]
pred
[
"filename"
]
=
img_path_list
[
idx_pred
]
if
print_pred
:
if
print_pred
:
print
(
", "
.
join
(
logger
.
info
(
", "
.
join
(
[
f
"
{
k
}
:
{
pred
[
k
]
}
"
for
k
in
pred
]))
[
f
"
{
k
}
:
{
pred
[
k
]
}
"
for
k
in
pred
]))
img_list
=
[]
img_list
=
[]
...
@@ -573,7 +572,7 @@ def main():
...
@@ -573,7 +572,7 @@ def main():
res
=
clas_engine
.
predict
(
cfg
[
"infer_imgs"
],
print_pred
=
True
)
res
=
clas_engine
.
predict
(
cfg
[
"infer_imgs"
],
print_pred
=
True
)
for
_
in
res
:
for
_
in
res
:
pass
pass
print
(
"Predict complete!"
)
logger
.
info
(
"Predict complete!"
)
return
return
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录