Skip to content
312308542Public

About

Official implementation of OV-DINO: Unified Open-Vocabulary Detection with Language-Aware Selective Fusion

Resources

Stars

1 star

Watchers

0 watching

Forks

Β 
Β 

Latest commit

Β 

History

56 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ¦– OV-DINO

Unified Open-Vocabulary Detection with Language-Aware Selective Fusion

Hao Wang1,2,Pengzhen Ren1,Zequn Jie3, Xiao Dong1, Chengjian Feng3, Yinlong Qian3,

Lin Ma3, Dongmei Jiang2, Yaowei Wang2,4, Xiangyuan Lan2πŸ“§, Xiaodan Liang1,2πŸ“§

1 Sun Yat-sen University, 2 Pengcheng Lab, 3 Meituan Inc, 4 HIT, Shenzhen

πŸ“§ corresponding author.

[Paper] [HuggingFace] [Demo] [BibTex]

πŸ”₯ Updates

  • 16/07/2024: We provide the online demo, click and enjoy !!!

  • 16/07/2024: We release the web inference demo, try to deploy it by yourself.

  • 15/07/2024: We release the fine-tuning code, try to fine-tune on your custom dataset. Feel free to raise issue if you encounter some problem.

  • 15/07/2024: We release the local inference demo, try to deploy OV-DINO on you local machine and run inference on images.

  • 14/07/2024: We release the pre-trained models and the evaluation code.

  • 11/07/2024: We release OV-DINO paper on arxiv. Code and pre-trained model are coming soon.

πŸš€ Introduction

This project contains the official PyTorch implementation, pre-trained models, fine-tuning code, and inference demo for OV-DINO.

  • OV-DINO is a novel unified open vocabulary detection approach that offers superior performance and effectiveness for practical real-world application.

  • OV-DINO entails a Unified Data Integration pipeline that integrates diverse data sources for end-to-end pre-training, and a Language-Aware Selective Fusion module to improve the vision-language understanding of the model.

  • OV-DINO shows significant performance improvement on COCO and LVIS benchmarks compared to previous methods, achieving relative improvements of +2.5% AP on COCO and +12.7% AP on LVIS compared to G-DINO in zero-shot evaluation.

πŸ“„ Overview

✨ Model Zoo

Model Pre-Train Data APmv APr APc APf APval APr APc APf APcoco Weights
OV-DINO1 O365 24.4 15.5 20.3 29.7 18.7 9.3 14.5 27.4 49.5 / 57.5 HF CKPTπŸ€—
OV-DINO2 O365,GoldG 39.4 32.0 38.7 41.3 32.2 26.2 30.1 37.3 50.6 / 58.4 HF CKPTπŸ€—
OV-DINO3 O365,GoldG,CC1M‑ 40.1 34.5 39.5 41.5 32.9 29.1 30.4 37.4 50.2 / 58.2 HF CKPTπŸ€—

NOTE: APmv denotes the zero-shot evaluation results on LVIS MiniVal, APval denotes the zero-shot evaluation results on LVIS Val, APcoco denotes (zero-shot / fine-tune) evaluation results on COCO, respectively.

🏁 Getting Started

1. Project Structure

OV-DINO
β”œβ”€β”€ datas
β”‚Β Β  β”œβ”€β”€ coco
β”‚   β”‚   β”œβ”€β”€ annotations
β”‚   β”‚   β”œβ”€β”€ train2017
β”‚   β”‚   └── val2017
β”‚   β”œβ”€β”€ lvis
β”‚   β”‚   β”œβ”€β”€ annotations
β”‚   β”‚   β”œβ”€β”€ train2017
β”‚   β”‚   └── val2017
β”‚   └── custom
β”‚       β”œβ”€β”€ annotations
β”‚       β”œβ”€β”€ train
β”‚       └── val
β”œβ”€β”€ inits
β”‚Β Β  β”œβ”€β”€ huggingface
β”‚Β Β  β”œβ”€β”€ ovdino
β”‚Β Β  └── swin
β”œβ”€β”€ ovdino
β”‚Β Β  β”œβ”€β”€ configs
β”‚Β Β  β”œβ”€β”€ demo
β”‚Β Β  β”œβ”€β”€ detectron2-717ab9
β”‚Β Β  β”œβ”€β”€ detrex
β”‚Β Β  β”œβ”€β”€ projects
β”‚Β Β  β”œβ”€β”€ scripts
β”‚Β Β  └── tools
β”œβ”€β”€ wkdrs
β”‚   β”œβ”€β”€ ...
β”‚

