In this lab, you carry out a transfer learning example based on Inception-v3 image recognition neural network. The objective is to classify coastline images captured using drones based on their potential for flood damage. This lab is part of a series of labs on processing scientific data.

What you'll learn

Prerequisites

Transfer learning is a machine learning method which utilizes a pre-trained neural network. For example, the image recognition model called Inception-v3 consists of two parts:

The pre-trained Inception-v3 model achieves state-of-the-art accuracy for recognizing general objects with 1000 classes, like "Zebra", "Dalmatian", and "Dishwasher". The model extracts general features from input images in the first part and classifies them based on those features in the second part.

In transfer learning, when you build a new model to classify your original dataset, you reuse the feature extraction part and re-train the classification part with your dataset. Since you don't have to train the feature extraction part (which is the most complex part of the model), you can train the model with less computational resources and training time.

Step 1: Launch Cloud Datalab

To launch Cloud Datalab:

Step 1.1

Open Cloud Shell. The cloud shell icon is at the top right of the GCP web console:

Step 1.2

In Cloud Shell, type:

gcloud compute zones list

Pick a zone in a geographically closeby region.

Step 1.3

In Cloud Shell, type:

datalab create coastline --zone <ZONE>

Datalab will take about 5 minutes to start. Move on to the next step.

Step 2: Enable the Cloud Machine Learning API

Enable the Cloud Machine Learning API.

Step 3: Enable the Cloud Dataflow API

Enable the Cloud Dataflow API.

Step 4: Understand the objective

You have about 8,000 images that were captured from drones and classified into categories based on their potential to suffer flood damage. For example, the aerial image above depicts "scarps and steep slopes in clay". This diagram, from "The Landslide Handbook" by LM Highland, shows the underlying structure:

Can a machine learning model that is shown examples of such coastlines learn to classify new images? As you can see, the "scarp" in question is barely visible in the image -- instead, it has to be inferred.

Switch back to the Cloud Shell tab.

Step 1

If necessary, wait for Datalab to finish launching. Datalab is ready when you see a message prompting you to do a "Web Preview".

Step 2

Click on the Web Preview icon on the top-right corner of the Cloud Shell ribbon.

Step 3

In Datalab, click on the icon for "Open ungit" in the top-right ribbon.

Step 4

In the Ungit window, select the text that reads /content/datalab/notebooks and remove the notebooks so that it reads /content/datalab, then hit enter.

In the panel that comes up, type the following as the GitHub repository to Clone from:

https://github.com/GoogleCloudPlatform/training-data-analyst

Then, click on Clone repository.

Step 5

Switch back to the browser window where you have Cloud Datalab open and navigate to training-data-analyst/quests/scientific/coastline.ipynb

Step 1

Read the narrative and click Shift + Enter (or Run) on each cell in the notebook.

Step 1

Click on the person icon in the top-right corner of your Datalab window and click on the link to manage the VM.

Step 2

In the web console, select the Datalab VM and click DELETE.

Step 3

In the web console, navigate to the Storage section and delete the newly created bucket (its name is that of your project with -txf appended to it).

Step 4

In the web console, navigate to the BigQuery section and delete the newly created dataset called demos.