Skip to content

Commit

Permalink
YOLOv4 quantization support (openvinotoolkit#662)
Browse files Browse the repository at this point in the history
* added quantization of YOLOv4
  • Loading branch information
negvet committed Apr 16, 2021
1 parent c63c72e commit f85636d
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 2 deletions.
3 changes: 2 additions & 1 deletion beta/examples/tensorflow/object_detection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,5 @@ To export a model to the OpenVINO IR and run it using the Intel® Deep Learning
|RetinaNet|Sparsity 50% (Magnitude)|COCO2017|33.13|[retinanet_coco_magnitude_sparsity.json](configs/sparsity/retinanet_coco_magnitude_sparsity.json)|[Link](https://storage.openvinotoolkit.org/repositories/nncf/tensorflow/models/develop/retinanet_sparsity_50.tar.gz)|
|RetinaNet|Filter Pruning 40%|COCO2017|32.7|[retinanet_coco_pruning.json](configs/pruning/retinanet_coco_pruning.json)|[Link](https://storage.openvinotoolkit.org/repositories/nncf/tensorflow/models/develop/retinanet_pruning_40.tar.gz)|
|YOLOv4|None|COCO2017|47.04|[yolo_v4_coco.json](configs/yolo_v4_coco.json)|[Link](https://storage.openvinotoolkit.org/repositories/nncf/tensorflow/models/develop/yolo_v4.tar.gz)|
|YOLOv4|Sparsity 50% (Magnitude)|COCO2017|46.54|[yolo_v4_coco_magnitude_sparsity.json](configs/sparsity/yolo_v4_coco_magnitude_sparsity.json)|[Link](https://storage.openvinotoolkit.org/repositories/nncf/tensorflow/models/develop/yolo_v4_sparsity_50.tar.gz)|
|YOLOv4|INT8 w:sym,per-channel a:asym,per-tensor |COCO2017|46.20|[yolo_v4_coco_int8.json](configs/quantization/yolo_v4_coco_int8.json)|[Link](https://storage.openvinotoolkit.org/repositories/nncf/tensorflow/models/develop/yolo_v4_int8_w_sym_ch_a_asym_t.tar.gz)|
|YOLOv4|Sparsity 50% (Magnitude)|COCO2017|46.54|[yolo_v4_coco_magnitude_sparsity.json](configs/sparsity/yolo_v4_coco_magnitude_sparsity.json)|[Link](https://storage.openvinotoolkit.org/repositories/nncf/tensorflow/models/develop/yolo_v4_sparsity_50.tar.gz)|
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"model": "YOLOv4",
"input_info": {
"sample_size": [1, 608, 608, 3]
},

"epochs": 1,
"batch_size": 63,
"workers": 16,

"dataset": "coco/2017",
"dataset_type": "tfds",

"optimizer": {
"type": "Adam",
"schedule_type": "cosine",
"schedule_params": {
"base_lr": 5e-6
}
},

"compression": {
"algorithm": "quantization",
"weights": {
"per_channel": true
},
"activations": {
"mode": "asymmetric"
},
"initializer": {
"range": {
"num_init_samples": 200,
"type": "minmax_percentile"
}
}
}
}

13 changes: 12 additions & 1 deletion beta/tests/sota_checkpoints_eval.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,18 @@
"batch_per_gpu": 15,
"reverse_input_channels": true,
"scale_value": "Placeholder[255]"

},
"yolo_v4_int8_w_sym_ch_a_asym_t": {
"config":"examples/tensorflow/object_detection/configs/quantization/yolo_v4_coco_int8.json",
"reference":"yolo_v4",
"target":46.20,
"resume":"yolo_v4_int8_w_sym_ch_a_asym_t",
"metric_type":"mAP",
"model_description":"yolo_v4_int8_w_sym_ch_a_asym_t",
"compression_description":"INT8",
"batch_per_gpu": 15,
"reverse_input_channels": true,
"scale_value": "Placeholder[255]"
},
"yolo_v4_sparsity_50": {
"config":"examples/tensorflow/object_detection/configs/sparsity/yolo_v4_coco_magnitude_sparsity.json",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
models:
- name: yolo_v4
launchers:
- framework: dlsdk
device: CPU
adapter:
type: yolo_v3
anchors: 12,16,19,36,40,28,36,75,76,55,72,146,142,110,192,243,459,401
num: 3
coords: 4
classes: 80
threshold: 0.001
anchor_masks: [[0,1,2],[3,4,5],[6,7,8]]
raw_output: True
outputs:
- yolo_v4/nncf_wrapper_predict_conv_3/BiasAdd/Add
- yolo_v4/nncf_wrapper_predict_conv_2/BiasAdd/Add
- yolo_v4/nncf_wrapper_predict_conv_1/BiasAdd/Add
datasets:
- name: ms_coco_detection_80_class_without_background
data_source: MSCOCO/val2017
annotation_conversion:
converter: mscoco_detection
annotation_file: MSCOCO/annotations/instances_val2017.json
has_background: False
sort_annotations: True
use_full_label_map: False
annotation: mscoco_det_80.pickle
dataset_meta: mscoco_det_80.json

preprocessing:
- type: resize
size: 608
postprocessing:
- type: resize_prediction_boxes
- type: filter
apply_to: prediction
min_confidence: 0.001
remove_filtered: true
- type: nms
overlap: 0.5
- type: clip_boxes
apply_to: prediction
metrics:
- type: map
integral: 11point
ignore_difficult: true
presenter: print_scalar
- name: AP@0.5
type: coco_precision
max_detections: 100
threshold: 0.5
- name: AP@0.5:0.05:0.95
type: coco_precision
max_detections: 100
threshold: '0.5:0.05:0.95'

0 comments on commit f85636d

Please sign in to comment.