Skip to content

Commit db5fca0

Browse files
authored
Remove raster seg masks from video prediction (#1097)
1 parent 9b2e64b commit db5fca0

File tree

1 file changed

+89
-68
lines changed

1 file changed

+89
-68
lines changed

examples/prediction_upload/video_predictions.ipynb

Lines changed: 89 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@
4141
"- Polyline\n",
4242
"- Classification - radio\n",
4343
"- Classification - checklist\n",
44+
"- Classification - free text\n",
45+
"- Nested classifications \n",
4446
"\n",
4547
"**NOT** supported:\n",
46-
"- Polygons \n",
47-
"- Segmentation masks\n",
48-
"- Free form text classifications\n",
49-
"\n",
50-
"Please note that this list of unsupported annotations only refers to limitations for importing annotations. For example, when using the Labelbox editor, segmentation masks can be created and edited on video assets.\n"
48+
"- Polygons [not supported in video editor or model]\n",
49+
"- Raster segmentation masks [not supported in model] \n",
50+
"- Vector segmentation masks [not supported in video editor]\n",
51+
"\n"
5152
],
5253
"cell_type": "markdown"
5354
},
@@ -680,45 +681,6 @@
680681
"outputs": [],
681682
"execution_count": null
682683
},
683-
{
684-
"metadata": {},
685-
"source": [
686-
"##### Raster Segmentation ########\n",
687-
"\n",
688-
"instance_uri = \"https://storage.googleapis.com/labelbox-datasets/video-sample-data/mask_example.png\"\n",
689-
"\n",
690-
"\n",
691-
"\n",
692-
"video_mask_prediction=[\n",
693-
" lb_types.VideoMaskAnnotation(\n",
694-
" frames=[\n",
695-
" lb_types.MaskFrame(index=10, instance_uri=instance_uri)\n",
696-
" ],\n",
697-
" instances=[\n",
698-
" lb_types.MaskInstance(color_rgb=(255,255,255), name=\"video_mask\")\n",
699-
" ] \n",
700-
" )\n",
701-
"]\n",
702-
"\n",
703-
"video_mask_prediction_ndjson = {\n",
704-
" \"masks\": {\n",
705-
" \"frames\": [{\n",
706-
" \"index\": 10,\n",
707-
" \"instanceURI\": instance_uri\n",
708-
" }],\n",
709-
" \"instances\": [\n",
710-
" {\n",
711-
" \"colorRGB\": (255, 255, 255),\n",
712-
" \"name\": \"video_mask\",\n",
713-
" }\n",
714-
" ]\n",
715-
" }\n",
716-
"}"
717-
],
718-
"cell_type": "code",
719-
"outputs": [],
720-
"execution_count": null
721-
},
722684
{
723685
"metadata": {},
724686
"source": [
@@ -763,7 +725,23 @@
763725
"print(\"Failed data rows: \",task.failed_data_rows)"
764726
],
765727
"cell_type": "code",
766-
"outputs": [],
728+
"outputs": [
729+
{
730+
"name": "stderr",
731+
"output_type": "stream",
732+
"text": [
733+
"There are errors present. Please look at `task.errors` for more details\n"
734+
]
735+
},
736+
{
737+
"name": "stdout",
738+
"output_type": "stream",
739+
"text": [
740+
"Errors: Duplicate global keys found: sample-video-2.mp4\n",
741+
"Failed data rows: [{'message': 'Duplicate global keys found: sample-video-2.mp4', 'failedDataRows': [{'globalKey': 'sample-video-2.mp4', 'rowData': 'https://storage.googleapis.com/labelbox-datasets/video-sample-data/sample-video-2.mp4', 'attachmentInputs': []}]}]\n"
742+
]
743+
}
744+
],
767745
"execution_count": null
768746
},
769747
{
@@ -782,7 +760,6 @@
782760
" lb.Tool(tool=lb.Tool.Type.BBOX, name=\"bbox_video\"),\n",
783761
" lb.Tool(tool=lb.Tool.Type.POINT, name=\"point_video\"),\n",
784762
" lb.Tool(tool=lb.Tool.Type.LINE, name=\"line_video_frame\"),\n",
785-
" lb.Tool(tool=lb.Tool.Type.RASTER_SEGMENTATION, name=\"video_mask\"),\n",
786763
" lb.Tool(\n",
787764
" tool=lb.Tool.Type.BBOX, name=\"bbox_class\",\n",
788765
" classifications=[\n",
@@ -872,7 +849,7 @@
872849
"\n",
873850
"ontology = client.create_ontology(\"Ontology Video Annotations\", \n",
874851
" ontology_builder.asdict(), \n",
875-
" # media_type=lb.MediaType.Video\n",
852+
" media_type=lb.MediaType.Video\n",
876853
" )"
877854
],
878855
"cell_type": "code",
@@ -912,7 +889,18 @@
912889
"model_run.upsert_data_rows(global_keys=[global_key])"
913890
],
914891
"cell_type": "code",
915-
"outputs": [],
892+
"outputs": [
893+
{
894+
"data": {
895+
"text/plain": [
896+
"True"
897+
]
898+
},
899+
"execution_count": 90,
900+
"metadata": {},
901+
"output_type": "execute_result"
902+
}
903+
],
916904
"execution_count": null
917905
},
918906
{
@@ -947,7 +935,6 @@
947935
" frame_bbox_with_checklist_subclass_prediction,\n",
948936
" global_radio_prediction,\n",
949937
" global_checklist_prediction,\n",
950-
" video_mask_prediction,\n",
951938
" text_prediction\n",
952939
" ]\n",
953940
"\n",
@@ -988,7 +975,6 @@
988975
" frame_bbox_with_checklist_subclass_prediction_ndjson,\n",
989976
" global_radio_classification_ndjson,\n",
990977
" global_checklist_classification_ndjson,\n",
991-
" video_mask_prediction_ndjson,\n",
992978
" text_prediction_ndjson\n",
993979
"]: \n",
994980
" annotation.update({\n",
@@ -1022,7 +1008,16 @@
10221008
"print(\"Status of uploads: \", upload_job_prediction.statuses)"
10231009
],
10241010
"cell_type": "code",
1025-
"outputs": [],
1011+
"outputs": [
1012+
{
1013+
"name": "stdout",
1014+
"output_type": "stream",
1015+
"text": [
1016+
"Errors: []\n",
1017+
"Status of uploads: [{'uuid': 'e3145fa9-42b8-466f-9ac5-0130aeab1060', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}, {'uuid': '04e035b4-3083-4408-9a67-9cb52cbe027b', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}, {'uuid': 'aafaeda7-8ba3-4df1-8e42-a02fe72add94', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}, {'uuid': '956687f4-091c-4dc0-9c84-0b4e35ae451b', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}, {'uuid': 'b7c6e33e-2cc4-46be-8a1f-d920cabf115b', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}, {'uuid': 'daff0aff-8834-4e80-97f5-cf2d38684c5c', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}, {'uuid': 'a611c275-39d8-47aa-808c-969692eb1698', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}, {'uuid': '9ed7be94-bf89-432b-99ff-c834f31087f0', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}, {'uuid': '6ed2ef7c-e83a-48e6-8073-c291779c7497', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}, {'uuid': '14a4950f-0835-49bb-a968-81c41cda6869', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}, {'uuid': '5bd23f6c-ab87-44b0-a32b-49c84f72b06c', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}]\n"
1018+
]
1019+
}
1020+
],
10261021
"execution_count": null
10271022
},
10281023
{
@@ -1051,7 +1046,15 @@
10511046
"project.setup_editor(ontology)"
10521047
],
10531048
"cell_type": "code",
1054-
"outputs": [],
1049+
"outputs": [
1050+
{
1051+
"name": "stderr",
1052+
"output_type": "stream",
1053+
"text": [
1054+
"Default createProject behavior will soon be adjusted to prefer batch projects. Pass in `queue_mode` parameter explicitly to opt-out for the time being.\n"
1055+
]
1056+
}
1057+
],
10551058
"execution_count": null
10561059
},
10571060
{
@@ -1071,7 +1074,18 @@
10711074
")"
10721075
],
10731076
"cell_type": "code",
1074-
"outputs": [],
1077+
"outputs": [
1078+
{
1079+
"data": {
1080+
"text/plain": [
1081+
"<Batch ID: 28e7da10-f660-11ed-9f2b-f9c234af8129>"
1082+
]
1083+
},
1084+
"execution_count": 95,
1085+
"metadata": {},
1086+
"output_type": "execute_result"
1087+
}
1088+
],
10751089
"execution_count": null
10761090
},
10771091
{
@@ -1368,18 +1382,6 @@
13681382
"]\n",
13691383
"\n",
13701384
"\n",
1371-
"instance_uri = \"https://storage.googleapis.com/labelbox-datasets/video-sample-data/mask_example.png\"\n",
1372-
"video_mask_annotation=[\n",
1373-
" lb_types.VideoMaskAnnotation(\n",
1374-
" frames=[\n",
1375-
" lb_types.MaskFrame(index=10, instance_uri=instance_uri)\n",
1376-
" ],\n",
1377-
" instances=[\n",
1378-
" lb_types.MaskInstance(color_rgb=(255,255,255), name=\"video_mask\")\n",
1379-
" ] \n",
1380-
" )\n",
1381-
"]\n",
1382-
"\n",
13831385
"text_annotation = [lb_types.ClassificationAnnotation(\n",
13841386
" name=\"free_text\", # must match your ontology feature's name\n",
13851387
" value=lb_types.Text(answer=\"sample text\")\n",
@@ -1416,7 +1418,6 @@
14161418
" polyline_annotation,\n",
14171419
" global_checklist_annotation,\n",
14181420
" global_radio_annotation,\n",
1419-
" video_mask_annotation,\n",
14201421
" nested_checklist_annotation,\n",
14211422
" nested_radio_annotation,\n",
14221423
" text_annotation\n",
@@ -1457,7 +1458,16 @@
14571458
"print(\"Status of uploads: \", upload_job_annotation.statuses)"
14581459
],
14591460
"cell_type": "code",
1460-
"outputs": [],
1461+
"outputs": [
1462+
{
1463+
"name": "stdout",
1464+
"output_type": "stream",
1465+
"text": [
1466+
"Errors: []\n",
1467+
"Status of uploads: [{'uuid': 'c5ddce8f-c672-49d7-bc43-f4cc5afbe0f2', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}, {'uuid': '9b2bf816-6f22-4b05-818a-d200a2061a94', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}, {'uuid': 'f6bf224d-a295-484b-8078-16e49e7583ec', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}, {'uuid': '0602a136-8383-49c0-be64-36ea1499cd31', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}, {'uuid': '306df4bd-a22d-48c7-bfee-fb0e8695d965', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}, {'uuid': '60ec1dfc-64bb-4354-98f0-67aec7794bac', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}, {'uuid': '6fd8c58d-883d-4fdb-9bdc-598c663e0ad4', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}, {'uuid': '200c256f-b6cd-4469-987a-e9d773dc5715', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}, {'uuid': 'b1c3ccbe-21fd-4c41-aeee-e2df9732cd5f', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}, {'uuid': '7682c660-147a-4cf8-9b3a-a15859100142', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}, {'uuid': '4e80a895-3722-49e9-8d00-15eded343a60', 'dataRow': {'id': 'clfco73at0080079n5dhm9y3a', 'globalKey': 'sample-video-2.mp4'}, 'status': 'SUCCESS'}]\n"
1468+
]
1469+
}
1470+
],
14611471
"execution_count": null
14621472
},
14631473
{
@@ -1474,7 +1484,18 @@
14741484
"model_run.upsert_labels(project_id=project.uid)"
14751485
],
14761486
"cell_type": "code",
1477-
"outputs": [],
1487+
"outputs": [
1488+
{
1489+
"data": {
1490+
"text/plain": [
1491+
"True"
1492+
]
1493+
},
1494+
"execution_count": 99,
1495+
"metadata": {},
1496+
"output_type": "execute_result"
1497+
}
1498+
],
14781499
"execution_count": null
14791500
},
14801501
{

0 commit comments

Comments
 (0)