IBM/powerai-transfer-learning

Name: powerai-transfer-learning

Owner: International Business Machines

Description: Image recognition training with TensorFlow Inception and transfer learning

Created: 2017-07-06 20:27:20.0

Updated: 2018-05-23 10:59:16.0

Pushed: 2017-12-01 17:28:09.0

Homepage: https://developer.ibm.com/code/patterns/image-recognition-training-powerai-notebooks/

Size: 24130

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Image recognition training with TensorFlow Inception and transfer learning

Read this in other languages: ???.

Transfer learning is the process of taking a pre-trained model (the weights and parameters of a network that has been trained on a large dataset by somebody else) and ?fine-tuning? the model with your own dataset. The idea is that this pre-trained model will act as a feature extractor. You will remove the last layer of the network and replace it with your own classifier (depending on what your problem space is). You then freeze the weights of all the other layers and train the network normally (Freezing the layers means not changing the weights during gradient descent/optimization). For this experiment we used Google's Inception-V3 pretrained model for Image Classification. This model consists of two parts:

The pre-trained Inception-v3 model achieves state-of-the-art accuracy for recognizing general objects with 1000 classes. The model extracts general features from input images in the first part and classifies them based on those features in the second part. We will use this pre-trained model and re-train it it to classify houses with or without swimming pools.

Flow
  1. The developer loads the provided notebook, which is run on a PowerAI system.
  2. A provided example dataset demonstrates a use case of recognizing images of houses with pools vs. houses without pools.
  3. The notebook uses the TensorFlow Inception model and retraining example to leverage the existing model and build a custom classifier.
  4. The notebook compares results using the original model and the new model.
Included components
Featured technologies

Watch the Video

Steps

Follow these steps to setup and run this Code Pattern. The steps are described in detail below.

  1. Get 24-hours of free access to the PowerAI platform
  2. Access and start the Jupyter notebook
  3. Run the notebook
  4. Analyze the results
  5. Save and share
  6. End your trial
1. Get 24-hours of free access to the PowerAI platform

IBM has partnered with Nimbix to provide cognitive developers a trial account that provides 24-hours of free processing time on the PowerAI platform. Follow these steps to register for access to Nimbix to try the PowerAI Cognitive Code Patterns and explore the platform.

Go to the IBM Marketplace PowerAI Portal, and click Request Trial.

On the IBM PowerAI Trial page, shown below, enter the required information to sign up for an IBM account and click Continue. If you already have an IBM ID, click Already have an account? Log in, enter your credentials and click Continue.

On the Almost there? page, shown below, enter the required information and click Continue to complete the registration and launch the IBM Marketplace Products and Services page.

Your IBM Marketplace Products and Services page displays all offerings that are available to you; the PowerAI Trial should now be one of them. From the PowerAI Trial section, click Launch, as shown below, to launch the IBM PowerAI trial page.

The Welcome to IBM PowerAI Trial page provides instructions for accessing the trial, as shown below. Alternatively, you will receive an email confirming your registration with similar instructions that you can follow to start the trial.

Summary of steps for starting the trial:

2. Access and start the Jupyter notebook

Use git clone to download the example notebook, dataset, and retraining library with a single command.

clone https://github.com/IBM/powerai-transfer-learning

3. Run the notebook

When a notebook is executed, what is actually happening is that each code cell in the notebook is executed, in order, from top to bottom.

Each code cell is selectable and is preceded by a tag in the left margin. The tag format is In [x]:. Depending on the state of the notebook, the x can be:

There are several ways to execute the code cells in your notebook:

4. Analyze the results

When you run the “Main” code cell you can watch the training as the accuracy quickly improves. At the end, the final test accuracy is shown. We usually see somewhere around 85% accuracy with these images.

We captured the model before and after the training. Look at our example images at the bottom of the notebook and see our before and after results.

The results should go from no recognition ability at all to a pretty good success rate. You might find it interesting to try different images and see if you can identify why it has more difficulty classifying some images.

5. Save and share
How to save your work:

Because this notebook is running temporarily on a Nimbix Cloud server, use the following options to save your work:

Under the File menu, there are options to:

6. End your trial

When you are done with your work, please cancel your subscription by issuing the following command in your ssh session or by visiting the Manage link on the My Products and Services page.

 poweroff --force

Troubleshooting

See DEBUGGING.md.

Links

Learn more

License

Apache 2.0


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.