Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
Opencv Zoo
提交
c6ddb9f9
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 搜索 >>
未验证
提交
c6ddb9f9
编写于
3月 21, 2023
作者:
Y
Yuantao Feng
提交者:
GitHub
3月 21, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
shorten int8-quantized naming (#149)
上级
7b7e5b45
变更
8
隐藏空白更改
内联
并排
Showing
8 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/human_segmentation_pphumanseg/human_segmentation_pphumanseg_2023mar_int8.onnx
...phumanseg/human_segmentation_pphumanseg_2023mar_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/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
浏览文件 @
c6ddb9f9
文件已移动
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
浏览文件 @
c6ddb9f9
文件已移动
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
浏览文件 @
c6ddb9f9
文件已移动
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
浏览文件 @
c6ddb9f9
文件已移动
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
浏览文件 @
c6ddb9f9
文件已移动
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
浏览文件 @
c6ddb9f9
文件已移动
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
浏览文件 @
c6ddb9f9
文件已移动
tools/quantize/quantize-ort.py
浏览文件 @
c6ddb9f9
...
...
@@ -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
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录