Skip to content

Commit 2e4fba3

Browse files
author
Matt Sokoloff
committed
updating guide small export changes
1 parent 7bb4c40 commit 2e4fba3

File tree

6 files changed

+532
-830
lines changed

6 files changed

+532
-830
lines changed

examples/model_assisted_labeling/Model_Diagnostics_Demo.ipynb

Lines changed: 55 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "acute-fluid",
5+
"id": "afraid-timing",
66
"metadata": {
77
"id": "EyNkbpW7ouEf"
88
},
99
"source": [
1010
" \n",
1111
"<td>\n",
12-
" <a target=\"_blank\" href=\"https://labelbox.com\" ><img src=\"https://labelbox.com/blog/content/images/2021/02/logo-v4.svg\" width=256/>\n",
13-
"</td>\n",
14-
"\n",
12+
" <a target=\"_blank\" href=\"https://labelbox.com\" ><img src=\"https://labelbox.com/blog/content/images/2021/02/logo-v4.svg\" width=256/></a>\n",
13+
"</td>"
14+
]
15+
},
16+
{
17+
"cell_type": "markdown",
18+
"id": "foster-injection",
19+
"metadata": {},
20+
"source": [
1521
"----\n",
1622
"\n",
1723
"# Model Diagnostics\n",
@@ -34,7 +40,7 @@
3440
"## Steps\n",
3541
"\n",
3642
"1. Have a set of ground truth labels in a project\n",
37-
"2. Install beta release of the SDK (SDK versions that are compatible with Model Diagnostics will have a \"b\" in the version name. The first SDK release to support this is 2.5b0.)\n",
43+
"2. Install the latest SDK release (At this time that is 3.0.0rc0)\n",
3844
"3. Create a `Model`\n",
3945
"4. Create a `Model Run`\n",
4046
"5. Compute predictions\n",
@@ -67,8 +73,9 @@
6773
},
6874
"outputs": [],
6975
"source": [
70-
"!pip3 install \"labelbox[data]==3.0.0rc0\" \\\n",
71-
" tensorflow"
76+
"!pip install \"labelbox[data]==3.0.0rc1\" \\\n",
77+
" scikit-image \\\n",
78+
" tensorflow"
7279
]
7380
},
7481
{
@@ -85,9 +92,8 @@
8592
"\n",
8693
"if COLAB:\n",
8794
" !git clone https://github.com/Labelbox/labelbox-python.git\n",
88-
" !cd labelbox-python && git checkout mea-dev\n",
89-
" !mv labelbox-python/examples/model_assisted_labeling/*.py .\n",
90-
" !mv labelbox-python/examples/model_assisted_labeling/mapillary_sample.csv ."
95+
" !cd labelbox-python\n",
96+
" !mv labelbox-python/examples/model_assisted_labeling/*.py ."
9197
]
9298
},
9399
{
@@ -109,40 +115,36 @@
109115
},
110116
"outputs": [],
111117
"source": [
112-
"from io import BytesIO\n",
113-
"from getpass import getpass\n",
114118
"import uuid\n",
115119
"import numpy as np\n",
116-
"from PIL import Image\n",
120+
"from skimage import measure\n",
117121
"import requests\n",
118122
"from tqdm import notebook\n",
119-
"from collections import defaultdict\n",
120-
"import ndjson\n",
123+
"import requests\n",
124+
"import csv\n",
121125
"import os\n",
122126
"\n",
123127
"from labelbox.schema.ontology import OntologyBuilder, Tool\n",
124-
"from labelbox import Client, LabelingFrontend, MALPredictionImport, DataRow\n",
125-
"from labelbox.data.metrics.iou import data_row_miou\n",
126-
"\n",
128+
"from labelbox import Client, LabelingFrontend, MALPredictionImport\n",
127129
"from labelbox.data.metrics.iou import data_row_miou\n",
128130
"from labelbox.data.serialization import NDJsonConverter\n",
129-
"from labelbox.data.annotation_types import ScalarMetric, LabelList, Label, RasterData, Mask, Point, Rectangle, ObjectAnnotation\n",
130-
"\n",
131-
"\n",
131+
"from labelbox.data.annotation_types import (\n",
132+
" ScalarMetric, \n",
133+
" LabelList, \n",
134+
" Label, \n",
135+
" RasterData, \n",
136+
" Mask, \n",
137+
" Point, \n",
138+
" Rectangle, \n",
139+
" ObjectAnnotation\n",
140+
")\n",
132141
"\n",
133142
"try:\n",
134143
" from image_model import predict, load_model, class_mappings\n",
135-
" from ndjson_utils import (\n",
136-
" create_boxes_ndjson, \n",
137-
" create_polygon_ndjson, \n",
138-
" create_mask_ndjson, \n",
139-
" create_point_ndjson\n",
140-
" )\n",
141144
"except ModuleNotFoundError: \n",
142145
" # !git clone https://github.com/Labelbox/labelbox-python.git\n",
143146
" # !cd labelbox-python && git checkout mea-dev\n",
144147
" # !mv labelbox-python/examples/model_assisted_labeling/*.py .\n",
145-
" # !mv labelbox-python/examples/model_assisted_labeling/mapillary_sample.csv .\n",
146148
" raise Exception(\"You will need to run from the labelbox-python git repo\")"
147149
]
148150
},
@@ -180,7 +182,6 @@
180182
},
181183
"outputs": [],
182184
"source": [
183-
"API_KEY = \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJja2s0cTF2Z3djMHZwMDcwNHhoeDdtNHZrIiwib3JnYW5pemF0aW9uSWQiOiJja2s0cTF2Z2Fwc2F1MDczMjRhd25zanEyIiwiYXBpS2V5SWQiOiJja3J3bWNmZXQwa2N6MHkyYzh4Z3E1NHhoIiwic2VjcmV0IjoiZGM0ZTEwM2E1ZTQ2YzRiOGFkZWU2ZmMxMGM2ZTAwMTkiLCJpYXQiOjE2MjgwMjg4NTQsImV4cCI6MjI1OTE4MDg1NH0.-zl_aqbd0IoCRsKFHps0HzNhGOUFaVt6bb24AUVj28k\"\n",
184185
"client = Client(api_key=API_KEY)\n",
185186
"load_model() # initialize Tensorflow Model"
186187
]
@@ -224,14 +225,23 @@
224225
{
225226
"cell_type": "code",
226227
"execution_count": null,
227-
"id": "existing-generic",
228+
"id": "spoken-watson",
228229
"metadata": {},
229230
"outputs": [],
230231
"source": [
231232
"# --- setup dataset ---\n",
232233
"# load mapillary sample\n",
233-
"with open('mapillary_sample.csv', 'r') as file:\n",
234-
" urls = [row[:-1].split(\",\") for row in file.readlines()][:10]"
234+
"sample_csv_url = \"https://raw.githubusercontent.com/Labelbox/labelbox-python/develop/examples/model_assisted_labeling/mapillary_sample.csv\"\n",
235+
"with requests.get(sample_csv_url, stream=True) as r:\n",
236+
" image_data = [row.split(',') for row in (line.decode('utf-8') for line in r.iter_lines())]"
237+
]
238+
},
239+
{
240+
"cell_type": "markdown",
241+
"id": "packed-madison",
242+
"metadata": {},
243+
"source": [
244+
"* Set up this prediction look to construct Annotation Types"
235245
]
236246
},
237247
{
@@ -244,7 +254,7 @@
244254
"outputs": [],
245255
"source": [
246256
"predictions = LabelList([])\n",
247-
"for (image_url, external_id) in notebook.tqdm(urls):\n",
257+
"for (image_url, external_id) in notebook.tqdm(image_data):\n",
248258
" image = RasterData(url = image_url, external_id = external_id)\n",
249259
" height, width = image.data.shape[:2]\n",
250260
" prediction = predict(np.array([image.im_bytes]), min_score=0.5, height=height, width = width)\n",
@@ -271,7 +281,7 @@
271281
},
272282
{
273283
"cell_type": "markdown",
274-
"id": "endless-expert",
284+
"id": "smooth-irrigation",
275285
"metadata": {},
276286
"source": [
277287
"## Setup a project\n",
@@ -281,7 +291,7 @@
281291
{
282292
"cell_type": "code",
283293
"execution_count": null,
284-
"id": "married-candy",
294+
"id": "available-endorsement",
285295
"metadata": {},
286296
"outputs": [],
287297
"source": [
@@ -299,7 +309,7 @@
299309
{
300310
"cell_type": "code",
301311
"execution_count": null,
302-
"id": "specified-directive",
312+
"id": "fresh-vertex",
303313
"metadata": {},
304314
"outputs": [],
305315
"source": [
@@ -503,7 +513,15 @@
503513
{
504514
"cell_type": "code",
505515
"execution_count": null,
506-
"id": "premier-arkansas",
516+
"id": "variable-consumption",
517+
"metadata": {},
518+
"outputs": [],
519+
"source": []
520+
},
521+
{
522+
"cell_type": "code",
523+
"execution_count": null,
524+
"id": "dense-malawi",
507525
"metadata": {},
508526
"outputs": [],
509527
"source": []

0 commit comments

Comments
 (0)