Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenCV
Opencv Zoo
提交
c5c7f1aa
O
Opencv Zoo
项目概览
OpenCV
/
Opencv Zoo
9 个月 前同步成功
通知
148
Star
400
Fork
122
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv Zoo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
c5c7f1aa
编写于
6月 08, 2022
作者:
Y
Yuantao Feng
提交者:
GitHub
6月 08, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add the missing yaml config for quantizing MP-PalmDet and improve quantized MP-PalmDet (#60)
上级
4fb59105
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
67 addition
and
14 deletion
+67
-14
models/palm_detection_mediapipe/README.md
models/palm_detection_mediapipe/README.md
+0
-2
models/palm_detection_mediapipe/palm_detection_mediapipe_2022may-int8-quantized.onnx
...pipe/palm_detection_mediapipe_2022may-int8-quantized.onnx
+2
-2
tools/quantize/inc_configs/mp_palmdet.yaml
tools/quantize/inc_configs/mp_palmdet.yaml
+40
-0
tools/quantize/quantize-inc.py
tools/quantize/quantize-inc.py
+25
-10
未找到文件。
models/palm_detection_mediapipe/README.md
浏览文件 @
c5c7f1aa
...
...
@@ -17,8 +17,6 @@ python demo.py
python demo.py
-i
/path/to/image
```
NOTE: For the quantized model, you will need to install OpenCV 4.6.0 to have asymmetric paddings support for quantized convolution layer in OpenCV. Score threshold needs to be adjusted as well for the quantized model, which is empirically 0.49.
### Example outputs
![
webcam demo
](
./examples/mppalmdet_demo.gif
)
...
...
models/palm_detection_mediapipe/palm_detection_mediapipe_2022may-int8-quantized.onnx
LFS
浏览文件 @
c5c7f1aa
无法预览此类型文件
tools/quantize/inc_configs/mp_palmdet.yaml
0 → 100644
浏览文件 @
c5c7f1aa
#
# Copyright (c) 2021 Intel Corporation
#
# 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.
version
:
1.0
model
:
# mandatory. used to specify model specific information.
name
:
mp_palmdet
framework
:
onnxrt_qlinearops
# mandatory. supported values are tensorflow, pytorch, pytorch_ipex, onnxrt_integer, onnxrt_qlinear or mxnet; allow new framework backend extension.
quantization
:
# optional. tuning constraints on model-wise for advance user to reduce tuning space.
approach
:
post_training_static_quant
# optional. default value is post_training_static_quant.
calibration
:
dataloader
:
batch_size
:
1
dataset
:
dummy
:
shape
:
[
1
,
256
,
256
,
3
]
low
:
-1.0
high
:
1.0
dtype
:
float32
label
:
True
tuning
:
accuracy_criterion
:
relative
:
0.02
# optional. default value is relative, other value is absolute. this example allows relative accuracy loss: 1%.
exit_policy
:
timeout
:
0
# optional. tuning timeout (seconds). default value is 0 which means early stop. combine with max_trials field to decide when to exit.
random_seed
:
9527
# optional. random seed for deterministic tuning.
tools/quantize/quantize-inc.py
浏览文件 @
c5c7f1aa
...
...
@@ -28,10 +28,14 @@ class Quantize:
q_model
.
save
(
output_name
)
class
Dataset
:
def
__init__
(
self
,
root
,
size
=
None
,
toTensor
=
False
):
def
__init__
(
self
,
root
,
size
=
None
,
dim
=
'chw'
,
mean
=
0.0
,
std
=
1.0
,
swapRB
=
False
,
toFP32
=
False
):
self
.
root
=
root
self
.
size
=
size
self
.
toTensor
=
toTensor
self
.
dim
=
dim
self
.
mean
=
mean
self
.
std
=
std
self
.
swapRB
=
swapRB
self
.
toFP32
=
toFP32
self
.
image_list
=
self
.
load_image_list
(
self
.
root
)
...
...
@@ -45,11 +49,22 @@ class Dataset:
def
__getitem__
(
self
,
idx
):
img
=
cv
.
imread
(
self
.
image_list
[
idx
])
if
self
.
swapRB
:
img
=
cv
.
cvtColor
(
img
,
cv
.
COLOR_BGR2RGB
)
if
self
.
size
:
img
=
cv
.
resize
(
img
,
dsize
=
self
.
size
)
if
self
.
toTensor
:
img
=
img
.
transpose
(
2
,
0
,
1
)
# hwc -> chw
if
self
.
toFP32
:
img
=
img
.
astype
(
np
.
float32
)
img
=
img
-
self
.
mean
img
=
img
/
self
.
std
if
self
.
dim
==
'chw'
:
img
=
img
.
transpose
(
2
,
0
,
1
)
# hwc -> chw
return
img
,
1
def
__len__
(
self
):
...
...
@@ -57,15 +72,15 @@ class Dataset:
models
=
dict
(
mobilenetv1
=
Quantize
(
model_path
=
'../../models/image_classification_mobilenet/image_classification_mobilenetv1_2022apr.onnx'
,
config_path
=
'./inc_configs/mobilenet.yaml'
),
config_path
=
'./inc_configs/mobilenet.yaml'
),
mobilenetv2
=
Quantize
(
model_path
=
'../../models/image_classification_mobilenet/image_classification_mobilenetv2_2022apr.onnx'
,
config_path
=
'./inc_configs/mobilenet.yaml'
),
mp
palm_
det
=
Quantize
(
model_path
=
'../../models/palm_detection_mediapipe/palm_detection_mediapipe_2022may.onnx'
,
config_path
=
'./inc_configs/mp
palmdet.yaml'
,
custom_dataset
=
Dataset
(
root
=
'../../benchmark/data/palm_detection'
)),
config_path
=
'./inc_configs/mobilenet.yaml'
),
mp
_palm
det
=
Quantize
(
model_path
=
'../../models/palm_detection_mediapipe/palm_detection_mediapipe_2022may.onnx'
,
config_path
=
'./inc_configs/mp_
palmdet.yaml'
,
custom_dataset
=
Dataset
(
root
=
'../../benchmark/data/palm_detection'
,
dim
=
'hwc'
,
swapRB
=
True
,
mean
=
127.5
,
std
=
127.5
,
toFP32
=
True
)),
lpd_yunet
=
Quantize
(
model_path
=
'../../models/license_plate_detection_yunet/license_plate_detection_lpd_yunet_2022may.onnx'
,
config_path
=
'./inc_configs/lpd_yunet.yaml'
,
custom_dataset
=
Dataset
(
root
=
'../../benchmark/data/license_plate_detection'
,
size
=
(
320
,
240
),
toTensor
=
True
)),
custom_dataset
=
Dataset
(
root
=
'../../benchmark/data/license_plate_detection'
,
size
=
(
320
,
240
),
dim
=
'chw'
,
toFP32
=
True
)),
)
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录