Home ONNX TopFormer Semantic Segmentation
Post
Cancel

Open In Github

Python scripts performing semantic segmentation using the TopFormer model in ONNX.

!TopFormer Semantic Segmentation Original image: https://en.wikipedia.org/wiki/File:Beatles_-_Abbey_Road.jpg

Requirements

  • Check the requirements.txt file.
  • For ONNX, if you have a NVIDIA GPU, then install the onnxruntime-gpu, otherwise use the onnxruntime library.
  • Additionally, pafy and youtube-dl are required for youtube video inference.

Installation

1
2
3
git clone https://github.com/ibaiGorordo/ONNX-TopFormer-Semantic-Segmentation.git
cd ONNX-TopFormer-Semantic-Segmentation
pip install -r requirements.txt

ONNX Runtime

For Nvidia GPU computers: pip install onnxruntime-gpu

Otherwise: pip install onnxruntime

For youtube video inference

1
2
pip install youtube_dl
pip install git+[https://github.com/zizo-pro/pafy@b8976f22c19e4ab5515cacbfae0a3970370c102b](https://github.com/zizo-pro/pafy@b8976f22c19e4ab5515cacbfae0a3970370c102b)

ONNX model

The model was converted from the Pytorch implementation using the code in the original repository. Download the converted ONNX model from the drive file and save them into the models folder.

Pytorch model

The original Pytorch model can be found in this repository: https://github.com/hustvl/TopFormer

Examples

  • Image inference:
    1
    
     python image_semantic_segmentation.py
    
  • Webcam inference:
    1
    
     python webcam_semantic_segmentation.py
    
  • Video inference: https://youtu.be/JkOSbtKfIFo
    1
    
     python video_semantic_segmentation.py
    

    !CREStereo depth estimation

Original video: https://youtu.be/yWHdkK5j4yk

References:

This post is licensed under CC BY 4.0 by the author.