|
16 | 16 | },
|
17 | 17 | {
|
18 | 18 | "cell_type": "code",
|
19 |
| - "execution_count": 1, |
| 19 | + "execution_count": null, |
20 | 20 | "id": "continuous-syndrome",
|
21 | 21 | "metadata": {},
|
22 | 22 | "outputs": [],
|
|
26 | 26 | },
|
27 | 27 | {
|
28 | 28 | "cell_type": "code",
|
29 |
| - "execution_count": 2, |
| 29 | + "execution_count": 1, |
30 | 30 | "id": "passing-question",
|
31 | 31 | "metadata": {},
|
32 | 32 | "outputs": [],
|
33 | 33 | "source": [
|
34 | 34 | "from labelbox.schema.ontology import OntologyBuilder, Tool, Classification, Option\n",
|
35 | 35 | "from labelbox import Client\n",
|
36 | 36 | "from getpass import getpass\n",
|
| 37 | + "import json\n", |
37 | 38 | "import os"
|
38 | 39 | ]
|
39 | 40 | },
|
40 | 41 | {
|
41 | 42 | "cell_type": "code",
|
42 |
| - "execution_count": 3, |
| 43 | + "execution_count": 2, |
43 | 44 | "id": "interested-bishop",
|
44 | 45 | "metadata": {},
|
45 | 46 | "outputs": [],
|
|
70 | 71 | },
|
71 | 72 | {
|
72 | 73 | "cell_type": "code",
|
73 |
| - "execution_count": 4, |
| 74 | + "execution_count": 3, |
74 | 75 | "id": "baking-recipient",
|
75 | 76 | "metadata": {},
|
76 | 77 | "outputs": [],
|
77 | 78 | "source": [
|
78 | 79 | "# Make sure this project has been fully setup (see project examples/project_configuration/project_setup.ipynb)\n",
|
79 | 80 | "# You also can just setup a project in the web ui\n",
|
80 |
| - "PROJECT_ID = \"ckm4xyfncfgja0760vpfdxoro\"\n", |
| 81 | + "PROJECT_ID = \"ckr083gl1dr8j0yag4jo5cnnt\"\n", |
81 | 82 | "# Only update this if you have an on-prem deployment\n",
|
82 | 83 | "ENDPOINT = \"https://api.labelbox.com/graphql\""
|
83 | 84 | ]
|
84 | 85 | },
|
85 | 86 | {
|
86 | 87 | "cell_type": "code",
|
87 |
| - "execution_count": 5, |
| 88 | + "execution_count": 4, |
88 | 89 | "id": "oriental-columbus",
|
89 | 90 | "metadata": {},
|
90 | 91 | "outputs": [],
|
|
103 | 104 | },
|
104 | 105 | {
|
105 | 106 | "cell_type": "code",
|
106 |
| - "execution_count": 6, |
| 107 | + "execution_count": 5, |
107 | 108 | "id": "refined-welsh",
|
108 | 109 | "metadata": {},
|
109 | 110 | "outputs": [
|
|
144 | 145 | "])\n",
|
145 | 146 | "# Note that color is selected automatically\n",
|
146 | 147 | "# 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))" |
148 | 149 | ]
|
149 | 150 | },
|
150 | 151 | {
|
151 | 152 | "cell_type": "code",
|
152 |
| - "execution_count": 7, |
| 153 | + "execution_count": 6, |
153 | 154 | "id": "faced-genome",
|
154 | 155 | "metadata": {},
|
155 | 156 | "outputs": [
|
|
191 | 192 | "ontology_builder.add_tool(tool_dog)\n",
|
192 | 193 | "ontology_builder.add_tool(tool_cat)\n",
|
193 | 194 | "# Exactly the same as the using the init\n",
|
194 |
| - "print(ontology_builder)" |
| 195 | + "print(json.dumps(ontology_builder.asdict(), indent = 2))" |
195 | 196 | ]
|
196 | 197 | },
|
197 | 198 | {
|
198 | 199 | "cell_type": "code",
|
199 |
| - "execution_count": 8, |
| 200 | + "execution_count": 7, |
200 | 201 | "id": "crazy-aside",
|
201 | 202 | "metadata": {},
|
202 | 203 | "outputs": [
|
|
283 | 284 | " options=[Option(value=\"clear\"),\n",
|
284 | 285 | " Option(value=\"blurry\")])\n",
|
285 | 286 | " ])\n",
|
286 |
| - "print(ontology_builder)" |
| 287 | + "print(json.dumps(ontology_builder.asdict(), indent = 2))" |
287 | 288 | ]
|
288 | 289 | },
|
289 | 290 | {
|
290 | 291 | "cell_type": "code",
|
291 |
| - "execution_count": 9, |
| 292 | + "execution_count": 8, |
292 | 293 | "id": "pacific-combining",
|
293 | 294 | "metadata": {},
|
294 | 295 | "outputs": [],
|
|
305 | 306 | },
|
306 | 307 | {
|
307 | 308 | "cell_type": "code",
|
308 |
| - "execution_count": 10, |
| 309 | + "execution_count": 9, |
309 | 310 | "id": "involved-effects",
|
310 | 311 | "metadata": {},
|
311 | 312 | "outputs": [],
|
|
339 | 340 | },
|
340 | 341 | {
|
341 | 342 | "cell_type": "code",
|
342 |
| - "execution_count": 11, |
| 343 | + "execution_count": 10, |
343 | 344 | "id": "brazilian-royalty",
|
344 | 345 | "metadata": {},
|
345 | 346 | "outputs": [],
|
|
351 | 352 | },
|
352 | 353 | {
|
353 | 354 | "cell_type": "code",
|
354 |
| - "execution_count": 12, |
| 355 | + "execution_count": 11, |
355 | 356 | "id": "collaborative-stephen",
|
356 | 357 | "metadata": {},
|
357 | 358 | "outputs": [
|
358 | 359 | {
|
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 | + ] |
367 | 403 | }
|
368 | 404 | ],
|
369 | 405 | "source": [
|
370 | 406 | "# This ontology is an object that represents an ontology that exists in labelbox\n",
|
371 | 407 | "# (unlike the ontology builder that only exists in your local python version)\n",
|
372 | 408 | "# 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))" |
374 | 411 | ]
|
375 | 412 | },
|
376 | 413 | {
|
377 | 414 | "cell_type": "code",
|
378 |
| - "execution_count": 13, |
| 415 | + "execution_count": 12, |
379 | 416 | "id": "promotional-treasury",
|
380 | 417 | "metadata": {},
|
381 | 418 | "outputs": [
|
382 | 419 | {
|
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 | + ] |
391 | 463 | }
|
392 | 464 | ],
|
393 | 465 | "source": [
|
394 | 466 | "# 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))" |
396 | 469 | ]
|
397 | 470 | },
|
398 | 471 | {
|
399 | 472 | "cell_type": "code",
|
400 |
| - "execution_count": 14, |
| 473 | + "execution_count": 13, |
401 | 474 | "id": "boring-hearing",
|
402 | 475 | "metadata": {},
|
403 | 476 | "outputs": [],
|
|
419 | 492 | },
|
420 | 493 | {
|
421 | 494 | "cell_type": "code",
|
422 |
| - "execution_count": 15, |
| 495 | + "execution_count": null, |
423 | 496 | "id": "beautiful-column",
|
424 | 497 | "metadata": {},
|
425 | 498 | "outputs": [],
|
426 | 499 | "source": []
|
427 |
| - }, |
428 |
| - { |
429 |
| - "cell_type": "code", |
430 |
| - "execution_count": 16, |
431 |
| - "id": "earlier-faith", |
432 |
| - "metadata": {}, |
433 |
| - "outputs": [], |
434 |
| - "source": [] |
435 | 500 | }
|
436 | 501 | ],
|
437 | 502 | "metadata": {
|
|
0 commit comments