2. Installation

# clone this project
git clone https://github.com/wanghao9610/OV-DINO.git
cd OV-DINO
export root_dir=$(realpath ./)
cd $root_dir/ovdino

# create conda env
conda create -n ovdino -y
conda activate ovdino
conda install pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 pytorch-cuda=11.6 -c pytorch -c nvidia -y
conda install gcc=8 gxx=8 -c conda-forge -y # Optional install gcc8
python -m pip install -e detectron2-717ab9
pip install -e ./

2. Data Preparing

COCO

  • Download COCO from the official website, and put them on datas/coco folder.
    cd $root_dir
    wget http://images.cocodataset.org/zips/train2017.zip -O datas/coco/train2017.zip
    wget http://images.cocodataset.org/zips/val2017.zip -O datas/coco/val2017.zip
    wget http://images.cocodataset.org/annotations/annotations_trainval2017.zip -O datas/coco/annotations_trainval2017.zip
  • Extract the ziped files, and remove them:
    cd $root_dir
    unzip datas/coco/train2017.zip -d datas/coco
    unzip datas/coco/val2017.zip -d datas/coco
    unzip datas/coco/annotations_trainval2017.zip -d datas/coco
    rm datas/coco/train2017.zip datas/coco/val2017.zip datas/coco/annotations_trainval2017.zip

LVIS

  • Download LVIS annotation files:
    cd $root_dir
    wget https://huggingface.co/hao9610/OV-DINO/resolve/main/lvis_v1_minival_inserted_image_name.json -O datas/lvis/annotations/lvis_v1_minival_inserted_image_name.json
    wget https://huggingface.co/hao9610/OV-DINO/resolve/main/lvis_v1_val_inserted_image_name.json -O datas/lvis/annotations/lvis_v1_val_inserted_image_name.json
  • Soft-link COCO to LVIS:
    cd $root_dir
    ln -s $(realpath datas/coco/train2017) datas/lvis
    ln -s $(realpath datas/coco/val2017) datas/lvis

3. Evaluation

Download the pre-trained model from Model Zoo, and put them on inits/ovdino directory.

cd $root_dir/ovdino
sh scripts/eval.sh path_to_eval_config_file path_to_pretrained_model output_directory

Zero-Shot Evaluation on COCO Benchmark

cd $root_dir/ovdino
sh scripts/eval.sh \
  projects/ovdino/configs/ovdino_swin_tiny224_bert_base_eval_coco.py \
  ../inits/ovdino/ovdino_swint_og-coco50.6_lvismv39.4_lvis32.2.pth \
  ../wkdrs/eval_ovdino

Zero-Shot Evaluation on LVIS Benchmark

cd $root_dir/ovdino
sh scripts/eval.sh \
  projects/ovdino/configs/ovdino_swin_tiny224_bert_base_eval_lvismv.py \
  ../inits/ovdino/ovdino_swint_ogc-coco50.2_lvismv40.1_lvis32.9.pth \
  ../wkdrs/eval_ovdino

sh scripts/eval.sh \
  projects/ovdino/configs/ovdino_swin_tiny224_bert_base_eval_lvis.py \
  ../inits/ovdino/ovdino_swint_ogc-coco50.2_lvismv40.1_lvis32.9.pth \
  ../wkdrs/eval_ovdino

