Giter Club home page Giter Club logo

keras-dogs's Introduction

Fine grain Dog Classification held by Baidu

author: cweihang

Star this repository if you find it helpful, thank you.

Language: English/简体中文

About

This is a dog classification competition held by Baidu. Competition URL: http://js.baidu.com/

Framework

Hardware

  • Geforce GTX 1060 6G
  • Intel® Core™ i7-6700 CPU
  • Memory 8G

Model

Structure of Xception

Implemented in Keras

  • Remove the final classify dense layer in Xception to get the deep feature
  • Input two images, containing same or different labels
  • Train the model with categorical loss of two images and their class labels
  • Train the model with binary loss meaning whether two images belong to same class or not

Data pre-process

Previous link was provided by Baidu and only Baidu has the rights to spread the data, thus I can not provide the data anymore if Baidu canceled the link shared. You can refer to http://dianshi.baidu.com/gemstone/competitions/detail?raceId=17 with another newly published dataset on which you can apply the same algorithm. You can also apply this model on Person ReID dataset Market1501. But you should do some processing on the data. You can refer to part of our CVPR paper code: rank-reid

  • Place the images with the same class into same directory, for using ImageDataGenerator.
  • Because I named the images with the format "typeid_randhash.jpg", I wrote img2keras.py for the work described above.
  • There are more details to handle. If you meet any error, refer the Keras document first. If you still have some question, you can create an issue.

Training

  • Use ImageDataGenerator for data argumentation
  • It's hard to find positive samples for binary training using ImageDataGenerator, because the samples are shuffled. Looking throughout the data set for positive samples is inefficient. Fortunately, in each batch, we can find some samples with the same class. So we simply swap those samples to construct positive samples.
  • Frozen the Xception CNN layers, train the full connected layers for category and binary classification with ADAM
  • Unfroze final two blocks(layer 105 to the end) of Xception, continue training with SGD
  • Remove data argumentation, retrain until converge

Code

Result

  • InceptionV3, softmax loss: 0.2502
  • Xception, softmax loss: 0.2235
  • Xception, multi loss: 0.211
  • Xception, multi loss, fine tune without data argumentation: 0.2045

If you find some bug in this code, create an issue or a pull request to fix it, thanks!

keras-dogs's People

Contributors

ahangchen 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.