- Introduction
- Demo
- Model Weights
- Dataset
- Methods
- Inference Performance
- Integration of OneAPI
- Other Integration Possiblities
- Further Works
- License
Semantic segmentation, a cornerstone of computer vision, involves understanding images at a pixel level. This repository embarks on a journey from training a robust semantic segmentation model on Oxford's Pets dataset to optimizing it for real-time inference using OpenVINO. The goal is to maintain exceptional accuracy while achieving lightning-fast performance.
A short video demonstration showcases the efficiency and accuracy achieved through the integration of OpenVINO.
Run demo.py. Make sure to have model weights in the path ./model/model_int8.xml
Demo.mp4
Model weights can be found in the Releases page. In order to run the final demo, you need only the INT8 files.
I used the Oxford's Pets dataset for our training and evaluation. This dataset offers a rich collection of diverse pet images along with meticulous pixel-wise annotations, providing the foundation for seamless semantic segmentation tasks.
- Pytorch
- OpenCV
- Pytorch Segmentation Models
- NNCF (Neural Network Compression Framework for enhanced OpenVINO™ inference)
- OpenVINO
- Intel Extention for Pytorch
The evolution of our model is outlined through these pivotal methods:
- Torch: Training of the model. And using torch for initial baseline to start with.
- TorchScript: Transitioning to TorchScript enables dynamic Just-In-Time (JIT) compilation, enhancing computational efficiency.
- Intel PyTorch Extension (IPEX) - BFFloat: IPEX with BFFloat optimization leverages oneDNN. IPEX applies graph fusion, which is accelerated by oneDNN.
- Testing Quantization: Quantization with Callibration data was used then to compress the model to INT8 without compermising on accuracy.
- OpenVINO Integration: The optimized model seamlessly converts to OpenVINO's Intermediate Representation (IR) format, delivering fast inference speed.
The leap in inference performance is astonishing:
- Initial PyTorch CPU inference speed: ~16 frames per second (fps).
- Inference speed with OpenVINO CPU (INT8 precision): ~100 fps.
Notably, this performance enhancement is achieved without any compromise on segmentation accuracy.
Optimization is at the heart of this project, facilitated by OneAPI tools:
- Export to ONNX: Model Optimizer (MO) exports the model to ONNX format for compatibility with OpenVINO.
- NNCF Quantization: Neural Network Compression Framework (NNCF) enables INT8 quantization and exporting.
- Intel OpenVINO Inference Engine: The Intel OpenVINO Inference Engine drives rapid execution during inference.
- Can use other Intel Hardware (Intel Xeon Processors, Habana Gaudi Instances, Intel Server GPUs) via DevCloud for training by leveraging IPEX and Torch XPU interface. Since I had a GPU locally, I preffered using it.
- Host an async inference server, and use the model for real-time inference with data from other devices. Couldn't do because of lack of hardware presently with me.
- Use the model for real-time inference with data from other devices (Make use of inference server within OpenVINO).
- Extend this to use Intel NCS on edge Devices
This project operates under the MIT License, granting you the freedom to manipulate, adjust, and share the code while adhering to the original license terms.