4. Fine-Tuning

Fine-Tuning on COCO Dataset

cd $root_dir/ovdino
sh scripts/train.sh \
  projects/ovdino/configs/ovdino_swin_tiny224_bert_base_ft_coco_24ep.py \
  ../inits/ovdino/ovdino_swint_og-coco50.6_lvismv39.4_lvis32.2.pth

Fine-Tuning on Custom Dataset

  • Prepare your custom dataset as the COCO annotation format.

  • Refer the following command to run fine-tuning.

    cd $root_dir/ovdino
    sh scripts/train.sh \
      projects/ovdino/configs/ovdino_swin_tiny224_bert_base_ft_custom_24ep.py \
      ../inits/ovdino/ovdino_swint_ogc-coco50.2_lvismv40.1_lvis32.9.pth

πŸ’» Demo

  • Local inference on a image or folder give the category names.

    cd $root_dir/ovdino
    sh scripts/demo.sh demo_config.py pretrained_model category_names input_images_or_directory output_directory

    Examples:

    cd $root_dir/ovdino
    # single image inference
    sh scripts/demo.sh \
      projects/ovdino/configs/ovdino_swin_tiny224_bert_base_infer_demo.py \
      ../inits/ovdino/ovdino_swint_ogc-coco50.2_lvismv40.1_lvis32.9.pth \
      "class0 class1 class2 ..." img0.jpg output_dir/img0_vis.jpg
    
    # multi images inference
    sh scripts/demo.sh \
      projects/ovdino/configs/ovdino_swin_tiny224_bert_base_infer_demo.py \
      ../inits/ovdino/ovdino_swint_ogc-coco50.2_lvismv40.1_lvis32.9.pth \
      "class0 long_class1 long_class2 ..." "img0.jpg img1.jpg" output_dir
    
    # image folder inference
    sh scripts/demo.sh \
      projects/ovdino/configs/ovdino_swin_tiny224_bert_base_infer_demo.py \
      ../inits/ovdino/ovdino_swint_ogc-coco50.2_lvismv40.1_lvis32.9.pth \
      "class0 long_class1 long_class2 ..." image_dir output_dir

    NOTE: the input category_names are separated by spaces, and the words of single class are connected by underline (_).

  • Web inference demo.

    cd $root_dir/ovdino
    sh scripts/app.sh \
      projects/ovdino/configs/ovdino_swin_tiny224_bert_base_infer_demo.py \
      ../inits/ovdino/ovdino_swint_ogc-coco50.2_lvismv40.1_lvis32.9.pth

    After the web demo deployment, you can open the demo on your browser.

    We also provide the online demo, click and enjoy.

βœ… TODO

  • Release the pre-trained model.
  • Release the fine-tuning and evaluation code.
  • Support the local inference demo.
  • Support the web inference demo.
  • Support OV-DINO in πŸ€— transformers.
  • Release the pre-training code.

😊 Acknowledge

This project has referenced some excellent open-sourced repos (Detectron2, detrex, GLIP, G-DINO, YOLO-World). Thanks for their wonderful works and contributions to the community.

πŸ“Œ Citation

If you find OV-DINO is helpful for your research or applications, please consider giving us a star 🌟 and citing it by the following BibTex entry.

@article{wang2024ovdino,
  title={OV-DINO: Unified Open-Vocabulary Detection with Language-Aware Selective Fusion}, 
  author={Hao Wang and Pengzhen Ren and Zequn Jie and Xiao Dong and Chengjian Feng and Yinlong Qian and Lin Ma and Dongmei Jiang and Yaowei Wang and Xiangyuan Lan and Xiaodan Liang},
  journal={arXiv preprint arXiv:2407.07844},
  year={2024}
}

About

Official implementation of OV-DINO: Unified Open-Vocabulary Detection with Language-Aware Selective Fusion

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages