|
81 | 81 | "execution_count": 1, |
82 | 82 | "id": "4d63074b-2379-48af-b9d6-2a66190f03c4", |
83 | 83 | "metadata": { |
84 | | - "id": "4d63074b-2379-48af-b9d6-2a66190f03c4", |
85 | 84 | "colab": { |
86 | 85 | "base_uri": "https://localhost:8080/" |
87 | 86 | }, |
| 87 | + "id": "4d63074b-2379-48af-b9d6-2a66190f03c4", |
88 | 88 | "outputId": "2560882d-6542-4dda-c075-d197ef2da5e3" |
89 | 89 | }, |
90 | 90 | "outputs": [ |
91 | 91 | { |
92 | | - "output_type": "stream", |
93 | 92 | "name": "stdout", |
| 93 | + "output_type": "stream", |
94 | 94 | "text": [ |
95 | 95 | "\u001b[K |████████████████████████████████| 172 kB 9.3 MB/s \n", |
96 | 96 | "\u001b[K |████████████████████████████████| 6.3 MB 15.2 MB/s \n", |
|
130 | 130 | " ClassificationAnnotation, ClassificationAnswer\n", |
131 | 131 | ")\n", |
132 | 132 | "from labelbox.data.serialization import NDJsonConverter\n", |
| 133 | + "from labelbox.schema.media_type import MediaType\n", |
133 | 134 | "import uuid\n", |
134 | 135 | "import json\n", |
135 | 136 | "import numpy as np" |
|
196 | 197 | }, |
197 | 198 | { |
198 | 199 | "cell_type": "markdown", |
| 200 | + "id": "49i_juOUr6av", |
| 201 | + "metadata": { |
| 202 | + "id": "49i_juOUr6av" |
| 203 | + }, |
199 | 204 | "source": [ |
200 | 205 | "First, we create an ontology with all the possible tools and classifications supported for images. The official list of supported annotations to import can be found here:\n", |
201 | 206 | "- [Model-Assisted Labeling](https://docs.labelbox.com/docs/model-assisted-labeling) (annotations/labels are not submitted)\n", |
202 | 207 | "- [Ground Truth](https://docs.labelbox.com/docs/import-ground-truth) (annotations/labels are submitted)" |
203 | | - ], |
204 | | - "metadata": { |
205 | | - "id": "49i_juOUr6av" |
206 | | - }, |
207 | | - "id": "49i_juOUr6av" |
| 208 | + ] |
208 | 209 | }, |
209 | 210 | { |
210 | 211 | "cell_type": "code", |
|
258 | 259 | }, |
259 | 260 | { |
260 | 261 | "cell_type": "markdown", |
261 | | - "source": [ |
262 | | - "To show the two different ways to upload annotations, we create two projects - one to showcase MAL (Model-Assisted Labeling) and one to showcase Label Import." |
263 | | - ], |
| 262 | + "id": "1GdimALBuzRU", |
264 | 263 | "metadata": { |
265 | 264 | "id": "1GdimALBuzRU" |
266 | 265 | }, |
267 | | - "id": "1GdimALBuzRU" |
| 266 | + "source": [ |
| 267 | + "To show the two different ways to upload annotations, we create two projects - one to showcase MAL (Model-Assisted Labeling) and one to showcase Label Import." |
| 268 | + ] |
268 | 269 | }, |
269 | 270 | { |
270 | 271 | "cell_type": "code", |
|
276 | 277 | "outputs": [], |
277 | 278 | "source": [ |
278 | 279 | "# Create two Labelbox projects\n", |
279 | | - "mal_project = client.create_project(name=\"image_mal_project\")\n", |
280 | | - "li_project = client.create_project(name=\"image_label_import_project\")\n", |
| 280 | + "mal_project = client.create_project(\n", |
| 281 | + " name=\"image_mal_project\",\n", |
| 282 | + " media_type=MediaType.Image\n", |
| 283 | + ")\n", |
| 284 | + "li_project = client.create_project(\n", |
| 285 | + " name=\"image_label_import_project\",\n", |
| 286 | + " media_type=MediaType.Image\n", |
| 287 | + ")\n", |
281 | 288 | "\n", |
282 | 289 | "# Create one Labelbox dataset\n", |
283 | 290 | "dataset = client.create_dataset(name=\"image_annotation_import_demo_dataset\")\n", |
|
319 | 326 | }, |
320 | 327 | { |
321 | 328 | "cell_type": "code", |
| 329 | + "execution_count": 33, |
| 330 | + "id": "qzBqhV4Pv3yp", |
| 331 | + "metadata": { |
| 332 | + "id": "qzBqhV4Pv3yp" |
| 333 | + }, |
| 334 | + "outputs": [], |
322 | 335 | "source": [ |
323 | 336 | "point_annotation=ObjectAnnotation(\n", |
324 | 337 | " value=Point(x=882,y=159), # Coordinates for this point annotation\n", |
|
363 | 376 | " ),\n", |
364 | 377 | " name=\"mask\" # Name of the tool in your ontology\n", |
365 | 378 | ")" |
366 | | - ], |
367 | | - "metadata": { |
368 | | - "id": "qzBqhV4Pv3yp" |
369 | | - }, |
370 | | - "id": "qzBqhV4Pv3yp", |
371 | | - "execution_count": 33, |
372 | | - "outputs": [] |
| 379 | + ] |
373 | 380 | }, |
374 | 381 | { |
375 | 382 | "cell_type": "markdown", |
|
383 | 390 | }, |
384 | 391 | { |
385 | 392 | "cell_type": "code", |
| 393 | + "execution_count": 34, |
| 394 | + "id": "f2RtQQPCymOB", |
| 395 | + "metadata": { |
| 396 | + "id": "f2RtQQPCymOB" |
| 397 | + }, |
| 398 | + "outputs": [], |
386 | 399 | "source": [ |
387 | 400 | "text_annotation=ClassificationAnnotation(\n", |
388 | 401 | " value=Text( # String value for the text annotation\n", |
|
409 | 422 | " ), \n", |
410 | 423 | " name=\"radio\" # Name of the classification in your ontology\n", |
411 | 424 | ")" |
412 | | - ], |
413 | | - "metadata": { |
414 | | - "id": "f2RtQQPCymOB" |
415 | | - }, |
416 | | - "id": "f2RtQQPCymOB", |
417 | | - "execution_count": 34, |
418 | | - "outputs": [] |
| 425 | + ] |
419 | 426 | }, |
420 | 427 | { |
421 | 428 | "cell_type": "markdown", |
|
440 | 447 | }, |
441 | 448 | "outputs": [ |
442 | 449 | { |
443 | | - "output_type": "stream", |
444 | 450 | "name": "stderr", |
| 451 | + "output_type": "stream", |
445 | 452 | "text": [ |
446 | 453 | "/usr/local/lib/python3.7/dist-packages/labelbox/data/annotation_types/classification/classification.py:85: UserWarning: Dropdown classification is deprecated and will be removed in a future release\n", |
447 | 454 | " warnings.warn(\"Dropdown classification is deprecated and will be \"\n" |
448 | 455 | ] |
449 | 456 | }, |
450 | 457 | { |
451 | | - "output_type": "execute_result", |
452 | 458 | "data": { |
453 | 459 | "text/plain": [ |
454 | 460 | "{'annotations': [ObjectAnnotation(name='point', feature_schema_id=None, extra={}, value=Point(extra={}, x=882.0, y=159.0), classifications=[]),\n", |
|
464 | 470 | " 'uid': None}" |
465 | 471 | ] |
466 | 472 | }, |
| 473 | + "execution_count": 35, |
467 | 474 | "metadata": {}, |
468 | | - "execution_count": 35 |
| 475 | + "output_type": "execute_result" |
469 | 476 | } |
470 | 477 | ], |
471 | 478 | "source": [ |
|
518 | 525 | }, |
519 | 526 | { |
520 | 527 | "cell_type": "code", |
521 | | - "source": [ |
522 | | - "import copy # We import this python package so we can create copies of our hard-coded annotations and upload one copy to each" |
523 | | - ], |
| 528 | + "execution_count": 16, |
| 529 | + "id": "0U_cA2Cw0pH1", |
524 | 530 | "metadata": { |
525 | 531 | "id": "0U_cA2Cw0pH1" |
526 | 532 | }, |
527 | | - "id": "0U_cA2Cw0pH1", |
528 | | - "execution_count": 16, |
529 | | - "outputs": [] |
| 533 | + "outputs": [], |
| 534 | + "source": [ |
| 535 | + "import copy # We import this python package so we can create copies of our hard-coded annotations and upload one copy to each" |
| 536 | + ] |
530 | 537 | }, |
531 | 538 | { |
532 | 539 | "cell_type": "code", |
533 | 540 | "execution_count": 39, |
534 | 541 | "id": "53aaf87b-114f-4b56-a417-8c7cddc1f532", |
535 | 542 | "metadata": { |
536 | | - "id": "53aaf87b-114f-4b56-a417-8c7cddc1f532", |
537 | 543 | "colab": { |
538 | 544 | "base_uri": "https://localhost:8080/" |
539 | 545 | }, |
| 546 | + "id": "53aaf87b-114f-4b56-a417-8c7cddc1f532", |
540 | 547 | "outputId": "e525feac-9f8e-49e7-95d0-33932998b0bd" |
541 | 548 | }, |
542 | 549 | "outputs": [ |
543 | 550 | { |
544 | | - "output_type": "execute_result", |
545 | 551 | "data": { |
546 | 552 | "text/plain": [ |
547 | 553 | "[{'classifications': [],\n", |
|
620 | 626 | " 'uuid': '7e92e01b-740d-48b4-935e-560ba0b63fa5'}]" |
621 | 627 | ] |
622 | 628 | }, |
| 629 | + "execution_count": 39, |
623 | 630 | "metadata": {}, |
624 | | - "execution_count": 39 |
| 631 | + "output_type": "execute_result" |
625 | 632 | } |
626 | 633 | ], |
627 | 634 | "source": [ |
|
663 | 670 | }, |
664 | 671 | "outputs": [ |
665 | 672 | { |
666 | | - "output_type": "stream", |
667 | 673 | "name": "stdout", |
| 674 | + "output_type": "stream", |
668 | 675 | "text": [ |
669 | 676 | "Errors: []\n" |
670 | 677 | ] |
|
702 | 709 | "execution_count": 36, |
703 | 710 | "id": "e8d4e99b-ad7e-48b9-8073-afb764d7c5b4", |
704 | 711 | "metadata": { |
705 | | - "id": "e8d4e99b-ad7e-48b9-8073-afb764d7c5b4", |
706 | 712 | "colab": { |
707 | 713 | "base_uri": "https://localhost:8080/" |
708 | 714 | }, |
| 715 | + "id": "e8d4e99b-ad7e-48b9-8073-afb764d7c5b4", |
709 | 716 | "outputId": "704fac54-8f45-46f0-ce2d-3769c5b11f23" |
710 | 717 | }, |
711 | 718 | "outputs": [ |
712 | 719 | { |
713 | | - "output_type": "execute_result", |
714 | 720 | "data": { |
715 | 721 | "text/plain": [ |
716 | 722 | "[{'classifications': [],\n", |
|
789 | 795 | " 'uuid': 'f413b3a2-1e71-473c-b3b0-c952791284df'}]" |
790 | 796 | ] |
791 | 797 | }, |
| 798 | + "execution_count": 36, |
792 | 799 | "metadata": {}, |
793 | | - "execution_count": 36 |
| 800 | + "output_type": "execute_result" |
794 | 801 | } |
795 | 802 | ], |
796 | 803 | "source": [ |
|
832 | 839 | }, |
833 | 840 | "outputs": [ |
834 | 841 | { |
835 | | - "output_type": "stream", |
836 | 842 | "name": "stdout", |
| 843 | + "output_type": "stream", |
837 | 844 | "text": [ |
838 | 845 | "Errors: []\n" |
839 | 846 | ] |
|
0 commit comments