All Projects → yassersouri → fast-bird-part-localization

yassersouri / fast-bird-part-localization

Licence: MIT license
Code for Fast Bird Part Localization (FGVC 2015)

Programming Languages

Jupyter Notebook
11667 projects
python
139335 projects - #7 most used programming language

fast-bird-part-localization

Code for Fast Bird Part Localization part of the following paper:

Fast Bird Part Localization for Fine-Grained Categorization
Yaser Souri, Shohreh Kasaei
The Third Workshop on Fine-Grained Visual Categorization (FGVC3) in conjunction with CVPR 2015

The code for classification part is very simple and not included in this repository.

Requirements

  1. Python 2.7. This might not work with Python 3.
  2. A recent installation of caffe with its python wrapper. (I have installed this version of caffe.)
  3. OpenCV 2.4 with its Python wrapper.
  4. All other python requirements are mentioned in requirements.txt

Getting Started

For testing or training you need the pretrained CaffeNet network. You can download it from this url. After downloading it, make sure you change the src/settings.py file and change the CAFFE_NET_PRETRAINED variable accordingly.

Training a new head detector

This can be done using the CUB dataset. First download the CUB-200-2011 dataset from here and extract it. Then change src/settings.py file and set the CUB_FOLDER_PATH varialble accordingly.

Then run the following command:

python create_rf_model.py

This will create a head detector for you in the models directory. To run this script you will night large amount of RAM (~30GB).

Changing part_name variable in create_rf_model.py file to body instead of head will create a detector for body.

Testing

For localization you can run something like this.

import sys
sys.path.append('/path/to/projectroot/')
from fast_bird_part_localization import settings
sys.path.append(settings.CAFFE_PYTHON_PATH)
import caffe
from fast_bird_part_localization import detector

fbp = detector('/path/to/project/models/head_model.mdl')

img = caffe.io.load_image('/path/to/bird.jpg')
head, head_prob = fbp.detect(img)
fbp.draw(img, head, head_prob)

This is the result you get:

Result

You can also take a look at the notebook example

Work in Progress

I'm in progress of cleaning up my original code and putting it here. So please wait a little while.

TODO:

  • Extracting code from notebook about postprocessing.
  • Extracting code from notebook about visualization.
  • Adding description on how to use the pretrined model.
  • Adding description on how to train a new model from CUB.
  • Adding description on how to train a new model from own data.
  • Adding code for PCP evaluation.
  • Adding bounding box regression for better PCP.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].