Example scripts for the detection of lanes using the ultra fast lane detection model in Tensorflow Lite.

Overview

TFlite Ultra Fast Lane Detection Inference

Example scripts for the detection of lanes using the ultra fast lane detection model in Tensorflow Lite.

!Ultra fast lane detection Source: https://www.flickr.com/photos/32413914@N00/1475776461/

Requirements

  • OpenCV, scipy and tensorflow/tflite_runtime. pafy and youtube-dl are required for youtube video inference.

Installation

pip install -r requirements.txt
pip install pafy youtube-dl

For the tflite runtime, you can either use tensorflow pip install tensorflow or the TensorFlow Runtime

tflite model

The original model was converted to different formats (including .tflite) by PINTO0309, download the models from his repository and save it into the models folder.

Original Pytorch model

The Pytorch pretrained model from the original repository.

Ultra fast lane detection - TuSimple(link)

  • Input: RGB image of size 800 x 200 pixels.
  • Output: Keypoints for a maximum of 4 lanes (left-most lane, left lane, right lane, and right-most lane).

Examples

  • Image inference:
python imageLaneDetection.py 
  • Webcam inference:
python webcamLaneDetection.py
  • Video inference:
python videoLaneDetection.py

Pytorch inference

For performing the inference in Pytorch, check my other repository Ultrafast Lane Detection Inference Pytorch.

ONNX inference

For performing the inference in ONNX, check my other repository ONNX Ultra Fast Lane Detection Inference.

Inference video Example

!Ultrafast lane detection on video

Original video: https://youtu.be/2CIxM7x-Clc (by Yunfei Guo)

You might also like...
A repository that shares tuning results of trained models generated by TensorFlow / Keras. Post-training quantization (Weight Quantization, Integer Quantization, Full Integer Quantization, Float16 Quantization), Quantization-aware training. TensorFlow Lite. OpenVINO. CoreML. TensorFlow.js. TF-TRT. MediaPipe. ONNX. [.tflite,.h5,.pb,saved_model,tfjs,tftrt,mlmodel,.xml/.bin, .onnx] Python scripts to detect faces in Python with the BlazeFace Tensorflow Lite models
Python scripts to detect faces in Python with the BlazeFace Tensorflow Lite models

Python scripts to detect faces using Python with the BlazeFace Tensorflow Lite models. Tested on Windows 10, Tensorflow 2.4.0 (Python 3.8).

Python script for performing depth completion from sparse depth and rgb images using the msg_chn_wacv20. model in Tensorflow Lite.
Python script for performing depth completion from sparse depth and rgb images using the msg_chn_wacv20. model in Tensorflow Lite.

TFLite-msg_chn_wacv20-depth-completion Python script for performing depth completion from sparse depth and rgb images using the msg_chn_wacv20. model

Use tensorflow to implement a Deep Neural Network for real time lane detection
Use tensorflow to implement a Deep Neural Network for real time lane detection

LaneNet-Lane-Detection Use tensorflow to implement a Deep Neural Network for real time lane detection mainly based on the IEEE IV conference paper "To

A tutorial showing how to train, convert, and run TensorFlow Lite object detection models on Android devices, the Raspberry Pi, and more!
A tutorial showing how to train, convert, and run TensorFlow Lite object detection models on Android devices, the Raspberry Pi, and more!

A tutorial showing how to train, convert, and run TensorFlow Lite object detection models on Android devices, the Raspberry Pi, and more!

VIL-100: A New Dataset and A Baseline Model for Video Instance Lane Detection (ICCV 2021)

Preparation Please see dataset/README.md to get more details about our datasets-VIL100 Please see INSTALL.md to install environment and evaluation too

Swapping face using Face Mesh with TensorFlow Lite
Swapping face using Face Mesh with TensorFlow Lite

Swapping face using Face Mesh with TensorFlow Lite

A Data Annotation Tool for Semantic Segmentation, Object Detection and Lane Line Detection.(In Development Stage)
A Data Annotation Tool for Semantic Segmentation, Object Detection and Lane Line Detection.(In Development Stage)

Data-Annotation-Tool How to Run this Tool? To run this software, follow the steps: git clone https://github.com/Autonomous-Car-Project/Data-Annotation

Ultra-lightweight human body posture key point CNN model. ModelSize:2.3MB  HUAWEI P40 NCNN benchmark: 6ms/img,
Ultra-lightweight human body posture key point CNN model. ModelSize:2.3MB HUAWEI P40 NCNN benchmark: 6ms/img,

Ultralight-SimplePose Support NCNN mobile terminal deployment Based on MXNET(=1.5.1) GLUON(=0.7.0) framework Top-down strategy: The input image is t

