Coder Social home page Coder Social logo

kaggle-cats-vs-dogs-redux's Introduction

Kaggle Cats vs Dogs Redux

Hi, this is my solution for the dogs vs cats redux kaggle competition that achieve the 51st place on the oficial public leaderboard. The solution is quite simple because I made it three days until the end of the competition and cannot improve it.

You can find the 3rd position solution on the kaggle blog

Architecture

I decide to start with a pre-trained model for this competition and I fallback to the Inception V3 model. The model achieve 99.8% accuracy. The final submission score can be improved in several ways, like emsembling more models, xgboost to combine classifiers, preprocess the training images(flip, rotate, scale), use external data, among others.

Installation

git clone https://github.com/mauri870/kaggle-cats-vs-dogs-redux.git
cd kaggle-cats-vs-dogs-redux

Preprocessing

First you need to download the train and test data from kaggle. The test and train images must be inside a test and train folder respectively

Run the preprocess script to prepare the data. It'll fit each image in a 299x299 box and fill the blank space in black color.

go run preprocess.go utils.go

Since the inception model expects the train images to be organized into subfolders, let's do that:

mkdir -p images/{dogs,cats}
cp -v images/train/cat* images/cats
cp -v images/train/dog* images/dogs

Retrain Inception V3

Here's my instructions to build and retrain the inception model:

Let's download and configure tensorflow:

export TF_VERSION=v1.0.0
wget -qO- https://github.com/tensorflow/tensorflow/archive/${TF_VERSION}.tar.gz | tar zx
cd tensorflow-${TF_VERSION}
./configure

Now we will retrain the last fully connected layers of the inception model:

python tensorflow/examples/image_retraining/retrain.py --flip_left_right --image_dir=$OLDPWD/images

Next we need to optimize our model because some ops used to train the original model are now deprecated and in case of the Golang tensorflow bindings will result in a fatal error

bazel build tensorflow/python/tools/optimize_for_inference
bazel-bin/tensorflow/python/tools/optimize_for_inference --input=/tmp/output_graph.pb --output=/tmp/output_graph_optimized.pb  --frozen_graph=True --input_names=Mul --output_names=final_result

Submission

Now we are ready to create the submission file!

Note: Refer to the official page in order to install and configure tensorflow for go

go run submission.go utils.go

kaggle-cats-vs-dogs-redux's People

Contributors

mauri870 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

petronetto

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.