Skip to content

YuxinZou/cls2det

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

cls2det is an object detection tool based on PyTorch. Unlike most popular object detection algorithms, cls2det implement object detection with only a classifier pre-trained on ImageNet dataset.

Benchmark

Evaluation on class "dog" on PASCAL VOC 2012 dataset:

AP50 AP40 AP30
train 0.229 0.367 0.507
val 0.235 0.382 0.510
AR50 AR40 AR30
train 0.406 0.426 0.636
val 0.394 0.533 0.631
  • Achieve good visual results by only using a classifier without any training process
  • Although the metrics are not good as SOTA, the location of the bounding box prediction is highly correlated with the ground truth from the perspective of the intuitive feeling. In some cases, e.g. when the size of the bounding box prediction does not need to be very accurate, this tool is of great significance.

example

Requirements

  • Linux
  • Python 3.6+
  • PyTorch 1.1.0 or higher
  • CUDA 9.0 or higher

Install

a. Create a conda virtual environment and activate it.

conda create -n cls2det python=3.6 -y
conda activate cls2det

b. Install PyTorch and torchvision following the official instructions, e.g.,

conda install pytorch torchvision -c pytorch

c. Clone the cls2det repository.

git clone https://github.com/Media-Smart/cls2det.git
cd cls2det

d. Install dependencies.

pip install -r requirements.txt

Prepare data

Download Pascal VOC 2012 and put the dataset into cls2det/data directory, the structure of data directory will look like as follows:

  data
    ├── VOC2012
    │     ├── Annotations
    │     ├── ImageSets
    │     │       └──── Main
    │     └── JPEGImages
    ├── eval
    ├── result
    └── imagenet.txt

Demo

a. Config

Modify some configuration accordingly in the config file like configs/detection.py

b. Run

python tools/demo.py --config configs/cls2det_resnet18.py --img_path <path to image>

Rendered image with bounding box prediction and confidence will be stored in data/result.

Eval

a. Config

Modify some configuration accordingly in the config file like configs/detection.py

b. Run

python tools/eval.py --config configs/cls2det_resnet18.py

The evaluation report will be shown on terminal.

About

classification to detection

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages