Home ONNX HybridNets Multitask Road Detection
Post
Cancel

Open In Github

Python scripts for performing road segemtnation and car detection using the HybridNets multitask model in ONNX.

!HybridNets Road multitask detections

Requirements

  • Check the requirements.txt file. Additionally, pafy and youtube-dl are required for youtube video inference.

Installation

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

ONNX model

The original models were converted to different formats (including .onnx) by PINTO0309, download the models from his repository and save them into the models folder.

Original Pytorch model

The Pytorch pretrained model was taken from the original repository.

Examples

  • Image inference: !HybridNets Image Road multitask detections Original image: https://commons.wikimedia.org/wiki/File:2021-02-23_Tuesday_16.02.01-16.11.18_UTC-3_Route_S-40_(Chile).webm?uselang=es
    1
    
     python image_road_detection.py
    
  • Video Bird Eye View: https://youtu.be/SbJ7C5d6X1w !HybridNets Bird eye view Road multitask detections

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

1
 python video_bird_eye_view_road_detection.py

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

1
 python video_road_detection.py

Bird Eye View for Custom Video:

If you use a different video for teh bird eye view, you will have to modify the horizon points. Set horizon_points=None to trigger the horizon point selection mode. This mode will show the image and wait until the two horizon points are selected as in the image below. A horizontal line is used as a guide, if the road does not reach that height, you can ignore the horizontal line. Copy the printed output into the horizon_points variable for next inferences.

!Horizon point selection

References:

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