DIGITS Tutorial : Example run of LeNet Model on MNIST

We would be using the DIGITS framework to train a LeNet Model on the famous Handwritten Numerical-digits Dataset MNIST. We assume that you have installed Caffe and DIGITS already, please follow the respective links to install them if you haven’t done that already. So let’s get started.

Start the Server

Start the digits server by executing the following. $DIGITS_HOME is the path where you installed Digits.

$> cd $DIGITS_HOME
$> ./digits-devserver

The first time DIGITS is run, you may be asked to provide some configuration options.

$> ./digits-devserver
  ___ ___ ___ ___ _____ ___
 |   \_ _/ __|_ _|_   _/ __|
 | |) | | (_ || |  | | \__ \
 |___/___\___|___| |_| |___/

DIGITS requires at least one DL backend to run.
==================================== Caffe =====================================
Where is caffe installed?

        Suggested values:
        (P*) [PATH/PYTHONPATH] <PATHS>
>> ~/caffe
Using "/home/username/caffe"
Saved config to /home/username/digits/digits/digits.cfg
 * Running on http://0.0.0.0:5000/

Most values are set silently by default. If you need more control over your configuration, try one of these commands:

# Set more options before starting the server
$> ./digits-devserver --config
# Advanced usage
$> python -m digits.config.edit --

Using the Webapp

When you fire up the digits server for the first time, you must see something like the below image on the url : 0.0.0.0:5000/ or http://localhost:5000

home-page-1

Create Database

To extract the MNIST dataset, DIGITS provides automated python scripts. Run the following from your <digits-home> folder.

$> python tools/download_data/main.py mnist ~/data/mnist

Now, in the browser application, in the Datasets section on the left side of the page, click on the blue Images button and select Classification which will take you to the “New Image Classification Dataset” page.

  • Change the image type to Grayscale
  • Change the image size to 28 x 28
  • Type in the path to the MNIST training images
    • /home/username/digits-1.0/mnist_10k if you are using the web installer
  • Give the dataset a name
  • Click on the Create button

While the model creation job is running, you should see the expected completion time on the right side of the new page that pops up. When the data set has completed training, go back to the home page, by clicking DIGITS in the top left hand part of the page. You should now see that there is a trained data set.

home-page-2

Training a Model

In the Models section on the left side of the page, click on the blue Images button and select Classification which will take you to the “New Image Classification Model” page. For this example, do the following:

  • Choose the MNIST dataset in the “Select Dataset” field
  • Choose the LeNet network in the “Standard Networks” tab
  • Give the model a name
  • Click on the Create button

While training the model, you should see the expected completion time on the right side. The page will also show you a near real-time ROC plot of the loss versus epoch (time-frame) and another graph will show the state of the learning rate of training.

training-model

Testing the Model

To test the model, scroll to the bottom of the page. On the left side are tools for testing the model.

  • Click on the Upload Image field which will bring up a local file browser and choose a file
    • If you’ve used the web installer, choose one in /home/username/digits-1.0/test_digits
  • Or, find an image on the web and paste the URL into the Image URL field
  • Click on Classify One Image

DIGITS will display the top five classifications and corresponding confidence values.

classified-one-image

Voilà!

We are done training and testing out Model! Stick around for more updates and feel free to comment in case of queries. I would highly recommend the digits-users and caffe-users google groups for general discussion and doubts solutions.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s