GithubHelp home page GithubHelp logo

athiwatp / simple-inception-transfer-learning Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jiexunsee/simple-inception-transfer-learning

0.0 2.0 0.0 6.25 MB

A classifier for cat and dog images (Response to Siraj's challenge of the week)

Python 100.00%

simple-inception-transfer-learning's Introduction

A classifier for cats and dogs

###*** EDIT: use THIS repository for a simpler and faster implementation transfer learning with inception

This is a response to Siraj's challenge of the week.

This is a classifier made with basic TensorFlow, using Transfer Learning from the Inception-V3 model. Data is taken from this Kaggle competition, as recommended by Siraj.

Pipeline

JPG images --> Inception-V3 --> 2048-dimensional vector --> Fully connected layer --> Prediction

How to use

Training

First, train the model, run:

python classifier.py train

This script will call the getvector.py script, which uses the Inception-V3 model to produce 2048-dimensional vector representations of images. These 2048-dimensional vectors have already been saved in the data_inputs.txt and data_labels.txt files, for convenience. (It takes quite long on a CPU to run a few hundred images through the Inception network, let alone the full 25,000 image dataset.)

After getting these vector representations, I use a fully connected one layer neural network to output a prediction vector, built with TensorFlow.

For my training, I only used 300 images of cats and dogs combined. Hence the text files only contain 300 training example data. However, the network performs remarkably well for such few training examples. This is perhaps because the Inception model was trained on a lot of pictures of animals like cats and dogs so it's able to extract the relevant features.

Testing

To test the model, run:

python classifier.py test cat.jpg

This runs the cat.jpg image through the Inception-V3 network to get the 2048-dimensional vector. Then it loads the saved TensorFlow one-layer neural network, and feeds the cat.jpg image vector into it. Do try other pictures too, the predictions are quite accurate.

Notes:

I got a lot of the code from the TF Slim tutorial. It's taken from the github. Specifically, I modified Inception-V3.py from here to return the 2048-D vector when the inception_v3 function is called, instead of the 1001 logits vector. The 1001 logits vector directly correspond to the 1001 categories that Inception is trained to classify.

simple-inception-transfer-learning's People

Contributors

jiexunsee avatar

Watchers

 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.