GithubHelp home page GithubHelp logo

dcn01 / gimagesearch-tensorflow-classifier Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alexdevmotion/gimagesearch-tensorflow-classifier

0.0 0.0 0.0 845.66 MB

A classifier similar to the google image search tool; categories: face, photo, clip art, line drawing

JavaScript 0.89% Python 97.32% HTML 1.68% Batchfile 0.11%

gimagesearch-tensorflow-classifier's Introduction

gimagesearch-tensorflow-classifier

A classifier similar to the google image search tool; categories: face, photo, clip art, line drawing ... with a state of the art GUI!

Prerequisites

  • Python 3.5 with pip (I used 64bit Anaconda 5.2.0)

Setup

pip install tensorflow
pip install tensorflow_hub
pip install flask

Firing up the app

Windows only

Linux users, I'm sure you'll figure out how to rewrite the complex start script :)

start.cmd

Note: The python installation and Scripts folders need to be in your %PATH%

Enriching the dataset

  • Make a google image search
  • Scroll down until images become irrelevant to your model
  • Open the browser console
  • Paste the js code from gimages_dataset_builder/js_console.js as indicated in the file's comments
  • A urls.txt file will be downloaded with the paths to all images in the search
  • Download the images using the download script

Downloading images

Image downloader params example (photo_urls is the urls.txt exported by the js script)

--urls gimages_dataset_builder\image_lists\photo_urls --output tensorflow_classifier\input\photo

This will automatically avoid unsupported formats and try to delete invalid images at the end, however, invalid images may still remain (sometimes, image extensions are not correct). If you get an error during training, just delete the image.

Retraining the model

Followed official guide for retraining an image classifier for new categories: https://www.tensorflow.org/tutorials/image_retraining

Defaults:

--image_dir input --summaries_dir model/retrain_logs --output_labels model/output_labels.txt --output_graph model/output_graph.pb
 --print_misclassified_test_images

Using the included dataset and the params above, on a Core i5 @ 3.3Ghz + Nvidia GTX 970 using latest tensorflow-gpu, CUDA, cuDNN it took ~ 25 mins

I also attempted to use --random_crop 10 --random_scale 10 --random_brightness 10 --flip_left_right but training took way too long on my machine (30 mins for 30 steps).

Training & testing results

90% train, 10% test

INFO:tensorflow:Final test accuracy = 98.1% (N=424)
INFO:tensorflow:=== MISCLASSIFIED TEST IMAGES ===
INFO:tensorflow:                                            input\clipart\00000518.jpg  line
INFO:tensorflow:                                            input\clipart\00000518.jpg  line
INFO:tensorflow:                                               input\face\00000326.jpg  line
INFO:tensorflow:                                               input\face\00000326.jpg  line
INFO:tensorflow:                                               input\line\00000315.jpg  clipart
INFO:tensorflow:input\line\stock-vector-sea-life-wildlife-animal-white-shark-decal-art-vector-isolated-decor-tribal-tattoo-design-632947772.jpg  clipart
INFO:tensorflow:                                               input\line\00000315.jpg  clipart
INFO:tensorflow:input\line\stock-vector-sea-life-wildlife-animal-white-shark-decal-art-vector-isolated-decor-tribal-tattoo-design-632947772.jpg  clipart

gimagesearch-tensorflow-classifier's People

Contributors

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