官方参考链接:https://github.com/PaddlePaddle/PaddleDetection/blob/develop/deploy/pptracking/README.md
配置一个paddle的环境
conda create -n pdgui01 python=3.7
conda activate pdgui01
conda install cudatoolkit=10.2.89 cudnn=7.6.5
python -m pip install paddlepaddle-gpu==2.1.2
验证paddle是否安装成功
import paddle
paddle.utils.run_check()
paddle.__version__
Windows环境下,需要手动下载安装cython_bbox,然后将setup.py中的找到steup.py, 修改extra_compile_args=[’-Wno-cpp’],替换为extra_compile_args = {‘gcc’: [’/Qstd=c99’]}, 然后运行python setup.py build_ext install
pip install Cython
python setup.py build_ext install
cd <PP-Tracking_GUi>
pip install -r requirements.txt
根据教程,将模型导出放在./output_inference
目录下
python main.py
官方参考教程:PP-Tracking之手把手玩转多目标跟踪
配置一个paddle的环境
conda create -n pd01 python=3.7
conda activate pd01
conda install cudatoolkit=10.2.89 cudnn=7.6.5
python -m pip install paddlepaddle-gpu==2.1.2
验证paddle是否安装成功
import paddle
paddle.utils.run_check()
paddle.__version__
Windows环境下,需要手动下载安装cython_bbox,然后将setup.py中的找到steup.py, 修改extra_compile_args=[’-Wno-cpp’],替换为extra_compile_args = {‘gcc’: [’/Qstd=c99’]}, 然后运行python setup.py build_ext install
pip install Cython
python setup.py build_ext install
cd <PaddleDetection>
pip install pycocotools && pip install -r requirements.txt && python setup.py install
数据集准备(可以手动,可以代码,二者选一即可)
手动下载
下载:https://bj.bcebos.com/v1/paddledet/data/mot/demo/MOT16.zip
可以下载到 data,然后将解压的文件夹放在 dataset/mot 中
代码下载
# 网速不好可以自行下载上传,解压
!cd ./data && wget https://bj.bcebos.com/v1/paddledet/data/mot/demo/MOT16.zip
!mv ./data/MOT16.zip ./PaddleDetection/dataset/mot
!cd ./PaddleDetection/dataset/mot && unzip MOT16.zip
# 生成labels_with_ids
!cd ./PaddleDetection/dataset/mot/MOT16 && mkdir images
!cd ./PaddleDetection/dataset/mot/MOT16 && mv ./train ./images && mv ./test ./images
!cd ./PaddleDetection/dataset/mot && python gen_labels_MOT.py
import glob
import os.path as osp
image_list = []
for seq in sorted(glob.glob('PaddleDetection/dataset/mot/MOT16/images/train/*')):
for image in glob.glob(osp.join(seq, "img1")+'/*.jpg'):
image = image.replace('PaddleDetection/dataset/mot/','')
image_list.append(image)
with open('mot16.train','w') as image_list_file:
image_list_file.write(str.join('\n',image_list))
然后将生成的mot16.train文件,复制到 /PaddleDetection/dataset/mot/image_lists下面
mkdir ./PaddleDetection/dataset/mot/image_lists
cp -r mot16.train ./PaddleDetection/dataset/mot/image_lists
修改配置文件
修改配置文件里面的数据集
添加在PaddleDetection/configs/mot/fairmot/fairmot_dla34_30e_1088x608.yml文件最后
# for MOT training
# for MOT training
TrainDataset:
!MOTDataSet
dataset_dir: dataset/mot
image_lists: ['mot16.train']
data_fields: ['image', 'gt_bbox', 'gt_class', 'gt_ide']
# for MOT evaluation
# If you want to change the MOT evaluation dataset, please modify 'data_root'
EvalMOTDataset:
!MOTImageFolder
dataset_dir: dataset/mot
data_root: MOT16/images/train
keep_ori_im: False # set True if save visualization images or video, or used in DeepSORT
# for MOT video inference
TestMOTDataset:
!MOTImageFolder
dataset_dir: dataset/mot
keep_ori_im: True # set True if save visualization images or video
训练
python -m paddle.distributed.launch --log_dir=./fairmot_dla34_30e_1088x608 --gpus 0 tools/train.py -c configs/mot/fairmot/fairmot_dla34_30e_1088x608.yml
ps:可能遇到的问题
问题1:
升级numpy即可
pip install numpy
问题2:
改以下文件"base/fairmot_reader_1088x608.yml"
为了方便我们下载训练好的模型进行eval https://paddledet.bj.bcebos.com/models/mot/fairmot_dla34_30e_1088x608.pdparams
根据官方样例做的
python tools/eval_mot.py -c configs/mot/fairmot/fairmot_dla34_30e_1088x608.yml -o weights=output/download/fairmot_dla34_30e_1088x608.pdparams