Comments
  • Bad inference Result!

    Bad inference Result!

    I used the pretrained mode "model_float16_quant.tflite" from this repo https://github.com/PINTO0309/PINTO_model_zoo/tree/main/140_Ultra-Fast-Lane-Detection but I got the following result: out27

    and the orginal image is: SC600_Forward_20220206130511_26

    any hints I can do to enhance the output!? @ibaiGorordo

    opened by AbdulFMS 2
  • Name 'lanes_points' is not defined

    Name 'lanes_points' is not defined

    Hello, thanks for the code. I'm running "imageLaneDetection.py" with culan tflite model and change model_type value in imageLaneDetection.py like:

    model_type = ModelType.CULANE
    

    then, i got these on terminal:

    163: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
      return np.array(lane_points_mat), np.array(lanes_detected)
    Traceback (most recent call last):
      File "imageLaneDetection.py", line 18, in <module>
        output_img = lane_detector.detect_lanes(img)
      File "/home/ubuntu/Codes/TfLite-Ultra-Fast-Lane-Detection-Inference/ultrafastLaneDetector/ultrafastLaneDetector.py", line 82, in detect_lanes
        visualization_img = self.draw_lanes(image, self.lanes_points, self.lanes_detected, self.cfg, draw_points)
      File "/home/ubuntu/Codes/TfLite-Ultra-Fast-Lane-Detection-Inference/ultrafastLaneDetector/ultrafastLaneDetector.py", line 175, in draw_lanes
        cv2.fillPoly(lane_segment_img, pts = [np.vstack((lanes_points[1],np.flipud(lanes_points[2])))], color =(255,191,0))
    NameError: name 'lanes_points' is not defined
    

    image

    is the error message means the "lanes_points" variable in ultrafastLaneDetector.py is not defined? Where should I define the "lanes_points" in code?

    opened by Yan-Long-Huang 2
  • cannot find the model_float32.tflite in the ModelZoo

    cannot find the model_float32.tflite in the ModelZoo

    i keep getting this error:

    _interpreter_wrapper.CreateWrapperFromFile( ValueError: Could not open 'models/model_float32.tflite'.

    Can anyone help please ?

    opened by gm24med 0
Owner
Ibai Gorordo
Passionate about sensors, technology and their potential to help people.
Ibai Gorordo
Lane assist for ETS2, built with the ultra-fast-lane-detection model.

Euro-Truck-Simulator-2-Lane-Assist Lane assist for ETS2, built with the ultra-fast-lane-detection model. This project was made possible by the amazing

null 36 Jan 5, 2023
Official code for "Eigenlanes: Data-Driven Lane Descriptors for Structurally Diverse Lanes", CVPR2022

[CVPR 2022] Eigenlanes: Data-Driven Lane Descriptors for Structurally Diverse Lanes Dongkwon Jin, Wonhui Park, Seong-Gyun Jeong, Heeyeon Kwon, and Cha

Dongkwon Jin 106 Dec 29, 2022
LaneDet is an open source lane detection toolbox based on PyTorch that aims to pull together a wide variety of state-of-the-art lane detection models

LaneDet is an open source lane detection toolbox based on PyTorch that aims to pull together a wide variety of state-of-the-art lane detection models. Developers can reproduce these SOTA methods and build their own methods.

TuZheng 405 Jan 4, 2023
KSAI Lite is a deep learning inference framework of kingsoft, based on tensorflow lite

KSAI Lite is a deep learning inference framework of kingsoft, based on tensorflow lite

null 80 Dec 27, 2022
LaneDetectionAndLaneKeeping - Lane Detection And Lane Keeping

LaneDetectionAndLaneKeeping This project is part of my bachelor's thesis. The go

null 5 Jun 27, 2022
Python scripts form performing stereo depth estimation using the HITNET model in Tensorflow Lite.

TFLite-HITNET-Stereo-depth-estimation Python scripts form performing stereo depth estimation using the HITNET model in Tensorflow Lite. Stereo depth e

Ibai Gorordo 22 Oct 20, 2022
Python scripts for performing stereo depth estimation using the MobileStereoNet model in Tensorflow Lite.

TFLite-MobileStereoNet Python scripts for performing stereo depth estimation using the MobileStereoNet model in Tensorflow Lite. Stereo depth estimati

Ibai Gorordo 4 Feb 14, 2022
Lane follower: Lane-detector (OpenCV) + Object-detector (YOLO5) + CAN-bus

Lane Follower This code is for the lane follower, including perception and control, as shown below. Environment Hardware Industrial Camera Intel-NUC(1

Siqi Fan 3 Jul 7, 2022
Find-Lane-Line - Use openCV library and Python to detect the road-lane-line

Find-Lane-Line This project is to use openCV library and Python to detect the road-lane-line. Data Pipeline Step one : Color Selection Step two : Cann

Kenny Cheng 3 Aug 17, 2022
Python scripts for performing lane detection using the LSTR model in ONNX

ONNX LSTR Lane Detection Python scripts for performing lane detection using the Lane Shape Prediction with Transformers (LSTR) model in ONNX. Requirem

Ibai Gorordo 29 Aug 30, 2022