Quantizing Semantic Segmentation Model¶
This example demonstrates the use of the Post-training Optimization Tool API for the task of quantizing a segmentation model. The DeepLabV3 model from TensorFlow* is used for this purpose. A custom
DataLoader is created to load the Pascal VOC 2012 dataset for semantic segmentation task and the implementation of Mean Intersection Over Union metric is used for the model evaluation. The code of the example is available on GitHub.
How to prepare the data¶
To run this example, you will need to download the validation part of the Pascal VOC 2012 image database http://host.robots.ox.ac.uk/pascal/VOC/voc2012/#data. Images are placed in the
JPEGImages folder, ImageSet file with the list of image names for the segmentation task can be found at
ImageSets/Segmentation/val.txt and segmentation masks are kept in the
How to Run the example¶
Launch Model Downloader tool to download
deeplabv3model from the Open Model Zoo repository.
omz_downloader --name deeplabv3
Launch Model Converter tool to generate Intermediate Representation (IR) files for the model:
omz_converter --name deeplabv3 --mo <PATH_TO_MODEL_OPTIMIZER>/mo.py
Launch the example script from the example directory:
python3 ./segmentation_example.py -m <PATH_TO_IR_XML> -d <VOCdevkit/VOC2012/JPEGImages> --imageset-file <VOCdevkit/VOC2012/ImageSets/Segmentation/val.txt> --mask-dir <VOCdevkit/VOC2012/SegmentationClass>
Optional: you can specify .bin file of IR directly using the