Skip to content

Commit c342597

Browse files
authored
[AL-4860] Remove NDJsonConverter from example notebooks
2 parents ebdb097 + 86473e8 commit c342597

19 files changed

+192
-372
lines changed

examples/annotation_import/conversational.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103
"source": [
104104
"from labelbox.schema.ontology import OntologyBuilder, Tool, Classification, Option\n",
105105
"from labelbox import Client, LabelingFrontend, MALPredictionImport, LabelImport\n",
106-
"from labelbox.data.serialization import NDJsonConverter\n",
107106
"from labelbox.schema.media_type import MediaType\n",
108107
"import uuid\n",
109108
"import json"

examples/annotation_import/image.ipynb

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,8 @@
507507
"cell_type": "code",
508508
"outputs": [
509509
{
510-
"output_type": "stream",
511510
"name": "stdout",
511+
"output_type": "stream",
512512
"text": [
513513
"<DataRow {\n",
514514
" \"created_at\": \"2023-02-09 19:41:53+00:00\",\n",
@@ -524,14 +524,14 @@
524524
]
525525
},
526526
{
527-
"output_type": "execute_result",
528527
"data": {
529528
"text/plain": [
530529
"2"
531530
]
532531
},
532+
"execution_count": 58,
533533
"metadata": {},
534-
"execution_count": 58
534+
"output_type": "execute_result"
535535
}
536536
],
537537
"execution_count": null
@@ -686,8 +686,8 @@
686686
"cell_type": "code",
687687
"outputs": [
688688
{
689-
"output_type": "stream",
690689
"name": "stdout",
690+
"output_type": "stream",
691691
"text": [
692692
"Batch <Batch {\n",
693693
" \"consensus_settings_json\": \"{\\\"numberOfLabels\\\":1,\\\"coveragePercentage\\\":0}\",\n",
@@ -743,11 +743,7 @@
743743
" polyline_annotation\n",
744744
" ]\n",
745745
" )\n",
746-
")\n",
747-
"\n",
748-
"\n",
749-
"# Convert our label from a Labelbox class object to the underlying NDJSON format required for upload \n",
750-
"label_ndjson = list(lb_serializers.NDJsonConverter.serialize(label))"
746+
")"
751747
],
752748
"cell_type": "code",
753749
"outputs": [],
@@ -819,8 +815,8 @@
819815
"cell_type": "code",
820816
"outputs": [
821817
{
822-
"output_type": "stream",
823818
"name": "stdout",
819+
"output_type": "stream",
824820
"text": [
825821
"Errors: []\n",
826822
" \n"
@@ -852,8 +848,8 @@
852848
"cell_type": "code",
853849
"outputs": [
854850
{
855-
"output_type": "stream",
856851
"name": "stdout",
852+
"output_type": "stream",
857853
"text": [
858854
"Errors: []\n",
859855
" \n"

examples/annotation_import/pdf.ipynb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
" Radio, Checklist, Text,\n",
7070
" ClassificationAnnotation, ClassificationAnswer\n",
7171
")\n",
72-
"from labelbox.data.serialization import NDJsonConverter\n",
7372
"from labelbox.schema.media_type import MediaType\n",
7473
"import uuid\n",
7574
"from uuid import uuid4\n",
@@ -91,7 +90,7 @@
9190
"metadata": {},
9291
"source": [
9392
"# Add your api key\n",
94-
"API_KEY = \"\"\n",
93+
"API_KEY = None\n",
9594
"client = Client(api_key=API_KEY)"
9695
],
9796
"cell_type": "code",
@@ -175,15 +174,15 @@
175174
"cell_type": "code",
176175
"outputs": [
177176
{
178-
"output_type": "stream",
179177
"name": "stderr",
178+
"output_type": "stream",
180179
"text": [
181180
"WARNING:labelbox.client: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"
182181
]
183182
},
184183
{
185-
"output_type": "stream",
186184
"name": "stdout",
185+
"output_type": "stream",
187186
"text": [
188187
"None\n"
189188
]
@@ -268,8 +267,8 @@
268267
"cell_type": "code",
269268
"outputs": [
270269
{
271-
"output_type": "stream",
272270
"name": "stdout",
271+
"output_type": "stream",
273272
"text": [
274273
"[]\n",
275274
"[{'uuid': 'dffe7d75-1c61-4dcd-a0d4-804438cf540b', 'dataRow': {'id': 'clb5cdf1c6u0a077d87kffy28'}, 'status': 'SUCCESS'}]\n"

examples/annotation_import/text.ipynb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@
9191
" Label, TextData, Checklist, Radio, ObjectAnnotation, TextEntity,\n",
9292
" ClassificationAnnotation, ClassificationAnswer, LabelList, Text, ImageData\n",
9393
")\n",
94-
"from labelbox.data.serialization import NDJsonConverter\n",
9594
"import uuid\n",
9695
"import json"
9796
],
@@ -284,8 +283,8 @@
284283
"cell_type": "code",
285284
"outputs": [
286285
{
287-
"output_type": "stream",
288286
"name": "stdout",
287+
"output_type": "stream",
289288
"text": [
290289
"<DataRow {\n",
291290
" \"created_at\": \"2023-01-30 18:06:23+00:00\",\n",
@@ -435,8 +434,8 @@
435434
"cell_type": "code",
436435
"outputs": [
437436
{
438-
"output_type": "stream",
439437
"name": "stdout",
438+
"output_type": "stream",
440439
"text": [
441440
"Batch: <Batch {\n",
442441
" \"consensus_settings_json\": \"{\\\"numberOfLabels\\\":1,\\\"coveragePercentage\\\":0}\",\n",
@@ -490,10 +489,7 @@
490489
" url = client.upload_data(content=obj_bytes, sign=True)\n",
491490
" return url \n",
492491
"\n",
493-
"label.add_url_to_masks(signing_function)\n",
494-
"\n",
495-
"# Convert our label from a Labelbox class object to the underlying NDJSON format required for upload \n",
496-
"label_ndjson = list(NDJsonConverter.serialize([label]))"
492+
"label.add_url_to_masks(signing_function)"
497493
],
498494
"cell_type": "code",
499495
"outputs": [],
@@ -562,8 +558,8 @@
562558
"cell_type": "code",
563559
"outputs": [
564560
{
565-
"output_type": "stream",
566561
"name": "stdout",
562+
"output_type": "stream",
567563
"text": [
568564
"Errors: []\n",
569565
" \n"
@@ -595,8 +591,8 @@
595591
"cell_type": "code",
596592
"outputs": [
597593
{
598-
"output_type": "stream",
599594
"name": "stdout",
595+
"output_type": "stream",
600596
"text": [
601597
"Errors: []\n"
602598
]

examples/annotation_import/tiled.ipynb

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
"import labelbox.data.annotation_types as lb_types\n",
9797
"import labelbox.schema.queue_mode as lb_queue_mode\n",
9898
"\n",
99-
"from labelbox.data.serialization.ndjson.converter import NDJsonConverter\n",
10099
"from labelbox.data.annotation_types.data.tiled_image import TiledBounds, TiledImageData, TileLayer, EPSG, EPSGTransformer\n",
101100
"\n"
102101
],
@@ -565,8 +564,8 @@
565564
"cell_type": "code",
566565
"outputs": [
567566
{
568-
"output_type": "stream",
569567
"name": "stdout",
568+
"output_type": "stream",
570569
"text": [
571570
"None\n"
572571
]
@@ -738,8 +737,8 @@
738737
"cell_type": "code",
739738
"outputs": [
740739
{
741-
"output_type": "stream",
742740
"name": "stdout",
741+
"output_type": "stream",
743742
"text": [
744743
"Batch: <Batch {\n",
745744
" \"consensus_settings_json\": \"{\\\"numberOfLabels\\\":1,\\\"coveragePercentage\\\":0}\",\n",
@@ -837,8 +836,8 @@
837836
"cell_type": "code",
838837
"outputs": [
839838
{
840-
"output_type": "stream",
841839
"name": "stderr",
840+
"output_type": "stream",
842841
"text": [
843842
"WARNING:labelbox.data.annotation_types.data.tiled_image:Unexpected tile size (512, 512, 3).\n",
844843
"WARNING:labelbox.data.annotation_types.data.tiled_image:Unexpected tile size (512, 512, 3).\n"
@@ -871,15 +870,11 @@
871870
" checklist_annotation,\n",
872871
" polygon_annotation_two\n",
873872
" ]\n",
874-
")\n",
875-
"# Convert our label from a Labelbox class object to the underlying NDJSON format required for upload \n",
876-
"label_ndjson = list(NDJsonConverter.serialize([label]))\n",
877-
"label_ndjson"
873+
")"
878874
],
879875
"cell_type": "code",
880876
"outputs": [
881877
{
882-
"output_type": "execute_result",
883878
"data": {
884879
"text/plain": [
885880
"[{'uuid': '61ad497c-85bd-4f3c-a32e-4cb368844a22',\n",
@@ -972,8 +967,9 @@
972967
" {'x': -122.31703039689702, 'y': 37.87397804081582}]}]"
973968
]
974969
},
970+
"execution_count": 66,
975971
"metadata": {},
976-
"execution_count": 66
972+
"output_type": "execute_result"
977973
}
978974
],
979975
"execution_count": null
@@ -1024,7 +1020,6 @@
10241020
"cell_type": "code",
10251021
"outputs": [
10261022
{
1027-
"output_type": "execute_result",
10281023
"data": {
10291024
"text/plain": [
10301025
"[{'name': 'point_geo',\n",
@@ -1124,8 +1119,9 @@
11241119
" 'dataRow': {'id': 'cldxm4s5906rw074nfm5kgtrl'}}]"
11251120
]
11261121
},
1122+
"execution_count": 68,
11271123
"metadata": {},
1128-
"execution_count": 68
1124+
"output_type": "execute_result"
11291125
}
11301126
],
11311127
"execution_count": null
@@ -1163,8 +1159,8 @@
11631159
"cell_type": "code",
11641160
"outputs": [
11651161
{
1166-
"output_type": "stream",
11671162
"name": "stdout",
1163+
"output_type": "stream",
11681164
"text": [
11691165
"Errors: []\n",
11701166
" \n"
@@ -1197,8 +1193,8 @@
11971193
"cell_type": "code",
11981194
"outputs": [
11991195
{
1200-
"output_type": "stream",
12011196
"name": "stdout",
1197+
"output_type": "stream",
12021198
"text": [
12031199
"Errors: []\n"
12041200
]

examples/basics/getting_started.ipynb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"import labelbox\n",
2020
"from labelbox.schema.ontology import OntologyBuilder, Tool, Classification,Option\n",
2121
"from labelbox.schema.annotation_import import MALPredictionImport\n",
22-
"from labelbox.data.serialization import NDJsonConverter\n",
2322
"from labelbox.schema.annotation_import import LabelImport\n",
2423
"from labelbox.schema.queue_mode import QueueMode\n",
2524
"from labelbox.schema.media_type import MediaType\n",
@@ -81,7 +80,7 @@
8180
"metadata": {},
8281
"source": [
8382
"## Generate API key: https://app.labelbox.com/account/api-keys\n",
84-
"LB_API_KEY = \"\"\n",
83+
"LB_API_KEY = None\n",
8584
"client = labelbox.Client(LB_API_KEY)\n",
8685
"\n",
8786
"DATA_ROWS = \"https://storage.googleapis.com/labelbox-datasets/VHR_geospatial/geospatial_datarows.json\"\n",
@@ -298,11 +297,9 @@
298297
{
299298
"metadata": {},
300299
"source": [
301-
"ground_truth_ndjson = list(NDJsonConverter.serialize(ground_truth_list))\n",
302-
"\n",
303300
"start_time = time.time()\n",
304301
"## Upload annotations\n",
305-
"upload_task = LabelImport.create_from_objects(client, project.uid, \"geospatial-import-job-1\", ground_truth_ndjson)\n",
302+
"upload_task = LabelImport.create_from_objects(client, project.uid, \"geospatial-import-job-1\", ground_truth_list)\n",
306303
"print(upload_task)\n",
307304
"\n",
308305
"#Wait for upload to finish (Will take up to five minutes)\n",

examples/integrations/detectron2/coco_object.ipynb

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
"from detectron2.utils.visualizer import Visualizer\n",
110110
"\n",
111111
"from labelbox import Client, LabelingFrontend, OntologyBuilder\n",
112-
"from labelbox.data.serialization import COCOConverter, NDJsonConverter\n",
112+
"from labelbox.data.serialization import COCOConverter\n",
113113
"from labelbox.schema.model import Model\n",
114114
"from labelbox.data.metrics.group import get_label_pairs\n",
115115
"from labelbox.schema.media_type import MediaType\n",
@@ -487,7 +487,7 @@
487487
{
488488
"metadata": {},
489489
"source": [
490-
"upload_task = model_run.add_predictions(f'diagnostics-import-{uuid.uuid4()}', NDJsonConverter.serialize(labels_mea))\n",
490+
"upload_task = model_run.add_predictions(f'diagnostics-import-{uuid.uuid4()}', labels_mea)\n",
491491
"upload_task.wait_until_done()\n",
492492
"print(upload_task.state)\n",
493493
"print(upload_task.errors)"
@@ -581,14 +581,13 @@
581581
{
582582
"metadata": {},
583583
"source": [
584-
" ndjsons = list(NDJsonConverter.serialize(labels_mal))\n",
585-
" upload_task = project.upload_annotations(name=f\"upload-job-{uuid.uuid4()}\",\n",
586-
" annotations=ndjsons,\n",
587-
" validate=False)\n",
588-
" # Wait for upload to finish\n",
589-
" upload_task.wait_until_done()\n",
590-
" # Review the upload status\n",
591-
" print(upload_task.errors)"
584+
"upload_task = project.upload_annotations(name=f\"upload-job-{uuid.uuid4()}\",\n",
585+
" annotations=labels_mal,\n",
586+
" validate=False)\n",
587+
"# Wait for upload to finish\n",
588+
"upload_task.wait_until_done()\n",
589+
"# Review the upload status\n",
590+
"print(upload_task.errors)"
592591
],
593592
"cell_type": "code",
594593
"outputs": [],

0 commit comments

Comments
 (0)