Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
38687970
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
38687970
编写于
4月 20, 2022
作者:
wc晨曦
提交者:
GitHub
4月 20, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add HRNet export model tutorials (#5502)
上级
78825715
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
111 addition
and
6 deletion
+111
-6
tutorials/pp-series/HRNet-Keypoint/README.md
tutorials/pp-series/HRNet-Keypoint/README.md
+26
-4
tutorials/pp-series/HRNet-Keypoint/dataset/download_coco.py
tutorials/pp-series/HRNet-Keypoint/dataset/download_coco.py
+2
-2
tutorials/pp-series/HRNet-Keypoint/tools/export_model.py
tutorials/pp-series/HRNet-Keypoint/tools/export_model.py
+83
-0
未找到文件。
tutorials/pp-series/HRNet-Keypoint/README.md
浏览文件 @
38687970
...
...
@@ -98,9 +98,9 @@ python -c "import paddle; print(paddle.__version__)"
-
If the coco dataset has been downloaded
The files can be organized according to the above data file organization structure.
### 2.3 Training & Evaluation &
Inference
### 2.3 Training & Evaluation &
Test
We provides scripts for training, evalution and
inference
with various features according to different configure.
We provides scripts for training, evalution and
test
with various features according to different configure.
```
bash
# training on single-GPU
...
...
@@ -115,7 +115,7 @@ python -m paddle.distributed.launch --gpus 0,1,2,3,4,5,6,7 tools/train.py -c con
export
CUDA_VISIBLE_DEVICES
=
0
python tools/eval.py
-c
configs/hrnet_w32_256x192.yml
-o
weights
=
https://paddledet.bj.bcebos.com/models/keypoint/hrnet_w32_256x192.pdparams
#
Inference
#
test
python tools/infer.py
-c
configs/hrnet_w32_256x192.yml
--infer_img
=
dataset/test_image/hrnet_demo.jpg
-o
weights
=
https://paddledet.bj.bcebos.com/models/keypoint/hrnet_w32_256x192.pdparams
# training with distillation
...
...
@@ -133,10 +133,32 @@ python -m paddle.distributed.launch --gpus 0,1,2,3,4,5,6,7 tools/train.py -c con
export
CUDA_VISIBLE_DEVICES
=
0
python tools/eval.py
-c
configs/lite_hrnet_30_256x192_coco_pact.yml
-o
weights
=
https://paddledet.bj.bcebos.com/models/keypoint/lite_hrnet_30_256x192_coco_pact.pdparams
#
Inference
with PACT quantization
#
test
with PACT quantization
python tools/infer.py
-c
configs/lite_hrnet_30_256x192_coco_pact.yml
--infer_img
=
dataset/test_image/hrnet_demo.jpg
-o
weights
=
https://paddledet.bj.bcebos.com/models/keypoint/lite_hrnet_30_256x192_coco_pact.pdparams
```
### 2.4 Export model & Inference
```
bash
# export model
python tools/export_model.py
-c
configs/hrnet_w32_256x192.yml
-o
weights
=
https://paddledet.bj.bcebos.com/models/keypoint/hrnet_w32_256x192_coco.pdparams
# inference
python deploy/infer.py
--model_dir
=
output_inference/hrnet_w32_256x192/
--image_file
=
dataset/test_image/hrnet_demo.jpg
# export model with lite model
python tools/export_model.py
-c
configs/lite_hrnet_30_256x192_coco.yml
-o
weights
=
https://paddledet.bj.bcebos.com/models/keypoint/lite_hrnet_30_256x192_coco.pdparams
# inference with lite model
python deploy/infer.py
--model_dir
=
output_inference/lite_hrnet_30_256x192_coco/
--image_file
=
dataset/test_image/hrnet_demo.jpg
# export model with PACT quantization
python tools/export_model.py
-c
configs/lite_hrnet_30_256x192_coco_pact.yml
-o
weights
=
https://paddledet.bj.bcebos.com/models/keypoint/lite_hrnet_30_256x192_coco_pact.pdparams
# inference with PACT quantization
python deploy/infer.py
--model_dir
=
output_inference/lite_hrnet_30_256x192_coco_pact/
--image_file
=
dataset/test_image/hrnet_demo.jpg
```
...
...
tutorials/pp-series/HRNet-Keypoint/dataset/download_coco.py
浏览文件 @
38687970
...
...
@@ -16,11 +16,11 @@ import sys
import
os.path
as
osp
import
logging
# add python path of PadleDetection to sys.path
parent_path
=
osp
.
abspath
(
osp
.
join
(
__file__
,
*
([
'..'
]
*
3
)))
parent_path
=
osp
.
abspath
(
osp
.
join
(
__file__
,
*
([
'..'
]
*
2
)))
if
parent_path
not
in
sys
.
path
:
sys
.
path
.
append
(
parent_path
)
from
ppdet
.utils.download
import
download_dataset
from
lib
.utils.download
import
download_dataset
logging
.
basicConfig
(
level
=
logging
.
INFO
)
...
...
tutorials/pp-series/HRNet-Keypoint/tools/export_model.py
0 → 100644
浏览文件 @
38687970
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
os
import
sys
# add python path of PadleDetection to sys.path
parent_path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
__file__
,
*
([
'..'
]
*
2
)))
sys
.
path
.
insert
(
0
,
parent_path
)
# ignore warning log
import
warnings
warnings
.
filterwarnings
(
'ignore'
)
import
glob
import
paddle
from
lib.utils.workspace
import
load_config
,
merge_config
from
lib.slim
import
build_slim_model
from
lib.core.trainer
import
Trainer
from
lib.utils.check
import
check_gpu
,
check_version
,
check_config
from
lib.utils.cli
import
ArgsParser
from
lib.utils.logger
import
setup_logger
logger
=
setup_logger
(
'eval'
)
def
parse_args
():
parser
=
ArgsParser
()
parser
.
add_argument
(
"--save-inference-dir"
,
default
=
'output_inference'
,
type
=
str
,
help
=
"Evaluation directory, default is current directory."
)
args
=
parser
.
parse_args
()
return
args
def
main
():
FLAGS
=
parse_args
()
cfg
=
load_config
(
FLAGS
.
config
)
# cfg['output_eval'] = FLAGS.output_eval
merge_config
(
FLAGS
.
opt
)
if
cfg
.
use_gpu
:
paddle
.
set_device
(
'gpu'
)
else
:
paddle
.
set_device
(
'cpu'
)
if
'slim'
in
cfg
:
cfg
=
build_slim_model
(
cfg
,
mode
=
'test'
)
check_config
(
cfg
)
check_gpu
(
cfg
.
use_gpu
)
check_version
()
# build trainer
trainer
=
Trainer
(
cfg
,
mode
=
'test'
)
# load weights
trainer
.
load_weights
(
cfg
.
weights
)
# export model
trainer
.
export
(
output_dir
=
FLAGS
.
save_inference_dir
)
if
__name__
==
'__main__'
:
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录