3rd place (with the best Efficiency Score) in Challenge Track 1: Multi-Class Multi-Movement Vehicle Counting in 2020 AI City Challenge @ CVPR.
By Team Orange-Control from 1AI Labs, Didi Chuxing (DiDi AI Labs) and 2Beijing University of Posts and Telecommunications (BUPT).
- Team Members: Wenwei Li2,1, Haowen Wang2,1, Yue Shi1, Ke Dong1, Bo Jiang1, Zhengping Che1 (team leader), Jian Tang1 (advisor), and Xiuquan Qiao2 (advisor)
- python3.6
torch==1.5.0+cu101
torchvision==0.6.0+cu101
opencv-python==4.2
pandas==0.24.2
numpy==1.17.3
sklearn==0.21.2
filterpy==1.4.5
easydict==1.9
ffmpeg==2.8.15
numba==0.46.0
tensorboard>=1.14
pycocotools==2.0.0
tqdm==4.33.0
pillow==6.1.0
Here are the steps to reproduce our results:
- Download the corresponding model file best.pt and put it in the folder
weights
. - Make sure the raw video files and required txt files are in the folder
data/Dataset_A
. - Run
inference.py
to get separate result files in the folderoutput
for all 31 videos. - Run
result.py
to combine all 31 csv files and get the single submission filetrack1.txt
.
mkdir weights
mkdir output
python3 inference.py 1 31
python3 result.py
We use YOLOv3+sort to detect and track vehicles. To count the movement, we use a detection line (detection line) for each movement by annotating the provided training videos (Data set A), as defined in get_lines.py
. If a vehicle passes the detection line, the count of the corresponding movement will increase by 1 after a short pre-defined delay calculated based on the training data.
We use yolov3 as our detector, which is initialized by the public COCO pre-trained model and fine-tuned with some annotated frames from the training set (which will be described later). The corresponding files are in the folder yolov3_pytorch
. Below are the steps to train the detector.
- Make sure the following files are placed correctly.
- The training images (extracted from the raw training videos) in
data/images/
- The annotation text files in
yolov3_pytorch/data/labels/
object.data
andobject.names
inyolov3_pytorch/data
, which describe the input data and output classes
- The training images (extracted from the raw training videos) in
- Downdload the official coco pretrained model yolov3.weights from https://pjreddie.com/darknet/yolo/ and put it in
yolov3_pytorch/weights
. - Use the following train command to finetine the pretrained model. The
train_best.pt
file is the final model.
cd yolov3_pytorch
unzip data/labels.zip
python3 train.py --data data/object.data --cfg cfg/yolov3.cfg --epochs 200
Some of the utility scripts are borrowed from https://github.com/ultralytics/yolov3.
We selected 5 videos from the provided training videos (Data set A), including cam3.mp4, cam5.mp4, cam7.mp4, cam8.mp4, cam20.mp4
. A subset of 3835 frames was extracted from these videos for manual annotation.
You can use the following command to extract frames directly from the videos.
ffmpeg -i cam_x.mp4 -r 1 -f image2 yolov3_pytorch/data/images/%06d.jpg
The extracted frames should be put in the folder yolov3_pytorch/data/images
.