As shown in our software stack diagram, we have three main modules: preprocessing, training, and postprocessing. In preprocessing, we augment the synthetic data to bridge the domain gap between the training and test sets. For the training module, our model utilizes a yolov8 network. For postprocessing, we propose novel methods such as retrospective rectification and selective deblurring to further improve the model's accuracy.
The inference can be run with some simple commands. The code is tested on Google Colab.
- Clone the repo and cd into the root directory:
git clone https://github.com/cycv5/AICityChallenge
cd AICityChallenge
- Run the setup code:
./setup.sh
- Place the input videos under
AICityChallenge/data/test/video
, make sure the video is named in the format ofxxx_n.mp4
where n is the video number. - Download the pre-trained weight here, or prepare your own weight file in pt format. To reproduce the leaderboard results precisely, please use the pretrained weight as the training process is non-deterministic (with variable parameters).
- Place the weight under
AICityChallenge/yolov8_tracking/weights
, or a place of your choice. - Run the
run.py
file as following,img_dir
andsave_dir
are optional, by default they will beAICityChallenge/data/test/video
andAICityChallenge/data/test/out
:
python3 run.py --img_dir <dir/containing/videos> --save_dir <dir/containing/output> --weights <dir/to/weights>
- Your result.txt will be in
AICityChallenge/data/test/out
or any directory you specify in 6.
-
Download the AI City Track 4 raw data and put under
AICityChallenge/yolov8_train/raw_data
-
Run the data augmentation script
data_gen.py
with the following parameters: source_dir, background_dir, target_dir, segmentation_dir.-
cd AICityChallenge/yolov8_train
-
python3 data_gen.py --source_dir raw_data/train --background_dir frame0.jpg --target_dir aug_data --segmentation_dir raw_data/segmentation_labels
-
-
Split the test val dataset with the splitfolders tool
pip3 install split-folders[full]
and thensplitfolders --ratio .9 .1 --output custom_data aug_data
-
Now you can run the python train.py script with the input parameters of your choice such as the number of epochs, batch size, GPU devices, learning rate, etc. In addition, you could also try ensemble learning by averaging the confidence score of different models, but we have the best model available in the shared link. Otherwise, you could use the default settings:
python3 train.py
-
The results will be saved in the
AICityChallenge/yolov8_train/runs
directory.
Enjoy 😄