Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 50235da

Browse files
committed
update for kaggle api
1 parent 80c0ce5 commit 50235da

File tree

1 file changed

+53
-2
lines changed

1 file changed

+53
-2
lines changed

samples/outreach/blogs/segmentation_blogpost/5_Image_Segmentation.ipynb

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Finding visual objects in images - Image Segmentation with tf.keras "
8+
]
9+
},
10+
{
11+
"cell_type": "markdown",
12+
"metadata": {},
13+
"source": [
14+
"<table class=\"tfo-notebook-buttons\" align=\"left\"><td>\n",
15+
"<a target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/tensorflow/blob/master/tensorflow/contrib/eager/python/examples/generative_examples/image_captioning_with_attention.ipynb\">\n",
16+
" <img src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" />Run in Google Colab</a> \n",
17+
"</td><td>\n",
18+
"<a target=\"_blank\" href=\"https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/eager/python/examples/generative_examples/image_captioning_with_attention.ipynb\"><img width=32px src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" />View source on GitHub</a></td></table>"
19+
]
20+
},
321
{
422
"cell_type": "markdown",
523
"metadata": {
624
"colab_type": "text",
725
"id": "cl79rk4KKol8"
826
},
927
"source": [
10-
"# Finding visual objects in images - Image Segmentation with tf.keras \n",
1128
"In this tutorial we will learn how to segment images. **Segmentation** is the process of generating pixel-wise segmentations giving the class of the object visible at each pixel. For example, we could be identifying the location and boundaries of people within an image or identifying cell nuclei from an image. Formally, image segmentation refers to the process of partitioning an image into a set of pixels that we desire to identify (our target) and the background. \n",
1229
"\n",
1330
"Specifically, in this tutorial we will be using the [Kaggle Carvana Image Masking Challenge Dataset](https://www.kaggle.com/c/carvana-image-masking-challenge). \n",
@@ -93,7 +110,41 @@
93110
"id": "RW9gk331S0KA"
94111
},
95112
"source": [
96-
"# Get all the files "
113+
"# Get all the files \n",
114+
"Since this tutorial will be using a dataset from Kaggle, it requires [creating an API Token](https://github.com/Kaggle/kaggle-api) for your Kaggle acccount, and uploading it. "
115+
]
116+
},
117+
{
118+
"cell_type": "code",
119+
"execution_count": null,
120+
"metadata": {},
121+
"outputs": [],
122+
"source": [
123+
"import os\n",
124+
"\n",
125+
"# Upload the API token.\n",
126+
"def get_kaggle_credentials():\n",
127+
" token_dir = os.path.join(os.path.expanduser(\"~\"),\".kaggle\")\n",
128+
" token_file = os.path.join(token_dir, \"kaggle.json\")\n",
129+
" if not os.path.isdir(token_dir):\n",
130+
" os.mkdir(token_dir)\n",
131+
" try:\n",
132+
" with open(token_file,'r') as f:\n",
133+
" pass\n",
134+
" except IOError as no_file:\n",
135+
" try:\n",
136+
" from google.colab import files\n",
137+
" except ImportError:\n",
138+
" raise no_file\n",
139+
" \n",
140+
" uploaded = files.upload()\n",
141+
" with open(token_file, \"w\") as f:\n",
142+
" f.write(uploaded[\"kaggle.json\"])\n",
143+
" os.chmod(token_file, 600)\n",
144+
"\n",
145+
"get_kaggle_credentials()\n",
146+
"# Note: Only import kaggle after adding the credentials.\n",
147+
"import kaggle"
97148
]
98149
},
99150
{

0 commit comments

Comments
 (0)