Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
Opencv Zoo
比较版本
7b7e5b4505e641ec1b6ef6129b2c91accf0cdd11...afc67194681f3dcca7421b6695fd73622a7f1488
O
Opencv Zoo
项目概览
张重言
/
Opencv Zoo
10 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
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 搜索 >>
源分支
afc67194681f3dcca7421b6695fd73622a7f1488
选择Git版本
...
目标分支
7b7e5b4505e641ec1b6ef6129b2c91accf0cdd11
选择Git版本
比较
Commits (2)
https://gitcode.net/pulltheflower/opencv_zoo/-/commit/c6ddb9f96e02cc1db1e3a73419b964bcdb75ae8a
shorten int8-quantized naming (#149)
2023-03-21T15:39:45+08:00
Yuantao Feng
yuantao.feng@opencv.org.cn
https://gitcode.net/pulltheflower/opencv_zoo/-/commit/afc67194681f3dcca7421b6695fd73622a7f1488
more renamings (#150)
2023-03-21T23:04:09+08:00
Yuantao Feng
yuantao.feng@opencv.org.cn
隐藏空白更改
内联
并排
Showing
13 changed file
with
9 addition
and
9 deletion
+9
-9
models/face_detection_yunet/face_detection_yunet_2022mar_int8.onnx
...ce_detection_yunet/face_detection_yunet_2022mar_int8.onnx
+0
-0
models/face_recognition_sface/face_recognition_sface_2021dec_int8.onnx
...ecognition_sface/face_recognition_sface_2021dec_int8.onnx
+0
-0
models/facial_expression_recognition/facial_expression_recognition_mobilefacenet_2022july_int8.onnx
...l_expression_recognition_mobilefacenet_2022july_int8.onnx
+0
-0
models/handpose_estimation_mediapipe/handpose_estimation_mediapipe_2023feb_int8.onnx
...mediapipe/handpose_estimation_mediapipe_2023feb_int8.onnx
+0
-0
models/human_segmentation_pphumanseg/human_segmentation_pphumanseg_2023mar_int8.onnx
...phumanseg/human_segmentation_pphumanseg_2023mar_int8.onnx
+0
-0
models/image_classification_mobilenet/image_classification_mobilenetv1_2022apr_int8.onnx
...ilenet/image_classification_mobilenetv1_2022apr_int8.onnx
+0
-0
models/image_classification_mobilenet/image_classification_mobilenetv2_2022apr_int8.onnx
...ilenet/image_classification_mobilenetv2_2022apr_int8.onnx
+0
-0
models/image_classification_ppresnet/image_classification_ppresnet50_2022jan_int8.onnx
...presnet/image_classification_ppresnet50_2022jan_int8.onnx
+0
-0
models/license_plate_detection_yunet/license_plate_detection_lpd_yunet_2023mar_int8.onnx
...yunet/license_plate_detection_lpd_yunet_2023mar_int8.onnx
+0
-0
models/palm_detection_mediapipe/palm_detection_mediapipe_2023feb_int8.onnx
...tion_mediapipe/palm_detection_mediapipe_2023feb_int8.onnx
+0
-0
models/person_reid_youtureid/person_reid_youtu_2021nov_int8.onnx
...person_reid_youtureid/person_reid_youtu_2021nov_int8.onnx
+0
-0
models/text_recognition_crnn/text_recognition_CRNN_CN_2021nov_int8.onnx
...cognition_crnn/text_recognition_CRNN_CN_2021nov_int8.onnx
+0
-0
tools/quantize/quantize-ort.py
tools/quantize/quantize-ort.py
+9
-9
未找到文件。
models/face_detection_yunet/face_detection_yunet_2022mar
-act_int8-wt_int8-quantized
.onnx
→
models/face_detection_yunet/face_detection_yunet_2022mar
_int8
.onnx
LFS
浏览文件 @
afc67194
文件已移动
models/face_recognition_sface/face_recognition_sface_2021dec
-act_int8-wt_int8-quantized
.onnx
→
models/face_recognition_sface/face_recognition_sface_2021dec
_int8
.onnx
LFS
浏览文件 @
afc67194
文件已移动
models/facial_expression_recognition/facial_expression_recognition_mobilefacenet_2022july
-int8-quantized
.onnx
→
models/facial_expression_recognition/facial_expression_recognition_mobilefacenet_2022july
_int8
.onnx
LFS
浏览文件 @
afc67194
文件已移动
models/handpose_estimation_mediapipe/handpose_estimation_mediapipe_2023feb
-act_int8-wt_int8-quantized
.onnx
→
models/handpose_estimation_mediapipe/handpose_estimation_mediapipe_2023feb
_int8
.onnx
LFS
浏览文件 @
afc67194
文件已移动
models/human_segmentation_pphumanseg/human_segmentation_pphumanseg_2023mar
-act_int8-wt_int8-quantized
.onnx
→
models/human_segmentation_pphumanseg/human_segmentation_pphumanseg_2023mar
_int8
.onnx
LFS
浏览文件 @
afc67194
文件已移动
models/image_classification_mobilenet/image_classification_mobilenetv1_2022apr
-int8-quantized
.onnx
→
models/image_classification_mobilenet/image_classification_mobilenetv1_2022apr
_int8
.onnx
LFS
浏览文件 @
afc67194
文件已移动
models/image_classification_mobilenet/image_classification_mobilenetv2_2022apr
-int8-quantized
.onnx
→
models/image_classification_mobilenet/image_classification_mobilenetv2_2022apr
_int8
.onnx
LFS
浏览文件 @
afc67194
文件已移动
models/image_classification_ppresnet/image_classification_ppresnet50_2022jan
-act_int8-wt_int8-quantized
.onnx
→
models/image_classification_ppresnet/image_classification_ppresnet50_2022jan
_int8
.onnx
LFS
浏览文件 @
afc67194
文件已移动
models/license_plate_detection_yunet/license_plate_detection_lpd_yunet_2023mar
-act_int8-wt_int8-quantized
.onnx
→
models/license_plate_detection_yunet/license_plate_detection_lpd_yunet_2023mar
_int8
.onnx
LFS
浏览文件 @
afc67194
文件已移动
models/palm_detection_mediapipe/palm_detection_mediapipe_2023feb
-act_int8-wt_int8-quantized
.onnx
→
models/palm_detection_mediapipe/palm_detection_mediapipe_2023feb
_int8
.onnx
LFS
浏览文件 @
afc67194
文件已移动
models/person_reid_youtureid/person_reid_youtu_2021nov
-act_int8-wt_int8-quantized
.onnx
→
models/person_reid_youtureid/person_reid_youtu_2021nov
_int8
.onnx
LFS
浏览文件 @
afc67194
文件已移动
models/text_recognition_crnn/text_recognition_CRNN_CN_2021nov
-act_int8-wt_int8-quantized
.onnx
→
models/text_recognition_crnn/text_recognition_CRNN_CN_2021nov
_int8
.onnx
LFS
浏览文件 @
afc67194
文件已移动
tools/quantize/quantize-ort.py
浏览文件 @
afc67194
...
...
@@ -59,29 +59,30 @@ class Quantize:
# data reader
self
.
dr
=
DataReader
(
self
.
model_path
,
self
.
calibration_image_dir
,
self
.
transforms
,
data_dim
)
def
check_opset
(
self
,
convert
=
True
):
def
check_opset
(
self
):
model
=
onnx
.
load
(
self
.
model_path
)
if
model
.
opset_import
[
0
].
version
!=
13
:
print
(
'
\t
model opset version: {}. Converting to opset 13'
.
format
(
model
.
opset_import
[
0
].
version
))
# convert opset version to 13
model_opset13
=
version_converter
.
convert_version
(
model
,
13
)
# save converted model
output_name
=
'{}-opset.onnx'
.
format
(
self
.
model_path
[:
-
5
])
output_name
=
'{}-opset
13
.onnx'
.
format
(
self
.
model_path
[:
-
5
])
onnx
.
save_model
(
model_opset13
,
output_name
)
# update model_path for quantization
self
.
model_path
=
output_name
return
output_name
return
self
.
model_path
def
run
(
self
):
print
(
'Quantizing {}: act_type {}, wt_type {}'
.
format
(
self
.
model_path
,
self
.
act_type
,
self
.
wt_type
))
self
.
check_opset
()
output_name
=
'{}
-act_{}-wt_{}-quantized.onnx'
.
format
(
self
.
model_path
[:
-
5
],
self
.
act_type
,
self
.
wt_type
)
quantize_static
(
self
.
model_path
,
output_name
,
self
.
dr
,
new_model_path
=
self
.
check_opset
()
output_name
=
'{}
_{}.onnx'
.
format
(
self
.
model_path
[:
-
5
]
,
self
.
wt_type
)
quantize_static
(
new_
model_path
,
output_name
,
self
.
dr
,
quant_format
=
QuantFormat
.
QOperator
,
# start from onnxruntime==1.11.0, quant_format is set to QuantFormat.QDQ by default, which performs fake quantization
per_channel
=
self
.
per_channel
,
weight_type
=
self
.
type_dict
[
self
.
wt_type
],
activation_type
=
self
.
type_dict
[
self
.
act_type
])
os
.
remove
(
'augmented_model.onnx'
)
os
.
remove
(
'{}-opt.onnx'
.
format
(
self
.
model_path
[:
-
5
])
)
if
new_model_path
!=
self
.
model_path
:
os
.
remove
(
new_model_path
)
print
(
'
\t
Quantized model saved to {}'
.
format
(
output_name
))
models
=
dict
(
...
...
@@ -132,4 +133,3 @@ if __name__ == '__main__':
for
selected_model_name
in
selected_models
:
q
=
models
[
selected_model_name
]
q
.
run
()