buzhidaoshenme / YOLOX-OBB

YOLOX in DOTA with KLD loss. (Oriented Object Detection)(Rotated BBox)基于YOLOX的旋转目标检测
Apache License 2.0
74 stars 19 forks source link

YOLOX-OBB

YOLOX in DOTA with KLD loss. (Oriented Object Detection)(Rotated BBox)基于YOLOX的旋转目标检测

Installation

  1. Install YOLOX-OBB(You can refer to the installation of YOLOX)
    cd YOLOX-OBB
    pip3 install -r requirements.txt
    pip3 install -v -e
  2. Install pycocotools
    pip3 install cython; pip3 install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
  3. Install swig
    sudo apt-get install swig
  4. Create the c++ extension for python
    cd DOTA_devkit_YOLO
    swig -c++ -python polyiou.i
    python setup.py build_ext --inplace
    cd -
  5. Install apex
    git clone https://github.com/NVIDIA/apex
    cd apex
    pip install -v --no-cache-dir ./
    cd -

    Data Preparation

  6. Split images and annotations(You can refer to DOTA_devkit_YOLO)

    python DOTA_devkit_YOLO/ImgSplit_multi_process.py
    1. Transform annotations into voc-like format
    • This is a object in voc-like format annotation:
    python custom tools/DOTA2VOC_obb.py
    1. Organize Directories(All annotations of train-images and val-images must be put into Annotations folder)
      |--your_data
      |--VOC2012
       |--Annotations
           |-- xxx.xml
               ... 
       |--ImageSets
           |--Main
               |--train.txt
               |--val.txt
               |--test.txt
       |--JPEGImages
       |--JPEGImages-val
       |-JPEGImages-test

      Train

  7. Modify configs

 change the data path with yours in yolox_dota_s_obb_kld.py

data_dir = 'your_data_path'
  1. Train

    CUDA_VISIBLE_DEVICES=0,1 python3 tools/train.py -f exps/example/yolox_voc/yolox_dota_s_obb_kld.py -d 2 -b 16 --fp16 -c weights/yolox_s.pth.tar

    Val

  2. get results

    CUDA_VISIBLE_DEVICES=0,1 python tools/eval.py -f exps/example/yolox_voc/yolox_dota_s_obb_kld.py -d 2 -b 16 -c YOLOX_outputs/yolox_dota_s_obb_kld/latest_ckpt.pth

     Results will be save to your_data/results/VOC2012/Main

    • If test, you must comment line 151 'target = self.load_anno(index)' and uncomment line 152 'target = []' in dota_obb.py before run the above instruction. Because test-set has no annotations.
  3. Merge results(You can refer to DOTA_devkit_YOLO)

    python DOTA_devkit_YOLO/ResultMerge.py
  4. Evaluation

    python DOTA_devkit_YOLO/dota_v1.5_evaluation_task1.py(You can refer to [DOTA_devkit_YOLO](https://github.com/hukaixuan19970627/DOTA_devkit_YOLO))
    • If test, you should upload your results to DOTA Evaluation Server.

Unfortunately

This implementation only get 0.712 mAP@0.5 on DOTA v1.0.

Reference

YOLOX

DOTA_devkit_YOLO

YOLOv5_DOTA_OBB

RotationDetection