diff --git a/models/face_detection_yunet/face_detection_yunet_2023mar.onnx b/models/face_detection_yunet/face_detection_yunet_2023mar.onnx index 2d8804a5..473fa862 100644 --- a/models/face_detection_yunet/face_detection_yunet_2023mar.onnx +++ b/models/face_detection_yunet/face_detection_yunet_2023mar.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8f2383e4dd3cfbb4553ea8718107fc0423210dc964f9f4280604804ed2552fa4 -size 232589 +oid sha256:1263d26b9e56d9e7431e4f868b4c4caa362653fb220f2aff240dc5270091a50b +size 126333 diff --git a/models/face_recognition_sface/face_recognition_sface_2021dec.onnx b/models/face_recognition_sface/face_recognition_sface_2021dec.onnx index 5817e559..ef2d161d 100644 --- a/models/face_recognition_sface/face_recognition_sface_2021dec.onnx +++ b/models/face_recognition_sface/face_recognition_sface_2021dec.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0ba9fbfa01b5270c96627c4ef784da859931e02f04419c829e83484087c34e79 -size 38696353 +oid sha256:f6abbfff9575e3041db692c1e29d782e995191888477fd59ebc81202d99fc63b +size 24227283 diff --git a/models/facial_expression_recognition/facial_expression_recognition_mobilefacenet_2022july.onnx b/models/facial_expression_recognition/facial_expression_recognition_mobilefacenet_2022july.onnx index 67dd024c..845b1863 100644 --- a/models/facial_expression_recognition/facial_expression_recognition_mobilefacenet_2022july.onnx +++ b/models/facial_expression_recognition/facial_expression_recognition_mobilefacenet_2022july.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4f61307602fc089ce20488a31d4e4614e3c9753a7d6c41578c854858b183e1a9 -size 4791892 +oid sha256:a6bd51e7dca0c2bfb3755e7884e69f6c6810fbad9e53f9d75a597add3baed1a8 +size 2413209 diff --git a/models/handpose_estimation_mediapipe/handpose_estimation_mediapipe_2023feb.onnx b/models/handpose_estimation_mediapipe/handpose_estimation_mediapipe_2023feb.onnx index 3d660a34..f5e718d8 100644 --- a/models/handpose_estimation_mediapipe/handpose_estimation_mediapipe_2023feb.onnx +++ b/models/handpose_estimation_mediapipe/handpose_estimation_mediapipe_2023feb.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:db0898ae717b76b075d9bf563af315b29562e11f8df5027a1ef07b02bef6d81c -size 4099621 +oid sha256:febfac55f789674c38eee023c369de4f1c57ab592a699781e87d89b54a6d4189 +size 2076178 diff --git a/models/human_segmentation_pphumanseg/human_segmentation_pphumanseg_2023mar.onnx b/models/human_segmentation_pphumanseg/human_segmentation_pphumanseg_2023mar.onnx index d2921c1d..f6aab494 100644 --- a/models/human_segmentation_pphumanseg/human_segmentation_pphumanseg_2023mar.onnx +++ b/models/human_segmentation_pphumanseg/human_segmentation_pphumanseg_2023mar.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:552d8a984054e59b5d773d24b9b12022b22046ceb2bbc4c9aaeaceb36a9ddf24 -size 6163938 +oid sha256:c9f359bc3d50bf0bcf20762076b1cd174a431bb404149f482a2fccb8e5131628 +size 3099693 diff --git a/models/image_classification_mobilenet/image_classification_mobilenetv1_2022apr.onnx b/models/image_classification_mobilenet/image_classification_mobilenetv1_2022apr.onnx index a7dd869f..cae22a7b 100644 --- a/models/image_classification_mobilenet/image_classification_mobilenetv1_2022apr.onnx +++ b/models/image_classification_mobilenet/image_classification_mobilenetv1_2022apr.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cf4c563b54e7144d7c2803ee22a6471e68ae87377554724d501624f602395bea -size 16890136 +oid sha256:de99f3c6c92af11876ee21545701010876c9c0ec4f75d9bfbd5b5adccd516f8e +size 8449898 diff --git a/models/image_classification_mobilenet/image_classification_mobilenetv2_2022apr.onnx b/models/image_classification_mobilenet/image_classification_mobilenetv2_2022apr.onnx index 20731372..629fe8b9 100644 --- a/models/image_classification_mobilenet/image_classification_mobilenetv2_2022apr.onnx +++ b/models/image_classification_mobilenet/image_classification_mobilenetv2_2022apr.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c0c3f76d93fa3fd6580652a45618618a220fced18babf65774ed169de0432ad5 -size 13964571 +oid sha256:823ed99e25277696d79279f5866c138d1a04722409b02869c512d4a7a64d6006 +size 6992958 diff --git a/models/image_classification_ppresnet/image_classification_ppresnet50_2022jan.onnx b/models/image_classification_ppresnet/image_classification_ppresnet50_2022jan.onnx index d1e03061..41d95fd7 100644 --- a/models/image_classification_ppresnet/image_classification_ppresnet50_2022jan.onnx +++ b/models/image_classification_ppresnet/image_classification_ppresnet50_2022jan.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ad5486b0de6c2171ea4d28c734c2fb7c5f64fcdbd97180a0ef515cf4b766a405 -size 102567035 +oid sha256:17f32c5716fe2d6073164a3e677981e5e2b82f57e61d8fa49ee779f6a0fef7b8 +size 65414918 diff --git a/models/license_plate_detection_yunet/license_plate_detection_lpd_yunet_2023mar.onnx b/models/license_plate_detection_yunet/license_plate_detection_lpd_yunet_2023mar.onnx index 8e7b5cc8..c2feb657 100644 --- a/models/license_plate_detection_yunet/license_plate_detection_lpd_yunet_2023mar.onnx +++ b/models/license_plate_detection_yunet/license_plate_detection_lpd_yunet_2023mar.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6d4978a7b6d25514d5e24811b82bfb511d166bdd8ca3b03aa63c1623d4d039c7 -size 4146213 +oid sha256:31a621b3f88b90fade3f51e6060883e65d5410e6de53a6dea1888f6569f07bf4 +size 2080376 diff --git a/models/object_detection_nanodet/object_detection_nanodet_2022nov.onnx b/models/object_detection_nanodet/object_detection_nanodet_2022nov.onnx index 066cb860..638a1e0d 100644 --- a/models/object_detection_nanodet/object_detection_nanodet_2022nov.onnx +++ b/models/object_detection_nanodet/object_detection_nanodet_2022nov.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4b82da9944b88577175ee23a459dce2e26e6e4be573def65b1055dc2d9720186 -size 3800954 +oid sha256:4d26642c6c74864504fb5487821ca93dcb6a497629da4556ead4c51b7a52edcd +size 1917291 diff --git a/models/object_detection_yolox/object_detection_yolox_2022nov.onnx b/models/object_detection_yolox/object_detection_yolox_2022nov.onnx index 0a22cdd5..73f2a283 100644 --- a/models/object_detection_yolox/object_detection_yolox_2022nov.onnx +++ b/models/object_detection_yolox/object_detection_yolox_2022nov.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c5c2d13e59ae883e6af3b45daea64af4833a4951c92d116ec270d9ddbe998063 -size 35858002 +oid sha256:5ccec6eb86a17cf88f161aaf26dd56d333e3fbeb1b370eb9cb70c3dd12432d36 +size 17944560 diff --git a/models/object_tracking_dasiamrpn/object_tracking_dasiamrpn_kernel_cls1_2021nov.onnx b/models/object_tracking_dasiamrpn/object_tracking_dasiamrpn_kernel_cls1_2021nov.onnx index f8f2cada..1a0a98a2 100644 --- a/models/object_tracking_dasiamrpn/object_tracking_dasiamrpn_kernel_cls1_2021nov.onnx +++ b/models/object_tracking_dasiamrpn/object_tracking_dasiamrpn_kernel_cls1_2021nov.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d85b03e2aeded6cc9be945dfdc3ed6b8f4151f101e485037b6c5d5b36a6c4204 -size 23603598 +oid sha256:62114adf1dbe41461593ea4aa435ce4b7cd4a8ee3a12a01e383698e1f4817620 +size 11801998 diff --git a/models/object_tracking_dasiamrpn/object_tracking_dasiamrpn_kernel_r1_2021nov.onnx b/models/object_tracking_dasiamrpn/object_tracking_dasiamrpn_kernel_r1_2021nov.onnx index 87569d3e..c9391320 100644 --- a/models/object_tracking_dasiamrpn/object_tracking_dasiamrpn_kernel_r1_2021nov.onnx +++ b/models/object_tracking_dasiamrpn/object_tracking_dasiamrpn_kernel_r1_2021nov.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:082c85d231b88b97a1b2a50e73b640a332c5d98d7c1d80b5da9ab534fa7a9e5b -size 47206788 +oid sha256:5fba5bee6ed8c907b194594ad04c82385cd8076a2361170a41dbccafec05b55b +size 23603586 diff --git a/models/object_tracking_dasiamrpn/object_tracking_dasiamrpn_model_2021nov.onnx b/models/object_tracking_dasiamrpn/object_tracking_dasiamrpn_model_2021nov.onnx index 36278db4..7478072a 100644 --- a/models/object_tracking_dasiamrpn/object_tracking_dasiamrpn_model_2021nov.onnx +++ b/models/object_tracking_dasiamrpn/object_tracking_dasiamrpn_model_2021nov.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e88370b85cbad914a5eb414d9d9e0820f87fd0cd89b65205a766174206c35719 -size 91040894 +oid sha256:069198aff29984c381dcea84558ba60a75d851aac9310ebe52db5f9dda105608 +size 45524342 diff --git a/models/palm_detection_mediapipe/palm_detection_mediapipe_2023feb.onnx b/models/palm_detection_mediapipe/palm_detection_mediapipe_2023feb.onnx index a899f870..031aa4bb 100644 --- a/models/palm_detection_mediapipe/palm_detection_mediapipe_2023feb.onnx +++ b/models/palm_detection_mediapipe/palm_detection_mediapipe_2023feb.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:78ff51c38496b7fc8b8ebdb6cc8c1abb02fa6c38427c6848254cdaba57fcce7c -size 3905734 +oid sha256:d0843d197c6820c489e71081021823d57849032269b497994bef8682c530701d +size 1985511 diff --git a/models/person_detection_mediapipe/person_detection_mediapipe_2023mar.onnx b/models/person_detection_mediapipe/person_detection_mediapipe_2023mar.onnx index 1780b51b..3d36822d 100644 --- a/models/person_detection_mediapipe/person_detection_mediapipe_2023mar.onnx +++ b/models/person_detection_mediapipe/person_detection_mediapipe_2023mar.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:47fd5599d6fa17608f03e0eb0ae230baa6e597d7e8a2c8199fe00abea55a701f -size 11990159 +oid sha256:4fd42391028c48039af68baceae5733f3a3bd31241f887770b96678228e151df +size 6060089 diff --git a/models/person_reid_youtureid/person_reid_youtu_2021nov.onnx b/models/person_reid_youtureid/person_reid_youtu_2021nov.onnx index 1e642cac..dcea459e 100644 --- a/models/person_reid_youtureid/person_reid_youtu_2021nov.onnx +++ b/models/person_reid_youtureid/person_reid_youtu_2021nov.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0579683334d4b9440221606dcb461656dd0dc64143b18f48faedaced9b4f580d -size 106878407 +oid sha256:756e85946fe83d8269c8543f7b46290c87a43477758b08097cbcae7c4d654132 +size 53466034 diff --git a/models/pose_estimation_mediapipe/pose_estimation_mediapipe_2023mar.onnx b/models/pose_estimation_mediapipe/pose_estimation_mediapipe_2023mar.onnx index 2544a0a4..484d040e 100644 --- a/models/pose_estimation_mediapipe/pose_estimation_mediapipe_2023mar.onnx +++ b/models/pose_estimation_mediapipe/pose_estimation_mediapipe_2023mar.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9d89c599319a18fb7d2e28451a883476164543182bafca5f09eb2cf767ed2f3f -size 5557238 +oid sha256:449de123d2157d94db1a123e5943ba28e54ae50ffd72b13d9154f447f65f1836 +size 2831020 diff --git a/models/text_detection_db/text_detection_DB_IC15_resnet18_2021sep.onnx b/models/text_detection_db/text_detection_DB_IC15_resnet18_2021sep.onnx index 3ca7565c..0d977e02 100644 --- a/models/text_detection_db/text_detection_DB_IC15_resnet18_2021sep.onnx +++ b/models/text_detection_db/text_detection_DB_IC15_resnet18_2021sep.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:62fce3a058ac519952062fbd2cf45bae661130ce753d2a0fc918f4776ba3a02a -size 48770395 +oid sha256:62324d714056a4ce621e3ca5458c83be12ce8ba3cb0114ce2ee4fb29e616c7b8 +size 24404916 diff --git a/models/text_detection_db/text_detection_DB_TD500_resnet18_2021sep.onnx b/models/text_detection_db/text_detection_DB_TD500_resnet18_2021sep.onnx index 808bb66b..cb150843 100644 --- a/models/text_detection_db/text_detection_DB_TD500_resnet18_2021sep.onnx +++ b/models/text_detection_db/text_detection_DB_TD500_resnet18_2021sep.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ad4952eaa2e383dfc448858ed492d51ed159ac83daeff160fee94d3d9e3f2d7d -size 48770395 +oid sha256:a52ff8fb7c1a3bd56463ad997ca845a80451adfc5421da43f61e540ae6aafe98 +size 24404916 diff --git a/models/text_recognition_crnn/text_recognition_CRNN_CH_2021sep.onnx b/models/text_recognition_crnn/text_recognition_CRNN_CH_2021sep.onnx index 443f5dec..dacb1221 100644 --- a/models/text_recognition_crnn/text_recognition_CRNN_CH_2021sep.onnx +++ b/models/text_recognition_crnn/text_recognition_CRNN_CH_2021sep.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2dc566fd01ac2118b25c6960508ebd758b64c421a2bfa78dc05401ada6737e0b -size 64906971 +oid sha256:a51fa1e4155f9a68439869c7187f0ccda3a8ffce7abdb23da75c225b1c9b5fe4 +size 32472431 diff --git a/models/text_recognition_crnn/text_recognition_CRNN_CH_2023feb_fp16.onnx b/models/text_recognition_crnn/text_recognition_CRNN_CH_2023feb.onnx similarity index 100% rename from models/text_recognition_crnn/text_recognition_CRNN_CH_2023feb_fp16.onnx rename to models/text_recognition_crnn/text_recognition_CRNN_CH_2023feb.onnx diff --git a/models/text_recognition_crnn/text_recognition_CRNN_CN_2021nov.onnx b/models/text_recognition_crnn/text_recognition_CRNN_CN_2021nov.onnx index e48fe7fe..9f0e4085 100644 --- a/models/text_recognition_crnn/text_recognition_CRNN_CN_2021nov.onnx +++ b/models/text_recognition_crnn/text_recognition_CRNN_CN_2021nov.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c760bf82d684b87dfabb288e6c0f92d41a8cd6c1780661ca2c3cd10c2065a9ba -size 72807160 +oid sha256:acff153535e41702c14c62a41f5d09df7e28459b46525372e1a60c4cd309285d +size 36422522 diff --git a/models/text_recognition_crnn/text_recognition_CRNN_EN_2021sep.onnx b/models/text_recognition_crnn/text_recognition_CRNN_EN_2021sep.onnx index ff13f288..626502e9 100644 --- a/models/text_recognition_crnn/text_recognition_CRNN_EN_2021sep.onnx +++ b/models/text_recognition_crnn/text_recognition_CRNN_EN_2021sep.onnx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a84b1f6e11a65c2d733cb0cc1f014aae3f99051e3f11447dc282faa678eee544 -size 33823087 +oid sha256:1269b01d544cccb4e4c61b8a7a209b6643ef4ce969432ca963ce78f093138c2a +size 16918127 diff --git a/models/text_recognition_crnn/text_recognition_CRNN_EN_2023feb_fp16.onnx b/models/text_recognition_crnn/text_recognition_CRNN_EN_2023feb.onnx similarity index 100% rename from models/text_recognition_crnn/text_recognition_CRNN_EN_2023feb_fp16.onnx rename to models/text_recognition_crnn/text_recognition_CRNN_EN_2023feb.onnx diff --git a/tools/quantize/fp16-quantize-ort.py b/tools/quantize/fp16-quantize-ort.py new file mode 100644 index 00000000..55e1ef6a --- /dev/null +++ b/tools/quantize/fp16-quantize-ort.py @@ -0,0 +1,60 @@ +import sys +import onnx +from onnxconverter_common import float16 + +op_block_list = ['ArrayFeatureExtractor', 'Binarizer', 'CastMap', 'CategoryMapper', 'DictVectorizer', + 'FeatureVectorizer', 'Imputer', 'LabelEncoder', 'LinearClassifier', 'LinearRegressor', + 'Normalizer', 'OneHotEncoder', 'RandomUniformLike', 'SVMClassifier', 'SVMRegressor', 'Scaler', + 'TreeEnsembleClassifier', 'TreeEnsembleRegressor', 'ZipMap', 'NonMaxSuppression', 'TopK', + 'RoiAlign', 'Range', 'CumSum', 'Min', 'Max', 'Upsample'] + + +class Quantize: + def __init__(self, model_path): + self.model_path = model_path + + def run(self): + model = onnx.load(self.model_path) + model_fp16 = float16.convert_float_to_float16(model, op_block_list=op_block_list) + output_name = '{}_fp16.onnx'.format(self.model_path[:-5]) + onnx.save(model_fp16, output_name) + + +models = dict( + yunet=Quantize(model_path='../../models/face_detection_yunet/face_detection_yunet_2023mar.onnx'), + sface=Quantize(model_path='../../models/face_recognition_sface/face_recognition_sface_2021dec.onnx'), + fer=Quantize(model_path='../../models/facial_expression_recognition/facial_expression_recognition_mobilefacenet_2022july.onnx'), + pphumanseg=Quantize(model_path='../../models/human_segmentation_pphumanseg/human_segmentation_pphumanseg_2023mar.onnx'), + mobilenetv1=Quantize(model_path='../../models/image_classification_mobilenet/image_classification_mobilenetv1_2022apr.onnx'), + mobilenetv2=Quantize(model_path='../../models/image_classification_mobilenet/image_classification_mobilenetv2_2022apr.onnx'), + ppresnet50=Quantize(model_path='../../models/image_classification_ppresnet/image_classification_ppresnet50_2022jan.onnx'), + nanodet=Quantize(model_path='../../models/object_detection_nanodet/object_detection_nanodet_2022nov.onnx'), + yolox=Quantize(model_path='../../models/object_detection_yolox/object_detection_yolox_2022nov.onnx'), + dasiamrpn=Quantize(model_path='../../models/object_tracking_dasiamrpn/object_tracking_dasiamrpn_model_2021nov.onnx'), + dasiamrpn_cls1=Quantize(model_path='../../models/object_tracking_dasiamrpn/object_tracking_dasiamrpn_kernel_cls1_2021nov.onnx'), + dasiamrpn_r1=Quantize(model_path='../../models/object_tracking_dasiamrpn/object_tracking_dasiamrpn_kernel_r1_2021nov.onnx'), + youtureid=Quantize(model_path='../../models/person_reid_youtureid/person_reid_youtu_2021nov.onnx'), + mp_palmdet=Quantize(model_path='../../models/palm_detection_mediapipe/palm_detection_mediapipe_2023feb.onnx'), + mp_handpose=Quantize(model_path='../../models/handpose_estimation_mediapipe/handpose_estimation_mediapipe_2023feb.onnx'), + lpd_yunet=Quantize(model_path='../../models/license_plate_detection_yunet/license_plate_detection_lpd_yunet_2023mar.onnx'), + mp_persondet=Quantize(model_path='../../models/person_detection_mediapipe/person_detection_mediapipe_2023mar.onnx'), + mp_pose=Quantize(model_path='../../models/pose_estimation_mediapipe/pose_estimation_mediapipe_2023mar.onnx'), + db_en=Quantize(model_path='../../models/text_detection_db/text_detection_DB_IC15_resnet18_2021sep.onnx'), + db_ch=Quantize(model_path='../../models/text_detection_db/text_detection_DB_TD500_resnet18_2021sep.onnx'), + crnn_en=Quantize(model_path='../../models/text_recognition_crnn/text_recognition_CRNN_EN_2021sep.onnx'), + crnn_ch=Quantize(model_path='../../models/text_recognition_crnn/text_recognition_CRNN_CH_2021sep.onnx'), + crnn_cn=Quantize(model_path='../../models/text_recognition_crnn/text_recognition_CRNN_CN_2021nov.onnx') +) + +if __name__ == '__main__': + selected_models = [] + for i in range(1, len(sys.argv)): + selected_models.append(sys.argv[i]) + if not selected_models: + selected_models = list(models.keys()) + print('Models to be quantized to fp16: {}'.format(str(selected_models))) + + for selected_model_name in selected_models: + q = models[selected_model_name] + print("------------------{}------------------".format(selected_model_name)) + q.run() diff --git a/tools/quantize/requirements.txt b/tools/quantize/requirements.txt index 5650ee30..b2ee03ce 100644 --- a/tools/quantize/requirements.txt +++ b/tools/quantize/requirements.txt @@ -3,3 +3,4 @@ onnx onnxruntime onnxruntime-extensions neural-compressor +onnxconverter-common