|
56 | 56 | "from labelbox.data.annotation_types import (\n", |
57 | 57 | " Label,\n", |
58 | 58 | " ImageData,\n", |
| 59 | + " MaskData,\n", |
59 | 60 | " LabelList,\n", |
60 | 61 | " TextData,\n", |
61 | 62 | " VideoData,\n", |
|
397 | 398 | "1. Value\n", |
398 | 399 | " - Must be either a Geometry, TextEntity, or Classification\n", |
399 | 400 | " - This is the same as a top level tool in labelbox\n", |
400 | | - "2. name or schema_id\n", |
| 401 | + "2. name or feature_schema_id\n", |
401 | 402 | " - This is the id that corresponds to a particular class or just simply the class name\n", |
402 | 403 | " - If uploading to labelbox this must match a field in an ontology.\n", |
403 | 404 | "3. (Optional) Classifications \n", |
|
437 | 438 | "\n", |
438 | 439 | "point_annotation = ObjectAnnotation(\n", |
439 | 440 | " value = Point(x = 5, y = 3),\n", |
440 | | - " schema_id = \"ckrgcgl89000108jtggc9e687\"\n", |
| 441 | + " feature_schema_id = \"ckrgcgl89000108jtggc9e687\"\n", |
441 | 442 | ")" |
442 | 443 | ] |
443 | 444 | }, |
|
471 | 472 | "\n", |
472 | 473 | "polygon_annotation = ObjectAnnotation(\n", |
473 | 474 | " value = Polygon(points = [Point(x = x, y = y) for x,y in xy_poly]),\n", |
474 | | - " schema_id = \"ckrgcel71000008jtd9mn0szu\"\n", |
| 475 | + " feature_schema_id = \"ckrgcel71000008jtd9mn0szu\"\n", |
475 | 476 | ")\n", |
476 | 477 | "\n" |
477 | 478 | ] |
|
500 | 501 | "\n", |
501 | 502 | "line_annotation = ObjectAnnotation(\n", |
502 | 503 | " value = Line(points = [Point(x = x, y = y) for x,y in xy_line]),\n", |
503 | | - " schema_id = \"ckrgcel71000008jtd9mn0szu\"\n", |
| 504 | + " feature_schema_id = \"ckrgcel71000008jtd9mn0szu\"\n", |
504 | 505 | ")" |
505 | 506 | ] |
506 | 507 | }, |
|
529 | 530 | "\n", |
530 | 531 | "rectangle_annotation = ObjectAnnotation(\n", |
531 | 532 | " value = Rectangle(start = start, end = end),\n", |
532 | | - " schema_id = \"ckrgcel71000008jtd9mn0szu\"\n", |
| 533 | + " feature_schema_id = \"ckrgcel71000008jtd9mn0szu\"\n", |
533 | 534 | ")" |
534 | 535 | ] |
535 | 536 | }, |
|
551 | 552 | "source": [ |
552 | 553 | "\n", |
553 | 554 | "mask_annotation = ObjectAnnotation(\n", |
554 | | - " value = Mask(mask = ImageData(arr = np.zeros((32,32,3), dtype = np.uint8)), color = (255,255,255)),\n", |
| 555 | + " value = Mask(mask = MaskData(arr = np.zeros((32,32,3), dtype = np.uint8)), color = (255,255,255)),\n", |
555 | 556 | " name = \"mask class name\"\n", |
556 | 557 | ")\n", |
557 | 558 | "\n", |
558 | 559 | "mask_annotation = ObjectAnnotation(\n", |
559 | | - " value = Mask(mask = ImageData(arr = np.zeros((32,32,3), dtype = np.uint8)), color = (255,255,255)),\n", |
560 | | - " schema_id = \"ckrgcel71000008jtd9mn0szu\"\n", |
| 560 | + " value = Mask(mask = MaskData(arr = np.zeros((32,32,3), dtype = np.uint8)), color = (255,255,255)),\n", |
| 561 | + " feature_schema_id = \"ckrgcel71000008jtd9mn0szu\"\n", |
561 | 562 | ")" |
562 | 563 | ] |
563 | 564 | }, |
|
577 | 578 | "metadata": {}, |
578 | 579 | "outputs": [], |
579 | 580 | "source": [ |
580 | | - "raster_data = ImageData(arr = np.zeros((32,32,3), dtype = np.uint8))\n", |
| 581 | + "raster_data = MaskData(arr = np.zeros((32,32,3), dtype = np.uint8))\n", |
581 | 582 | "mask_annotation = ObjectAnnotation(\n", |
582 | 583 | " value = Mask(mask = raster_data, color = [255,255,255]),\n", |
583 | 584 | " name = \"eyes\"\n", |
|
604 | 605 | "metadata": {}, |
605 | 606 | "outputs": [], |
606 | 607 | "source": [ |
607 | | - "raster_data = ImageData(arr = np.zeros((32,32, 3), dtype = np.uint8))\n", |
| 608 | + "raster_data = MaskData(arr = np.zeros((32,32, 3), dtype = np.uint8))\n", |
608 | 609 | "mask_annotation = ObjectAnnotation(\n", |
609 | 610 | " value = Mask(mask = raster_data, color = (128,255,255)),\n", |
610 | 611 | " name = \"eye\"\n", |
|
639 | 640 | "\n", |
640 | 641 | "entity_annotation = ObjectAnnotation(\n", |
641 | 642 | " value = TextEntity(start = 10, end = 12),\n", |
642 | | - " schema_id = \"ckrgddyli000108mk0c0t9qya\"\n", |
| 643 | + " feature_schema_id = \"ckrgddyli000108mk0c0t9qya\"\n", |
643 | 644 | ")" |
644 | 645 | ] |
645 | 646 | }, |
|
734 | 735 | "outputs": [], |
735 | 736 | "source": [ |
736 | 737 | "mask_annotation = Mask(\n", |
737 | | - " mask = ImageData(arr = np_mask),\n", |
| 738 | + " mask = MaskData(arr = np_mask),\n", |
738 | 739 | " color = color \n", |
739 | 740 | ")\n", |
740 | 741 | "\n", |
|
790 | 791 | "metadata": {}, |
791 | 792 | "outputs": [], |
792 | 793 | "source": [ |
793 | | - "mask_data = ImageData(arr = np_seg_mask)\n", |
| 794 | + "mask_data = MaskData(arr = np_seg_mask)\n", |
794 | 795 | "eye_mask = Mask(mask = mask_data, color = eye_color)\n", |
795 | 796 | "nose_mask = Mask(mask = mask_data, color = nose_color)\n" |
796 | 797 | ] |
|
844 | 845 | ")\n", |
845 | 846 | "\n", |
846 | 847 | "text_annotation = ClassificationAnnotation(\n", |
847 | | - " schema_id = \"my text class\", \n", |
| 848 | + " feature_schema_id = \"my text class\", \n", |
848 | 849 | " value = Text(answer = \"some text answer\") \n", |
849 | 850 | ")" |
850 | 851 | ] |
|
871 | 872 | "\n", |
872 | 873 | "\n", |
873 | 874 | "radio_annotation = ClassificationAnnotation(\n", |
874 | | - " schema_id = \"ckresqdg7000001jnb70v4zcc\",\n", |
875 | | - " value = Radio(answer = ClassificationAnswer(schema_id = \"ckrdy06ia000007ky94h04qlj\")) \n", |
| 875 | + " feature_schema_id = \"ckresqdg7000001jnb70v4zcc\",\n", |
| 876 | + " value = Radio(answer = ClassificationAnswer(feature_schema_id = \"ckrdy06ia000007ky94h04qlj\")) \n", |
876 | 877 | ")" |
877 | 878 | ] |
878 | 879 | }, |
|
893 | 894 | "source": [ |
894 | 895 | "\n", |
895 | 896 | "checklist_annotation = ClassificationAnnotation(\n", |
896 | | - " schema_id = \"ckrestd5g000101jnhudjf29a\",\n", |
897 | | - " value = Checklist(answer = [ClassificationAnswer(schema_id = \"ckrdy06ia000007ky94h04qlj\")])\n", |
| 897 | + " feature_schema_id = \"ckrestd5g000101jnhudjf29a\",\n", |
| 898 | + " value = Checklist(answer = [ClassificationAnswer(feature_schema_id = \"ckrdy06ia000007ky94h04qlj\")])\n", |
898 | 899 | ")\n", |
899 | 900 | " \n", |
900 | 901 | "checklist_annotation = ClassificationAnnotation(\n", |
|
954 | 955 | " ),\n", |
955 | 956 | " ObjectAnnotation(\n", |
956 | 957 | " name = \"deer_eyes\",\n", |
957 | | - " value = Mask(mask = ImageData(arr = np_mask), color = color)\n", |
| 958 | + " value = Mask(mask = MaskData(arr = np_mask), color = color)\n", |
958 | 959 | " )\n", |
959 | 960 | " ]\n", |
960 | 961 | ")" |
|
967 | 968 | "source": [ |
968 | 969 | "### Interacting with labelbox:\n", |
969 | 970 | "* For this label to be compatible with labelbox we need the following:\n", |
970 | | - " - all named features must have schema_ids\n", |
| 971 | + " - all named features must have feature_schema_ids\n", |
971 | 972 | " - all data must have urls\n", |
972 | 973 | " - masks\n", |
973 | 974 | " - images\n", |
|
1170 | 1171 | "metadata": {}, |
1171 | 1172 | "source": [ |
1172 | 1173 | "### Assigning Schema Ids:\n", |
1173 | | - "* All tools, classifications, and options either have names or schema_ids.\n", |
| 1174 | + "* All tools, classifications, and options either have names or feature_schema_ids.\n", |
1174 | 1175 | "* Locally it is convenient to provide a name so that we don't need a labelbox project to use these interfaces.\n", |
1175 | 1176 | "* To use MAL and MEA schema ids are required" |
1176 | 1177 | ] |
|
1220 | 1221 | "metadata": {}, |
1221 | 1222 | "outputs": [], |
1222 | 1223 | "source": [ |
1223 | | - "def show_schema_ids(label):\n", |
| 1224 | + "def show_feature_schema_ids(label):\n", |
1224 | 1225 | " for annotation in label.annotations:\n", |
1225 | | - " print(f\"Object : {annotation.name} - {annotation.schema_id}\")\n", |
| 1226 | + " print(f\"Object : {annotation.name} - {annotation.feature_schema_id}\")\n", |
1226 | 1227 | " for classification in getattr(annotation, 'classifications', []):\n", |
1227 | | - " print(f\"--- Subclass : {classification.name} - {classification.schema_id}\")\n", |
| 1228 | + " print(f\"--- Subclass : {classification.name} - {classification.feature_schema_id}\")\n", |
1228 | 1229 | " option = classification.value\n", |
1229 | | - " print(f\"--- --- Options: {option.answer.name} - {option.answer.schema_id}\")\n", |
| 1230 | + " print(f\"--- --- Options: {option.answer.name} - {option.answer.feature_schema_id}\")\n", |
1230 | 1231 | "\n", |
1231 | 1232 | " if isinstance(annotation, ClassificationAnnotation):\n", |
1232 | 1233 | " for option in annotation.value.answer:\n", |
1233 | | - " print(f\"--- Options: {option.name} - {option.schema_id}\")\n", |
1234 | | - "show_schema_ids(label)" |
| 1234 | + " print(f\"--- Options: {option.name} - {option.feature_schema_id}\")\n", |
| 1235 | + "show_feature_schema_ids(label)" |
1235 | 1236 | ] |
1236 | 1237 | }, |
1237 | 1238 | { |
|
1241 | 1242 | "metadata": {}, |
1242 | 1243 | "outputs": [], |
1243 | 1244 | "source": [ |
1244 | | - "label.assign_schema_ids(ontology)\n", |
1245 | | - "show_schema_ids(label)" |
| 1245 | + "label.assign_feature_schema_ids(ontology)\n", |
| 1246 | + "show_feature_schema_ids(label)" |
1246 | 1247 | ] |
1247 | 1248 | }, |
1248 | 1249 | { |
|
1283 | 1284 | "metadata": {}, |
1284 | 1285 | "outputs": [], |
1285 | 1286 | "source": [] |
| 1287 | + }, |
| 1288 | + { |
| 1289 | + "cell_type": "code", |
| 1290 | + "execution_count": null, |
| 1291 | + "id": "progressive-courage", |
| 1292 | + "metadata": {}, |
| 1293 | + "outputs": [], |
| 1294 | + "source": [] |
| 1295 | + }, |
| 1296 | + { |
| 1297 | + "cell_type": "code", |
| 1298 | + "execution_count": null, |
| 1299 | + "id": "asian-album", |
| 1300 | + "metadata": {}, |
| 1301 | + "outputs": [], |
| 1302 | + "source": [] |
1286 | 1303 | } |
1287 | 1304 | ], |
1288 | 1305 | "metadata": { |
|
0 commit comments