/traffic_detection

GM Autodrive Challenge Traffic Sign and Signal recognition 2021 utilizing Yolov4 architecture to identify relevant visual information for autonomous driving. Also contains the csp darknet source code as this is implemented as a ROS package. Relevant package code in /scripts and /launch primarily. Worked alongside Angelo Yang, Nicholas Vacek, Jung Hoon Seo

Primary LanguageC

About

GM Autodrive Challenge is a competition inviting various research focused schools in competition to develop the best autonomous vehicle. This repository represents the ROS package for Traffic Sign and Signal recognition 2021 utilizing Yolov4 architecture to identify relevant visual information such as speed limit signs and traffic lights for autonomous driving. Worked alongside Angelo Yang https://www.linkedin.com/in/ryang42, Nicholas Vacek https://www.linkedin.com/in/jung-hoon-seo-5ab813178, and Jung Hoon Seo https://www.linkedin.com/in/nicholas-vacek-314a23187 We ultimately managed to place 3rd in great success and more information can be found here! http://autodrive.tamu.edu/

Demo

Link to Youtube with Video Demonstration of project

Get weight files here:

https://drive.google.com/drive/folders/1JYdu6nVTAw-i4xpqJ-Zrzcw2Wiwc3alU?usp=sharing

Training is still not done so prediction results may be rough!

Weight suffix descriptions:

  • (name)_(number, multiple of 10,000).weights
    • weight saved at that number of iterations.
  • (name)_last.weights
    • the last or most recent set of weights. May not be the best!
  • (name)_ema.weights
    • exponential moving average of all training weights.
  • (name)_best.weights
    • the best set of weights thus far, before training is done.
  • (name)_final.weights
    • the best set of weights, once training is done.

put selected .weight, classes.names, and <model>.cfg files in the models/ folder. Make sure to update the references in scripts/detect_ros.py to point to these files!

To test:

  • bunch of packages: todo just install whatever is missing for now
  • ROS is stupid old and is mostly python2.
  • God there was a lot of code that needed to be rewritten into python 2
  • CFG files need tweaking to work correctly for inference. THis is just the nature of how it works.
  • If using darknet rather than tensorflow, it imports an obj.data file, which can be set.
    • See: this link, scroll to step 3.
    • Train, valid, and backup files don't matter.
    • classes & names need to be set correctly!

Requirements:

  • sudo apt install libopencv-dev

Specific versions required to install tensorflow 2.1 on python 2.7

  • python -m pip install --upgrade pip==19.9.1
  • python -m pip install keras==2.2.4
  • python -m pip install tensorflow

tensorflow-based prediction with yolov4-csp

Using this: https://github.com/hhk7734/tensorflow-yolov4 branch to import the model into tensorflow.

To change version of OpenCV found

  • Command to remove old version of opencv from python path without deleting it:
  • sudo mv /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so /opt/ros/kinetic/lib/python2.7/cv2.so
  • Follow these install instructions for OpenCV
  • If the build doesn't work:
    • cd ~/catkin_ws/src/traffic_detection/src/opencv/build
    • cmake ../opencv-3.4.11
    • cmake --build .
  • cd ~/catkin_ws/src/traffic_detection/src/opencv/build && sudo make install
  • Need to Catkin Make with the local OpenCV install specified:
  • catkin_make -DOpenCV_DIR=~/catkin_ws/src/traffic_detection/src/opencv/build

Running inference inside ROS with ROSBag:

  • cd ~/catkin_ws/src && git clone <this repo> to clone it into the correct location.
  • source ~/catkin_ws/devel/setup.bash to start environment
  • cd ~/catkin_ws/src/traffic_detection && python bind.py build -> should no longer be needed (handled by setup.py)
  • cd ~/catkin_ws/src/traffic_detection/src/darknet && make -> should no longer be needed (handled by setup.py)
  • cd ~/catkin_ws && catkin_make
  • edit traffic_detect.launch to point to where the bag file is.
  • roslaunch traffic_detection traffic_detect.launch