GithubHelp home page GithubHelp logo

livst / feature-extraction-with-caffe Goto Github PK

View Code? Open in Web Editor NEW

This project forked from snownus/feature-extraction-with-caffe

0.0 1.0 0.0 106.13 MB

Machine learning with features extracted from convolutional neural networks

License: MIT License

Python 100.00%

feature-extraction-with-caffe's Introduction

Feature Extraction with Caffe

Image feature extraction with Caffe
Including some examples classify the Oxford-IIIT Pet Dataset using scikit-learn

Dependencies

Caffe, Python 2, NumPy, scikit-learn, matplotlib

Installation

Download the CaffeNet modelfile to caffe/models/bvlc_reference_caffenet/ and other dependent files by this script

./data/ilsvrc12/get_ilsvrc_aux.sh

Modify the deploy.prototxt file as following

cp models/bvlc_reference_caffenet/deploy.prototxt  
      models/bvlc_reference_caffenet/deploy_feature.prototxtgedit models/bvlc_reference_caffenet/deploy_feature.prototxt
# line 152
layer {
  name: "fc6"
  type: "InnerProduct"
  bottom: "pool5"
  # top: "fc6"    # comment out
  top: "fc6wi"    # add
  inner_product_param {
    num_output: 4096
  }
}
layer {
  name: "relu6"
  type: "ReLU"
  # bottom: "fc6" # comment out
  bottom: "fc6wi" # add
  top: "fc6"
}

Usage

Make sure that the path to caffe_root (-c), images (-p) are correctly designated.
You should prepare a '.npy' file (-i) contains image filenames in numpy.array.
If you use a GPU, set the device ID (-g).

python feature_extract.py -c caffe/ -p images/ -i image_filenames.npy -g 0

Examples

  • Contour of grid search (SVM)
    Grid Search (SVM)

  • Classification of Oxford-IIIT Pet Dataset using SVM

> accuracy = sklearn.metrics.accuracy_score(test_labels, predicts)
> print(accuracy)
0.829838709677  

> report = sklearn.metrics.classification_report(test_labels, predicts, target_names)
> print(report)
                            precision    recall  f1-score   support

          american bulldog       0.66      0.80      0.72        50
 american pit bull terrier       0.66      0.58      0.62        50
              basset hound       0.78      0.80      0.79        50
                    beagle       0.71      0.60      0.65        50
                     boxer       0.71      0.78      0.74        50
                 chihuahua       0.89      0.78      0.83        50
    english cocker spaniel       0.81      0.84      0.82        50
            english setter       0.85      0.78      0.81        50
        german shorthaired       0.95      0.82      0.88        50
            great pyrenees       0.84      0.84      0.84        50
                  havanese       0.88      0.84      0.86        50
             japanese chin       0.93      0.86      0.90        50
                  keeshond       0.98      0.98      0.98        50
                leonberger       0.88      0.92      0.90        50
        miniature pinscher       0.87      0.82      0.85        50
              newfoundland       0.85      0.92      0.88        50
                pomeranian       0.95      0.78      0.86        50
                       pug       0.96      0.98      0.97        50
             saint bernard       0.81      0.86      0.83        50
                   samoyed       0.84      0.94      0.89        50
          scottish terrier       0.90      0.90      0.90        49
                 shiba inu       0.79      0.88      0.83        50
staffordshire bull terrier       0.56      0.66      0.61        41
           wheaten terrier       0.79      0.84      0.82        50
         yorkshire terrier       0.96      0.92      0.94        50

               avg / total       0.83      0.83      0.83      1240
  • Confusion matrix
    Confusion Matrix (SVM)

  • Keeshond (the best class in F-score)
    Keeshond

  • Staffordshire bull terrier (the worst class)
    Staffordshire bull terrier

  • American pit bull terrier (sometimes predicted as staffordshire bull terrier)
    American pit bull terrier

feature-extraction-with-caffe's People

Contributors

masaki-y avatar amasky avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.