The project folder holds codes related to MMRotate and SAM.
Script Descriptions:
eval_zero-shot-oriented-detection_dota.py
implement Zero-shot Oriented Object Detection with SAM. It prompts SAM with predicted boxes from a horizontal object detector.demo_zero-shot-oriented-detection.py
inference single image for Zero-shot Oriented Object Detection with SAM.data_builder
holds configuration information and process of dataset, dataloader.
The project is refer to sam-mmrotate.
conda create -n mmrotate-sam python=3.8 -y
conda activate mmrotate-sam
pip install torch==1.9.1+cu111 torchvision==0.10.1+cu111 -f https://download.pytorch.org/whl/torch_stable.html
pip install openmim
mim install mmengine 'mmcv>=2.0.0rc0' 'mmrotate>=1.0.0rc0'
pip install git+https://github.com/facebookresearch/segment-anything.git
pip install opencv-python pycocotools matplotlib onnxruntime onnx
Note: You can also choose to install MMRotate from source code:
git clone https://github.com/open-mmlab/mmrotate.git
cd mmrotate; pip install -e .; cd ..
- Inference MMRotate-SAM with a single image and obtain visualization result.
# download weights
cd mmrotate_sam
mkdir ../models
wget -P ../models https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth
wget -P ../models https://download.openmmlab.com/mmrotate/v0.1.0/rotated_fcos/rotated_fcos_sep_angle_r50_fpn_1x_dota_le90/rotated_fcos_sep_angle_r50_fpn_1x_dota_le90-0be71a0c.pth
# demo
python demo_zero-shot-oriented-detection.py \
../mmrotate/data/split_ss_dota/test/images/P0006__1024__0___0.png \
../mmrotate/configs/rotated_fcos/rotated-fcos-hbox-le90_r50_fpn_1x_dota.py \
../models/rotated_fcos_sep_angle_r50_fpn_1x_dota_le90-0be71a0c.pth \
--sam-type "vit_b" --sam-weight ../models/sam_vit_b_01ec64.pth --out-path output.png
- Evaluate the quantitative evaluation metric on DOTA data set.
python eval_zero-shot-oriented-detection_dota.py \
../mmrotate/configs/rotated_fcos/rotated-fcos-hbox-le90_r50_fpn_1x_dota.py \
../models/rotated_fcos_sep_angle_r50_fpn_1x_dota_le90-0be71a0c.pth \
--sam-type "vit_b" --sam-weight ../models/sam_vit_b_01ec64.pth