Skip to content

Commit 25f423d

Browse files
authored
[GSoC] Add block quantized models (opencv#270)
* Gemm and MatMul block quantization support * refactoring * fix indentation * node name independent * Block quantization tool: - constant weight category supported - add data type saturation - handled the case in which all the elements within a block are the same benchmark script modified to support block quantized models block quantized some models * add missing block quantized models * formatting * add blocked models to eval script. Evaluation yunet * Add sface and pphumanseg evaluation, block quantization tool fix, handpose blocked model fix, removed blocked CRNN EN, * changed evaluation metric in block_quantize script and add verbose mode * Add evaluation for PP-ResNet and Mobilenet * changed file suffix and update readmes * renamed int8bq
1 parent 50cc599 commit 25f423d

File tree

46 files changed

+291
-52
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+291
-52
lines changed

benchmark/README.md

Lines changed: 1 addition & 1 deletion

benchmark/benchmark.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
parser.add_argument("--fp32", action="store_true", help="Benchmark models of float32 precision only.")
4747
parser.add_argument("--fp16", action="store_true", help="Benchmark models of float16 precision only.")
4848
parser.add_argument("--int8", action="store_true", help="Benchmark models of int8 precision only.")
49+
parser.add_argument("--int8bq", action="store_true", help="Benchmark models of blocked int8 precision only.")
4950
parser.add_argument("--all", action="store_true", help="Benchmark all models")
5051
args = parser.parse_args()
5152

@@ -194,15 +195,17 @@ def printResults(self, model_name, model_path):
194195
model_handler, model_paths = MODELS.get(model_config.pop('name'))
195196

196197
_model_paths = []
197-
if args.fp32 or args.fp16 or args.int8:
198+
if args.fp32 or args.fp16 or args.int8 or args.int8bq:
198199
if args.fp32:
199200
_model_paths += model_paths['fp32']
200201
if args.fp16:
201202
_model_paths += model_paths['fp16']
202203
if args.int8:
203204
_model_paths += model_paths['int8']
205+
if args.int8bq:
206+
_model_paths += model_paths['int8bq']
204207
else:
205-
_model_paths = model_paths['fp32'] + model_paths['fp16'] + model_paths['int8']
208+
_model_paths = model_paths['fp32'] + model_paths['fp16'] + model_paths['int8'] + model_paths["int8bq"]
206209
# filter out excluded models
207210
excludes = []
208211
if args.model_exclude is not None:

models/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def register(self, item):
4646
fp32_model_paths = []
4747
fp16_model_paths = []
4848
int8_model_paths = []
49+
int8bq_model_paths = []
4950
# onnx
5051
ret_onnx = sorted(glob.glob(os.path.join(model_dir, "*.onnx")))
5152
if "object_tracking" in item.__module__:
@@ -57,6 +58,8 @@ def register(self, item):
5758
int8_model_paths.append([r])
5859
elif "fp16" in r: # exclude fp16 for now
5960
fp16_model_paths.append([r])
61+
elif "blocked" in r:
62+
int8bq_model_paths.append([r])
6063
else:
6164
fp32_model_paths.append([r])
6265
# caffe
@@ -72,6 +75,7 @@ def register(self, item):
7275
fp32=fp32_model_paths,
7376
fp16=fp16_model_paths,
7477
int8=int8_model_paths,
78+
int8bq=int8bq_model_paths
7579
)
7680

7781
self._dict[item.__name__] = (item, all_model_paths)

models/face_detection_yunet/README.md

Lines changed: 7 additions & 2 deletions
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:49f000ec501fef24739071fc7e68267d32209045b6822c0c72dce1da25726f10
3+
size 122489

models/face_recognition_sface/README.md

Lines changed: 3 additions & 0 deletions
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:fb143eea07838aa532d1c95df5f69899974ea0140e1fba05e94204be13ed74ee
3+
size 10667852

models/facial_expression_recognition/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:0c3eaf9d0a7d442c0aa3beb3234243e1cdff9ad8871fb3cec346e90874caf57d
3+
size 1376702

models/handpose_estimation_mediapipe/README.md

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)