# FII-CenterNet **Repository Path**: leofansq/FII-CenterNet ## Basic Information - **Project Name**: FII-CenterNet - **Description**: FII-CenterNet: an anchor-free detector with foreground attention for traffic object detection (IEEE-TVT) - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: https://github.com/leofansq/FII-CenterNet - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-04-13 - **Last Updated**: 2022-04-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # FII-CenterNet: An Anchor-free Detector with Foreground Attention for Traffic Object Detection ![architecture](./img/architecture.png) > 更多的细节请参考: > > [FII-CenterNet: An Anchor-free Detector with Foreground Attention for Traffic Object Detection](https://ieeexplore.ieee.org/document/9316984) ### (0) 摘要 大多数成功的目标检测方法都是Anchor-based的,而预先设定的Anchor参数使得他们较难适应复杂多样的道路交通目标。我们将前景信息引入CenterNet以减少复杂交通场景中背景干扰信息的影响,进而提出了一个新的Anchor-free的目标检测方法--FII-CenterNet。该方法基于2D视觉图像语义分割实现前景区域提案,并将前景和背景的过渡区域定义为中景区域。除了引入前景的位置信息,该方法同时利用前景的尺寸信息以提升目标尺寸的回归效果。 ![abstract](./img/abstract.png) ### (1) 准备 本代码已在下述环境下测试: Python 3.6, PyTorch v0.4.1, Ubuntu 16.04 (CUDA 9.0, cuDNN v7). * Python环境准备 ``` conda create -n FIICenterNet python=3.6 source activate FIICenterNet ``` * 安装 pytorch0.4.1 ``` conda install pytorch=0.4.1 torchvision -c pytorch ``` * 安装 COCOAPI ``` # COCOAPI=/path/to/clone/cocoapi git clone https://github.com/cocodataset/cocoapi.git $COCOAPI cd $COCOAPI/PythonAPI make python setup.py install --user ``` * 克隆本仓库 * 配置所需环境 ``` pip install -r requirements.txt ``` * 编译 deformable convolutional (DCNv2) ``` cd $FIICenterNet_ROOT/src/lib/models/networks/DCNv2 ./make.sh ``` * [**可选项**] 编译NMS (如需使用多尺度测试 multi-scale testing). ``` cd $FIICenterNet_ROOT/src/lib/external make ``` * 下载预训练模型 | 数据集 | 预训练模型 | 结果 | |--------------------------|----------------|------------| | KITTI | [Baidu](https://pan.baidu.com/s/1IGcg4YLN_nLxZNHLVHyOyg): 3xdh | [Baidu](https://pan.baidu.com/s/1jZ5ct4zgKZ7thDV5XbLOjw): sb67 | | Pascal VOC | [Baidu](https://pan.baidu.com/s/1pWldlPXlugVCIKaMKF6zJQ): xhta | [Baidu](https://pan.baidu.com/s/1ZRNd-7-rwGB3DrGMnKYYYQ): f0oi | ### (2) KITTI数据集 ![KITTI](./img/kitti.png) * 准备数据集 目前数据集需被转换为COCO格式. * 下载数据集 [KITTI](http://www.cvlibs.net/datasets/kitti/eval_object.php?obj_benchmark=2d) * 文件结构 ``` FII-CenterNet 根目录 |---- data |---- kitti |---- training |---- Labels (包含下载的 labels txt) |---- KITTI_COCO |---- annotations (包含转换好格式的 labels jason) |---- images (包含下载的训练图片) |---- test_images (包含下载的测试图片) ``` > 已转换好格式的 annotations [Baidu](https://pan.baidu.com/s/1zp7U3hHY6_06gUSp3KQDJg): t55q * 训练 ``` python main.py ctdet --exp_id kitti_exp --dataset=kitti --batch_size 8 --gpus 0 --attention --wh_weight=0.1 --lr=1e-4 ``` > 当为了Evaluation而训练时,将 ./src/lib/datasets/dataset/kitti_half.py 重命名为 kitti.py > 当为了Testing而训练时,将 ./src/lib/datasets/dataset/kitti_full.py 重命名为 kitti.py * Evaluation * 预测 ``` python test.py --exp_id kitti_exp --not_prefetch_test ctdet --dataset=kitti --load_model /your_path/your_model.pth --attention --flip_test ``` * 评价 ``` ./tools/kitti_eval/evaluate_object_3d_offline ../data/kitti/training/Labels/ /your_path/results/ ``` * Testing ``` python test.py --exp_id kitti_full --not_prefetch_test ctdet --dataset=kitti --load_model /your_path/model_last.pth --attention --flip_test --trainval ``` ### (3) Pascal VOC数据集 ![voc](./img/voc.png) * 准备数据集 为对比评价该方法效果,实验在 VOC 2007 和 VOC 2012 trainval sets 上训练, 在 VOC 2007 test set 上测试. 目前数据集需被转换为COCO格式. * 下载数据集 * 文件结构 ``` FII-CenterNet 根目录 |---- data |---- VOC_COCO |---- Annotations (包含下载的 annotations xml) |---- annotations (包含转换好的 jason) |---- images (包含下载的训练图片) ``` > 转换好格式的 annotations [Baidu](https://pan.baidu.com/s/1zTozLskCJkV2vF6ZIIzIRw): qbhp * 训练 ``` python main.py ctdet --exp_id voc_exp --batch_size 32 --gpus 0,1 --attention --wh_weight=0.1 --lr=1.25e-4 --num_epochs=140 --lr_step='90,120' ``` * Evaluation * 预测 ``` python test.py --exp_id voc_exp --not_prefetch_test ctdet --load_model /your_path/your_model.pth --attention --flip_test --trainval ``` * 评价 ``` python tools/reval.py /your_path/results.json ``` ### (4) 可视化 ![demo](./img/demo.png) ``` python demo.py ctdet --demo /.../FII-CenterNet/kitti_images/ --load_model /your_path/your_model.pth --attention --debug=2 ``` ### 引用 ``` @ARTICLE{9316984, author={S. {Fan} and F. {Zhu} and S. {Chen} and H. {Zhang} and B. {Tian} and Y. {Lv} and F. -Y. {Wang}}, journal={IEEE Transactions on Vehicular Technology}, title={FII-CenterNet: An Anchor-free Detector with Foreground Attention for Traffic Object Detection}, year={2021}, volume={}, number={}, pages={1-1}, doi={10.1109/TVT.2021.3049805} } ``` ### 致谢 部分代码基于 [Objects as Points](https://github.com/xingyizhou/CenterNet).