Skip to content

Commit 4344d8e

Browse files
authored
Merge pull request #195 from Labelbox/ms/notebook-update
update notebooks
2 parents 0a3d5ad + 6cb0f6f commit 4344d8e

File tree

2 files changed

+159
-107
lines changed

2 files changed

+159
-107
lines changed

examples/basics/ontologies.ipynb

Lines changed: 110 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
{
1818
"cell_type": "code",
19-
"execution_count": 1,
19+
"execution_count": null,
2020
"id": "continuous-syndrome",
2121
"metadata": {},
2222
"outputs": [],
@@ -26,20 +26,21 @@
2626
},
2727
{
2828
"cell_type": "code",
29-
"execution_count": 2,
29+
"execution_count": 1,
3030
"id": "passing-question",
3131
"metadata": {},
3232
"outputs": [],
3333
"source": [
3434
"from labelbox.schema.ontology import OntologyBuilder, Tool, Classification, Option\n",
3535
"from labelbox import Client\n",
3636
"from getpass import getpass\n",
37+
"import json\n",
3738
"import os"
3839
]
3940
},
4041
{
4142
"cell_type": "code",
42-
"execution_count": 3,
43+
"execution_count": 2,
4344
"id": "interested-bishop",
4445
"metadata": {},
4546
"outputs": [],
@@ -70,21 +71,21 @@
7071
},
7172
{
7273
"cell_type": "code",
73-
"execution_count": 4,
74+
"execution_count": 3,
7475
"id": "baking-recipient",
7576
"metadata": {},
7677
"outputs": [],
7778
"source": [
7879
"# Make sure this project has been fully setup (see project examples/project_configuration/project_setup.ipynb)\n",
7980
"# You also can just setup a project in the web ui\n",
80-
"PROJECT_ID = \"ckm4xyfncfgja0760vpfdxoro\"\n",
81+
"PROJECT_ID = \"ckr083gl1dr8j0yag4jo5cnnt\"\n",
8182
"# Only update this if you have an on-prem deployment\n",
8283
"ENDPOINT = \"https://api.labelbox.com/graphql\""
8384
]
8485
},
8586
{
8687
"cell_type": "code",
87-
"execution_count": 5,
88+
"execution_count": 4,
8889
"id": "oriental-columbus",
8990
"metadata": {},
9091
"outputs": [],
@@ -103,7 +104,7 @@
103104
},
104105
{
105106
"cell_type": "code",
106-
"execution_count": 6,
107+
"execution_count": 5,
107108
"id": "refined-welsh",
108109
"metadata": {},
109110
"outputs": [
@@ -144,12 +145,12 @@
144145
"])\n",
145146
"# Note that color is selected automatically\n",
146147
"# The ids will be assigned when this ontology is created in labelbox\n",
147-
"print(ontology_builder)"
148+
"print(json.dumps(ontology_builder.asdict(), indent = 2))"
148149
]
149150
},
150151
{
151152
"cell_type": "code",
152-
"execution_count": 7,
153+
"execution_count": 6,
153154
"id": "faced-genome",
154155
"metadata": {},
155156
"outputs": [
@@ -191,12 +192,12 @@
191192
"ontology_builder.add_tool(tool_dog)\n",
192193
"ontology_builder.add_tool(tool_cat)\n",
193194
"# Exactly the same as the using the init\n",
194-
"print(ontology_builder)"
195+
"print(json.dumps(ontology_builder.asdict(), indent = 2))"
195196
]
196197
},
197198
{
198199
"cell_type": "code",
199-
"execution_count": 8,
200+
"execution_count": 7,
200201
"id": "crazy-aside",
201202
"metadata": {},
202203
"outputs": [
@@ -283,12 +284,12 @@
283284
" options=[Option(value=\"clear\"),\n",
284285
" Option(value=\"blurry\")])\n",
285286
" ])\n",
286-
"print(ontology_builder)"
287+
"print(json.dumps(ontology_builder.asdict(), indent = 2))"
287288
]
288289
},
289290
{
290291
"cell_type": "code",
291-
"execution_count": 9,
292+
"execution_count": 8,
292293
"id": "pacific-combining",
293294
"metadata": {},
294295
"outputs": [],
@@ -305,7 +306,7 @@
305306
},
306307
{
307308
"cell_type": "code",
308-
"execution_count": 10,
309+
"execution_count": 9,
309310
"id": "involved-effects",
310311
"metadata": {},
311312
"outputs": [],
@@ -339,7 +340,7 @@
339340
},
340341
{
341342
"cell_type": "code",
342-
"execution_count": 11,
343+
"execution_count": 10,
343344
"id": "brazilian-royalty",
344345
"metadata": {},
345346
"outputs": [],
@@ -351,53 +352,125 @@
351352
},
352353
{
353354
"cell_type": "code",
354-
"execution_count": 12,
355+
"execution_count": 11,
355356
"id": "collaborative-stephen",
356357
"metadata": {},
357358
"outputs": [
358359
{
359-
"data": {
360-
"text/plain": [
361-
"OntologyBuilder(tools=[Tool(tool=<Type.BBOX: 'rectangle'>, name='animal', required=False, color='#1CE6FF', classifications=[], schema_id='ckm3se1a5010x0y6r3hpsb0wc', feature_schema_id='ckm3se1a5010y0y6rcdc0bvvl'), Tool(tool=<Type.BBOX: 'rectangle'>, name='human', required=False, color='#FF34FF', classifications=[], schema_id='ckmbdol5s1ybj0y969w8z6fcs', feature_schema_id='ckmbdol5s1ybk0y96fje86ktu')], classifications=[Classification(class_type=<Type.CHECKLIST: 'checklist'>, instructions='image', required=False, options=[Option(value='difficult', schema_id='ckm3se1aw010z0y6rdgaof1fu', feature_schema_id='ckm3se1aw01100y6rf8b59u51', options=[]), Option(value='contains_human', schema_id='ckm3se1aw01110y6rfx3benbx', feature_schema_id='ckm3se1aw01120y6r7zkcd93v', options=[])], schema_id='ckm3se1a4010v0y6rfe3b9s8t', feature_schema_id='ckm3se1a4010w0y6rd579gyl3')])"
362-
]
363-
},
364-
"execution_count": 27,
365-
"metadata": {},
366-
"output_type": "execute_result"
360+
"name": "stdout",
361+
"output_type": "stream",
362+
"text": [
363+
"{\n",
364+
" \"tools\": [\n",
365+
" {\n",
366+
" \"tool\": \"rectangle\",\n",
367+
" \"name\": \"person\",\n",
368+
" \"required\": false,\n",
369+
" \"color\": \"#ff0000\",\n",
370+
" \"classifications\": [\n",
371+
" {\n",
372+
" \"type\": \"radio\",\n",
373+
" \"instructions\": \"has_handbag\",\n",
374+
" \"name\": \"has_handbag\",\n",
375+
" \"required\": false,\n",
376+
" \"options\": [\n",
377+
" {\n",
378+
" \"schemaNodeId\": \"ckr083u8g8ien0yar9pc10mlf\",\n",
379+
" \"featureSchemaId\": \"ckr083u8g8ieo0yargphlg4dq\",\n",
380+
" \"label\": \"True\",\n",
381+
" \"value\": \"True\",\n",
382+
" \"options\": []\n",
383+
" },\n",
384+
" {\n",
385+
" \"schemaNodeId\": \"ckr083u8h8iep0yar0s1x5syr\",\n",
386+
" \"featureSchemaId\": \"ckr083u8h8ieq0yar9gtddq0k\",\n",
387+
" \"label\": \"False\",\n",
388+
" \"value\": \"False\",\n",
389+
" \"options\": []\n",
390+
" }\n",
391+
" ],\n",
392+
" \"schemaNodeId\": \"ckr083sxf8iei0yar9y0radk3\",\n",
393+
" \"featureSchemaId\": \"ckr083sxf8iej0yardcg05ffq\"\n",
394+
" }\n",
395+
" ],\n",
396+
" \"schemaNodeId\": \"ckr083qt78ie60yar9rsh40p1\",\n",
397+
" \"featureSchemaId\": \"ckr083qt78ie70yar0goy4trr\"\n",
398+
" }\n",
399+
" ],\n",
400+
" \"classifications\": []\n",
401+
"}\n"
402+
]
367403
}
368404
],
369405
"source": [
370406
"# This ontology is an object that represents an ontology that exists in labelbox\n",
371407
"# (unlike the ontology builder that only exists in your local python version)\n",
372408
"# To construct a local ontology from a ontology db object you can do:\n",
373-
"OntologyBuilder.from_dict(ontology.normalized)"
409+
"ontology_builder = OntologyBuilder.from_dict(ontology.normalized)\n",
410+
"print(json.dumps(ontology_builder.asdict(), indent = 2))"
374411
]
375412
},
376413
{
377414
"cell_type": "code",
378-
"execution_count": 13,
415+
"execution_count": 12,
379416
"id": "promotional-treasury",
380417
"metadata": {},
381418
"outputs": [
382419
{
383-
"data": {
384-
"text/plain": [
385-
"OntologyBuilder(tools=[Tool(tool=<Type.BBOX: 'rectangle'>, name='animal', required=False, color='#1CE6FF', classifications=[], schema_id='ckm3se1a5010x0y6r3hpsb0wc', feature_schema_id='ckm3se1a5010y0y6rcdc0bvvl'), Tool(tool=<Type.BBOX: 'rectangle'>, name='human', required=False, color='#FF34FF', classifications=[], schema_id='ckmbdol5s1ybj0y969w8z6fcs', feature_schema_id='ckmbdol5s1ybk0y96fje86ktu')], classifications=[Classification(class_type=<Type.CHECKLIST: 'checklist'>, instructions='image', required=False, options=[Option(value='difficult', schema_id='ckm3se1aw010z0y6rdgaof1fu', feature_schema_id='ckm3se1aw01100y6rf8b59u51', options=[]), Option(value='contains_human', schema_id='ckm3se1aw01110y6rfx3benbx', feature_schema_id='ckm3se1aw01120y6r7zkcd93v', options=[])], schema_id='ckm3se1a4010v0y6rfe3b9s8t', feature_schema_id='ckm3se1a4010w0y6rd579gyl3')])"
386-
]
387-
},
388-
"execution_count": 28,
389-
"metadata": {},
390-
"output_type": "execute_result"
420+
"name": "stdout",
421+
"output_type": "stream",
422+
"text": [
423+
"{\n",
424+
" \"tools\": [\n",
425+
" {\n",
426+
" \"tool\": \"rectangle\",\n",
427+
" \"name\": \"person\",\n",
428+
" \"required\": false,\n",
429+
" \"color\": \"#ff0000\",\n",
430+
" \"classifications\": [\n",
431+
" {\n",
432+
" \"type\": \"radio\",\n",
433+
" \"instructions\": \"has_handbag\",\n",
434+
" \"name\": \"has_handbag\",\n",
435+
" \"required\": false,\n",
436+
" \"options\": [\n",
437+
" {\n",
438+
" \"schemaNodeId\": \"ckr083u8g8ien0yar9pc10mlf\",\n",
439+
" \"featureSchemaId\": \"ckr083u8g8ieo0yargphlg4dq\",\n",
440+
" \"label\": \"True\",\n",
441+
" \"value\": \"True\",\n",
442+
" \"options\": []\n",
443+
" },\n",
444+
" {\n",
445+
" \"schemaNodeId\": \"ckr083u8h8iep0yar0s1x5syr\",\n",
446+
" \"featureSchemaId\": \"ckr083u8h8ieq0yar9gtddq0k\",\n",
447+
" \"label\": \"False\",\n",
448+
" \"value\": \"False\",\n",
449+
" \"options\": []\n",
450+
" }\n",
451+
" ],\n",
452+
" \"schemaNodeId\": \"ckr083sxf8iei0yar9y0radk3\",\n",
453+
" \"featureSchemaId\": \"ckr083sxf8iej0yardcg05ffq\"\n",
454+
" }\n",
455+
" ],\n",
456+
" \"schemaNodeId\": \"ckr083qt78ie60yar9rsh40p1\",\n",
457+
" \"featureSchemaId\": \"ckr083qt78ie70yar0goy4trr\"\n",
458+
" }\n",
459+
" ],\n",
460+
" \"classifications\": []\n",
461+
"}\n"
462+
]
391463
}
392464
],
393465
"source": [
394466
"# You can even do\n",
395-
"OntologyBuilder.from_project(project)"
467+
"ontology_builder = OntologyBuilder.from_project(project)\n",
468+
"print(json.dumps(ontology_builder.asdict(), indent = 2))"
396469
]
397470
},
398471
{
399472
"cell_type": "code",
400-
"execution_count": 14,
473+
"execution_count": 13,
401474
"id": "boring-hearing",
402475
"metadata": {},
403476
"outputs": [],
@@ -419,19 +492,11 @@
419492
},
420493
{
421494
"cell_type": "code",
422-
"execution_count": 15,
495+
"execution_count": null,
423496
"id": "beautiful-column",
424497
"metadata": {},
425498
"outputs": [],
426499
"source": []
427-
},
428-
{
429-
"cell_type": "code",
430-
"execution_count": 16,
431-
"id": "earlier-faith",
432-
"metadata": {},
433-
"outputs": [],
434-
"source": []
435500
}
436501
],
437502
"metadata": {

examples/label_export/video.ipynb

Lines changed: 49 additions & 62 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)