"This demo will demostrate the steps to run deeplab semantic segmentation model on sample input images."
"This demo will demostrate the steps to use the DeepLab model to perform semantic segmentation on a sample input image. Expected outputs are semantic labels overlayed on the sample image.\n",
"\n",
"### What is DeepLab\n",
"Models used in this colab perform semantic segmentation. Semantic segmentation models focus on assigning semantic labels (e.g. sky, person, car) to multiple objects and stuff in a single image."
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "t3ozFsEEP-u_"
},
"source": [
"# Instructions\n",
"\u003ch3\u003e\u003ca href=\"https://cloud.google.com/tpu/\"\u003e\u003cimg valign=\"middle\" src=\"https://raw.githubusercontent.com/GoogleCloudPlatform/tensorflow-without-a-phd/master/tensorflow-rl-pong/images/tpu-hexagon.png\" width=\"50\"\u003e\u003c/a\u003e \u0026nbsp;\u0026nbsp;Use a free TPU device\u003c/h3\u003e\n",
"\n",
" 1. On the main menu, click Runtime and select **Change runtime type**. Set \"TPU\" as the hardware accelerator.\n",
" 1. Click Runtime again and select **Runtime \u003e Run All** (Watch out: the \"Colab-only auth for this notebook and the TPU\" cell requires user input). You can also run the cells manually with Shift-ENTER."
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "7cRiapZ1P3wy"
},
"source": [
"## Import Libraries"
]
]
},
},
{
{
...
@@ -17,19 +44,12 @@
...
@@ -17,19 +44,12 @@
"execution_count": 0,
"execution_count": 0,
"metadata": {
"metadata": {
"cellView": "code",
"cellView": "code",
"colab": {
"colab": {},
"autoexec": {
"startup": false,
"wait_interval": 0
}
},
"colab_type": "code",
"colab_type": "code",
"id": "kAbdmRmvq0Je"
"id": "kAbdmRmvq0Je"
},
},
"outputs": [],
"outputs": [],
"source": [
"source": [
"#@title Imports\n",
"\n",
"import os\n",
"import os\n",
"from io import BytesIO\n",
"from io import BytesIO\n",
"import tarfile\n",
"import tarfile\n",
...
@@ -44,25 +64,32 @@
...
@@ -44,25 +64,32 @@
"import tensorflow as tf"
"import tensorflow as tf"
]
]
},
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "p47cYGGOQE1W"
},
"source": [
"## Import helper methods\n",
"These methods will help us perform the following tasks:\n",
"* Load the latest version of the pretrained DeepLab model\n",
"* Load the colormap from the PASCAL VOC dataset\n",
"* Adds colors to various labels (For example, \"pink\" for people, \"green\" for bicycle and more)\n",
"* Visualize an image, and add an overlay of colors on various regions."
]
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 0,
"execution_count": 0,
"metadata": {
"metadata": {
"cellView": "code",
"cellView": "code",
"colab": {
"colab": {},
"autoexec": {
"startup": false,
"wait_interval": 0
}
},
"colab_type": "code",
"colab_type": "code",
"id": "vN0kU6NJ1Ye5"
"id": "vN0kU6NJ1Ye5"
},
},
"outputs": [],
"outputs": [],
"source": [
"source": [
"#@title Helper methods\n",
"\n",
"\n",
"class DeepLabModel(object):\n",
"class DeepLabModel(object):\n",
" \"\"\"Class to load deeplab model and run inference.\"\"\"\n",
" \"\"\"Class to load deeplab model and run inference.\"\"\"\n",
"* Learn about [Cloud TPUs](https://cloud.google.com/tpu/docs) that Google designed and optimized specifically to speed up and scale up ML workloads for training and inference and to enable ML engineers and researchers to iterate more quickly.\n",
"* Explore the range of [Cloud TPU tutorials and Colabs](https://cloud.google.com/tpu/docs/tutorials) to find other examples that can be used when implementing your ML project.\n",
"* [Here's](https://cloud.google.com/tpu/docs/tutorials/deeplab) a direct link to the DeepLab tutorial.\n"