Code Monkey home page Code Monkey logo

deep-hive's Introduction

Deep Hive

Tap into the hive mind with your audience and train a deep convolutional neural network live on stage.

I use this during presentations to illustrate to the basic process of (supervised) machine learning and give the audience a feel of how much (or how little) data is needed for training.

For the Kaggle Dogs vs. Cats dataset you get about 90% accuracy in about 250 user annotations. With 25 people in your audience this typically takes less than one minute!

More information about the design and architecture can be found in this HackerNoon article on Medium:
Deep Hive: Deep learning live on stage

The application has two main parts:

Dashboard

This is the live dashboard displayed on the presentation screen

Dashboard screenshot

Annotation

Your audience will visit the annotation page to do some annotations

Annotation screenshot

Model

A pretty simple model is used:

  • VGG16 backbone
  • GlobalAveragePooling2D
  • Dense (256)
  • Dropout
  • Dense (size is number of classes)

Stack

  • Python (python 3 only)
  • Keras (tensorflow)
  • Flask
  • Redis
  • React.js
  • D3.js
  • Webpack

Usage

Preparing the Dogs vs Cats dataset

  1. Download the train.zip file from Kaggle Dogs vs. Cats dataset

  2. Unzip it in the data directory. It should create a train folder

  3. Preprocess the images using

    python preprocess.py data/train data/catsdogs
    

Custom datasets

You can use your own dataset. The model is a classifier so the application expects the folders in the data directory to have the names of the classes. Specify the data directory with IMAGE_PATH in the Config.py file,

The application needs the images to be in a fixed size (default is 128x128). You can use the preprocess.ipynb notebook to rescale the images to the preferred size.

Custom url

To change the url displayed for the audience on the dashboard edit the short_url parameter in src/config.json file and recompile the frontend (see Frontend section).

Docker

The easiest way to run this application is via docker.

You can start all needed containers locally by running:

docker-compose up

When docker is running, the dashboard can be found at:
http://localhost:5000/dashboard

And the annotation interface at:
http://localhost:5000/

Standalone

To run it directly on your local machine, create and activate conda environment first

conda env create -f environment.yml
source activate deephive

Start the flask application

cd server
./start.sh

Start the worker containing the model

python worker.py

You will also need a Redis instance running.

Frontend

To recompile the javascript first install the npm packages:

npm install

For convenience, a bundle.js file has been committed in the repo. Run webpack to re-compile:

npm run build

To start a development server (proxies /api requests to flask):

npm run start

deep-hive's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

deep-hive's Issues

Feedback

Looks very accessible. Just a few pointers that you may or may not agree with:

I think it would be good if you declare that this is Python 3 only. Many people still work with a Python 2 installation.

Having the config files in the root would also help to find them. For most projects such files exist in root and if they are not there I expect I have to make them myself.

In the preprocessor your code assumes a file format. Would be good not to silently skip files from a different format, but to raise errors. Otherwise it may look mysterious to developers trying to get it to work.

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.