Skip to content

Commit

Permalink
Fix fcn-resnet50-12 accuracy check pipeline
Browse files Browse the repository at this point in the history
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
  • Loading branch information
vinnamkim committed Jun 13, 2022
1 parent e85a695 commit 25c30bd
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
38 changes: 38 additions & 0 deletions examples/experimental/onnx/accuracy_checker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
Copyright (c) 2022 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

from openvino.tools.accuracy_checker.annotation_converters.ms_coco import COCO_TO_VOC, MSCocoSegmentationConverter
from openvino.tools.accuracy_checker.main import main


class MSCocoSegmentationToVOCConverter(MSCocoSegmentationConverter):
__provider__ = 'mscoco_segmentation_to_voc'

@staticmethod
def _read_image_annotation(image, annotations, label_id_to_label):
image_labels, is_crowd, segmentation_polygons = MSCocoSegmentationConverter._read_image_annotation(
image, annotations, label_id_to_label)

# Convert to VOC labels
image_labels = MSCocoSegmentationToVOCConverter.convert_to_voc(
image_labels)

return image_labels, is_crowd, segmentation_polygons

@staticmethod
def convert_to_voc(image_labels):
return [COCO_TO_VOC[label] if label in COCO_TO_VOC else 0 for label in image_labels]


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ models:
datasets:
- name: mscoco_segmentation_to_voc
annotation_conversion:
converter: mscoco_segmentation
converter: mscoco_segmentation_to_voc
annotation_file: annotations/instances_val2017.json
has_background: True
sort_annotations: True
semantic_only: True
# This should be an absolute path
masks_dir: /mnt/ssd2/omz_data/val2017/segmentation_masks
masks_dir: segmentation_masks
# Only evaluate on VOC labels
convert_COCO_to_VOC_labels: True
annotation: mscoco_segmentation_to_voc.pickle
Expand Down
4 changes: 2 additions & 2 deletions examples/experimental/onnx/run_ptq_onnx_models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ for config in `ls $CONFIGS_DIR`; do

echo "2) Check model accuracy for $model_name (original)"
# Accuracy check for the original model
accuracy_check \
python $SCRIPT_DIR/accuracy_checker.py \
-c $CONFIGS_DIR/$config \
-ss $NUMBER_OF_SAMPLES \
-m $MODEL_DIR/$model_name.onnx \
Expand All @@ -56,7 +56,7 @@ for config in `ls $CONFIGS_DIR`; do

echo "3) Check model accuracy for $model_name (quantized)"
# Accuracy check for the quantized model
accuracy_check \
python $SCRIPT_DIR/accuracy_checker.py \
-c $CONFIGS_DIR/$config \
-ss $NUMBER_OF_SAMPLES \
-m $OUTPUT_DIR/$model_name-quantized.onnx \
Expand Down

0 comments on commit 25c30bd

Please sign in to comment.