Giter Site home page Giter Site logo

dogsvscats's Introduction

Kaggle: Dogs vs Cats Kernel Redux Edition

This repository consists a solution for the Cats vs Dogs classification challenge on Kaggle.
This solution scored a logloss of 0.04973 (#60 / 1314 teams). Top score was 0.03303 (#1).

This repository also contains links to my best and second best CNN models below.

Features

  • Best model (download Keras model here) achieves accuracy of 99.6% on unseen data.
  • Ensemble of the best model with the second best (download Keras model here) achieves 99.8% accuracy on unseen data. Predictions of the two models are simply averaged.
  • The performance is a result of finetuning pretrained models (Resnet-50 & Inception v3 respectively).
  • Used several data augmentation techniques -- channel jittering, blurs, brightness-contrast shifts, rotation, zooms, horizontal-vertical shifts and flips.

What worked

  • Using ELU activations or BatchNorm + PReLu
  • Using Dropout on Dense Layers with Data Augmentation
  • Using Pretrained models works like magic! 🙏
  • Training small models (10 layers max) from scratch for 25000 images plateaus at double the logloss than when using pretrained models, in my case.
  • Using larger image sizes improves accuracy till 350 x 350
  • Ensembling different models gives a very good accuracy boost. Higher the difference (different image sizes, different architectures etc.), better is the advantage of the ensemble.
  • Using the trained model to detect mistakes in the training and validation data!

What didn't turn out as expected

  • Going beyond the plateau logloss when training from scratch was almost impossible; probably because the lower layers did not learn good enough representations with limited data.
  • Trying to finetune last conv block of the pretrained models leads to overfitting in my case.
  • Using Dropout in conv layers leads to poor accuracy
  • Training even small models without BatchNorm and only using plain ReLU activations takes a huge amount of time.
  • Mean subtraction + Dividing by Standard Deviation speeds up training

Using the trained models

Download the trained models:
ResNet50 finetuned (best model) (Input shape: 350 x 350 x 3)
InceptionV3 finetuned (second best) (Input shape: 299 x 299 x 3)

from keras.models import load_model
model = load_model('bestvalyet.h5')  # weights path.

Both the models use Tensorflow dimension ordering.

dogsvscats's People

Contributors

prajwalkr avatar

Stargazers

Gerard jourdain Grégoire Charles  avatar Roman avatar Rudrabha Mukhopadhyay avatar  avatar  avatar  avatar GAURAV avatar cnn avatar Zhuolin Ji avatar coldgemini avatar cbsudux avatar Joe Chen avatar  avatar  avatar  avatar Suhith Rajesh avatar B Adarsh avatar Anantha Natarajan S avatar Harsha Srinivas avatar SHRAVAN MURALI avatar

Watchers

James Cloos avatar  avatar Samit avatar  avatar  avatar  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.