This is a project for the course TDT4265 - Computer Vision and Deep Learning at NTNU, Trondheim by Christian Le and Aleksander Klund.
This repository contains the code for object detection on LiDAR data from the NAPLab at NTNU. The project is divided into two main modules, each using YOLOv8 and Faster R-CNN.
The dataset contains 19 clips of LiDAR data, where each clip contains ~100 frames of data and contains 8 different classes, where bounding boxes are annotated for each frame. The dataset is collected by the NAPLab at NTNU. The objective of this project is to perform object detection on this dataset.
The test set is chosen to be from frame 201 to and including frame 301, which represents motion from a seperate scene from other parts of the dataset (a good fit for a test set). All other remaining images are in the datasets/NAPLab-LiDAR/images folder which is free to be partitioned into "train" and "val" folders through functions in src/tools/data_partitioner.py.
NOTE: The dataset themselves cannot be found in this repository, but within the devices used to train the models as redistribution of the dataset is prohibited.
Before running the code, the configuration files need to be set up. The configuration files are in YAML format and contain the parameters for running the different modes of each architecture. The configuration files are located in the configs/ folder.
The configuration files for the YOLOv8 model can be found in configs/YOLOv8/. The configuration files are in YAML format and contain the parameters for training, validation, prediction and exporting.
The "params" section in each .yaml file needs to follow the standard format of YOLOv8 train, val and pred parameters. They can be found here. Unspecified parameters will be set to default values. Other fields are specific for this project.
NOTE: Results of training are saved in "runs/detect/trainX", where "X" is specified in the terminal upon starting and ending training, where highest X is usually the most recent run. This can be changed by specifying "project" and "name" in "params".
NOTE: Validation data are saved in "runs/detect/valX", where "X" follows the same logic as in training. This can be changed by specifying "project" and "name" in "params".
NOTE: The model is validated on the test set, which is specified in "data" in "params".
NOTE: Prediction images are by default saved in "results/nameOfArchitecture".
NOTE: This function also attempts to export training, validation, prediction, configuration and emissions.csv to the export folder (appears after running the export mode).
The configuration files for the Faster R-CNN model can be found in configs/FasterRCNN/. The configuration files are in YAML format and contain the parameters for training, validation, prediction and exporting.
WORK IN PROGRESS
The scripts are run using the CLI,
$ python src/main.py --arch <str(required)> --mode <str(optional)> --model <str(optional)>
Explanation of the arguments:
TIP: Often when these functions are performed on a remote machine, the export function is very useful to collect the results and models in one place, which can then be transferred by doing the following on the local machine,
$ scp -r <user>@<remote_address>:<path_to_export_folder> <local_path>
YOLO supports tensorboard. There are multiple ways to check the tensorboard when using SSH into a remote server.
Tensorboard can be checked on local machine by port forwarding by doing the following on the local machine,
$ ssh -L <port>:localhost:<port> <remote address>
Here, it is assumed that the Tensorboard is located in "localhost:
Open the command line in VSCode (Ctrl + Shift + P) and type "Python: Open Tensorboard". This will open a new tab in the VSCode where the tensorboard can be accessed.
To start tensorboard, run the following command in the terminal,
$ tensorboard --logdir <path_to_tensorboard_logs>
The terminal will show the link to the tensorboard, which can be accessed in the browser.
To run the training in the background and avoid interruptions due to possible issues with local machine, it is recommended to use TMUX. To start a new session, run
$ tmux new -s <session_name>
To detach from the session, press "Ctrl + B" and then "D". To reattach to the session, run
$ tmux attach -t <session_name>