Skip to content

Commit e96036a

Browse files
committed
cleanup
1 parent 9c61b2a commit e96036a

File tree

1 file changed

+36
-113
lines changed

1 file changed

+36
-113
lines changed

examples/annotation_import/pdf_mal.ipynb

Lines changed: 36 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "dcc32476",
5+
"id": "7ede57bf",
66
"metadata": {},
77
"source": [
88
"<td>\n",
@@ -12,7 +12,7 @@
1212
},
1313
{
1414
"cell_type": "markdown",
15-
"id": "43328417",
15+
"id": "e2c69e42",
1616
"metadata": {},
1717
"source": [
1818
"<td>\n",
@@ -28,7 +28,7 @@
2828
},
2929
{
3030
"cell_type": "markdown",
31-
"id": "6311ec07",
31+
"id": "cef9c510",
3232
"metadata": {},
3333
"source": [
3434
"# PDF Annotation Import\n",
@@ -38,7 +38,7 @@
3838
},
3939
{
4040
"cell_type": "markdown",
41-
"id": "e111a6e2",
41+
"id": "8c877b9c",
4242
"metadata": {},
4343
"source": [
4444
"* For information on what types of annotations are supported per data type, refer to this documentation:\n",
@@ -47,7 +47,7 @@
4747
},
4848
{
4949
"cell_type": "markdown",
50-
"id": "c6a696c7",
50+
"id": "e7e5d296",
5151
"metadata": {},
5252
"source": [
5353
"* Notes:\n",
@@ -57,18 +57,16 @@
5757
{
5858
"cell_type": "code",
5959
"execution_count": 1,
60-
"id": "098fd6c8",
60+
"id": "8d8d554f",
6161
"metadata": {},
6262
"outputs": [],
6363
"source": [
64-
"# !pip install -q 'labelbox[data]'\n",
65-
"!pip install -q pip install https://github.com/Labelbox/labelbox-python/archive/refs/heads/jtso/al-3330.zip\n",
66-
"# !pip install -q -e ../../."
64+
"!pip install -q 'labelbox[data]'"
6765
]
6866
},
6967
{
7068
"cell_type": "markdown",
71-
"id": "5f5f479e",
69+
"id": "573525c5",
7270
"metadata": {},
7371
"source": [
7472
"# Imports"
@@ -77,7 +75,7 @@
7775
{
7876
"cell_type": "code",
7977
"execution_count": 2,
80-
"id": "51f77acd",
78+
"id": "e3522d4b",
8179
"metadata": {},
8280
"outputs": [],
8381
"source": [
@@ -96,7 +94,7 @@
9694
},
9795
{
9896
"cell_type": "markdown",
99-
"id": "20834a5f",
97+
"id": "e3036435",
10098
"metadata": {},
10199
"source": [
102100
"# API Key and Client\n",
@@ -105,19 +103,19 @@
105103
},
106104
{
107105
"cell_type": "code",
108-
"execution_count": 3,
109-
"id": "7e706b58",
106+
"execution_count": 56,
107+
"id": "6ffec272",
110108
"metadata": {},
111109
"outputs": [],
112110
"source": [
113111
"# Add your api key\n",
114-
"API_KEY = \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJja2NjOWZtbXc0aGNkMDczOHFpeWM2YW54Iiwib3JnYW5pemF0aW9uSWQiOiJja2N6NmJ1YnVkeWZpMDg1NW8xZHQxZzlzIiwiYXBpS2V5SWQiOiJja2V2cDF2enAwdDg0MDc1N3I2ZWZldGgzIiwiaWF0IjoxNTk5Njc0NzY0LCJleHAiOjIyMzA4MjY3NjR9.iyqPpEWNpfcjcTid5WVkXLi51g22e_l3FrK-DlFJ2mM\"\n",
112+
"API_KEY = \"YOUR API KEY\"\n",
115113
"client = Client(api_key=API_KEY)"
116114
]
117115
},
118116
{
119117
"cell_type": "markdown",
120-
"id": "f3d70bcf",
118+
"id": "70c4d820",
121119
"metadata": {},
122120
"source": [
123121
"---- \n",
@@ -129,15 +127,15 @@
129127
},
130128
{
131129
"cell_type": "markdown",
132-
"id": "9e88fd12",
130+
"id": "5d7fc082",
133131
"metadata": {},
134132
"source": [
135133
"### Project setup"
136134
]
137135
},
138136
{
139137
"cell_type": "markdown",
140-
"id": "b6b26171",
138+
"id": "d0bc3c39",
141139
"metadata": {},
142140
"source": [
143141
"First, we create an ontology with all the possible tools and classifications supported for PDF. The official list of supported annotations to import can be found here:\n",
@@ -148,7 +146,7 @@
148146
{
149147
"cell_type": "code",
150148
"execution_count": 4,
151-
"id": "00b4884a",
149+
"id": "f93aebd8",
152150
"metadata": {},
153151
"outputs": [],
154152
"source": [
@@ -184,7 +182,7 @@
184182
{
185183
"cell_type": "code",
186184
"execution_count": 5,
187-
"id": "e6ce5b06",
185+
"id": "e290fd6e",
188186
"metadata": {},
189187
"outputs": [
190188
{
@@ -205,7 +203,7 @@
205203
{
206204
"cell_type": "code",
207205
"execution_count": 6,
208-
"id": "c0bbf502",
206+
"id": "27961645",
209207
"metadata": {},
210208
"outputs": [],
211209
"source": [
@@ -228,7 +226,7 @@
228226
},
229227
{
230228
"cell_type": "markdown",
231-
"id": "eb7bb40c",
229+
"id": "db26d55d",
232230
"metadata": {},
233231
"source": [
234232
"### Create Label using Annotation Type Objects\n",
@@ -237,7 +235,7 @@
237235
},
238236
{
239237
"cell_type": "markdown",
240-
"id": "1ee26ad9",
238+
"id": "f409d3cc",
241239
"metadata": {},
242240
"source": [
243241
"### Object Annotations"
@@ -246,7 +244,7 @@
246244
{
247245
"cell_type": "code",
248246
"execution_count": 38,
249-
"id": "a877a9d8",
247+
"id": "5cbe5b5a",
250248
"metadata": {},
251249
"outputs": [],
252250
"source": [
@@ -263,7 +261,7 @@
263261
{
264262
"cell_type": "code",
265263
"execution_count": 39,
266-
"id": "e0c63922",
264+
"id": "4896ea42",
267265
"metadata": {},
268266
"outputs": [],
269267
"source": [
@@ -296,7 +294,7 @@
296294
},
297295
{
298296
"cell_type": "markdown",
299-
"id": "d5abfce2",
297+
"id": "0f79ecc9",
300298
"metadata": {},
301299
"source": [
302300
"### Create a Label object with all of our annotations"
@@ -305,7 +303,7 @@
305303
{
306304
"cell_type": "code",
307305
"execution_count": 51,
308-
"id": "616132d3",
306+
"id": "64ac1f74",
309307
"metadata": {},
310308
"outputs": [
311309
{
@@ -342,15 +340,15 @@
342340
},
343341
{
344342
"cell_type": "markdown",
345-
"id": "ef0c28cc",
343+
"id": "c7988155",
346344
"metadata": {},
347345
"source": [
348346
"### Model Assisted Labeling "
349347
]
350348
},
351349
{
352350
"cell_type": "markdown",
353-
"id": "7364844b",
351+
"id": "b33ef622",
354352
"metadata": {},
355353
"source": [
356354
"To do model-assisted labeling, we need to convert a Label object into an NDJSON. \n",
@@ -364,8 +362,10 @@
364362
{
365363
"cell_type": "code",
366364
"execution_count": 52,
367-
"id": "b77d5a9e",
368-
"metadata": {},
365+
"id": "8794d8aa",
366+
"metadata": {
367+
"scrolled": true
368+
},
369369
"outputs": [
370370
{
371371
"data": {
@@ -406,7 +406,7 @@
406406
{
407407
"cell_type": "code",
408408
"execution_count": 53,
409-
"id": "ab9b89fd",
409+
"id": "787524ac",
410410
"metadata": {},
411411
"outputs": [],
412412
"source": [
@@ -420,98 +420,21 @@
420420
},
421421
{
422422
"cell_type": "code",
423-
"execution_count": 54,
424-
"id": "966c5d8c",
423+
"execution_count": 57,
424+
"id": "eb5116f9",
425425
"metadata": {},
426-
"outputs": [
427-
{
428-
"name": "stdout",
429-
"output_type": "stream",
430-
"text": [
431-
"Errors: [{'uuid': 'fc1913c6-b735-4dea-bd25-c18152a4715f', 'dataRow': {'id': 'cl76eelhd0fm3071n9ropffkr'}, 'status': 'FAILURE', 'errors': [{'name': 'InvalidAnnotation', 'message': 'Document annotation is missing page or unit fields.', 'additionalInfo': None}]}, {'uuid': '9d7b2e57-d68f-4388-867a-af2a9b233719', 'dataRow': {'id': 'cl76eelhd0fm3071n9ropffkr'}, 'status': 'FAILURE', 'errors': [{'name': 'InvalidAnnotation', 'message': 'Document annotation is missing page or unit fields.', 'additionalInfo': None}]}, {'uuid': 'ad60897f-ea1a-47de-b923-459339764921', 'dataRow': {'id': 'cl76eelhd0fm3071n9ropffkr'}, 'status': 'FAILURE', 'errors': [{'name': 'InvalidAnnotation', 'message': 'Document annotation is missing page or unit fields.', 'additionalInfo': None}]}]\n"
432-
]
433-
}
434-
],
426+
"outputs": [],
435427
"source": [
436428
"# Errors will appear for each annotation that failed.\n",
437429
"# Empty list means that there were no errors\n",
438430
"# This will provide information only after the upload_job is complete, so we do not need to worry about having to rerun\n",
439431
"print(\"Errors:\", upload_job.errors)"
440432
]
441433
},
442-
{
443-
"cell_type": "code",
444-
"execution_count": 55,
445-
"id": "dc0f963f",
446-
"metadata": {},
447-
"outputs": [
448-
{
449-
"data": {
450-
"text/plain": [
451-
"{'tools': [{'tool': 'rectangle',\n",
452-
" 'name': 'box',\n",
453-
" 'required': False,\n",
454-
" 'color': '#ff0000',\n",
455-
" 'classifications': [],\n",
456-
" 'schemaNodeId': None,\n",
457-
" 'featureSchemaId': None}],\n",
458-
" 'classifications': [{'type': 'text',\n",
459-
" 'instructions': 'text',\n",
460-
" 'name': 'text',\n",
461-
" 'required': False,\n",
462-
" 'options': [],\n",
463-
" 'schemaNodeId': None,\n",
464-
" 'featureSchemaId': None,\n",
465-
" 'scope': 'global'},\n",
466-
" {'type': 'checklist',\n",
467-
" 'instructions': 'checklist',\n",
468-
" 'name': 'checklist',\n",
469-
" 'required': False,\n",
470-
" 'options': [{'schemaNodeId': None,\n",
471-
" 'featureSchemaId': None,\n",
472-
" 'label': 'first_checklist_answer',\n",
473-
" 'value': 'first_checklist_answer',\n",
474-
" 'options': []},\n",
475-
" {'schemaNodeId': None,\n",
476-
" 'featureSchemaId': None,\n",
477-
" 'label': 'second_checklist_answer',\n",
478-
" 'value': 'second_checklist_answer',\n",
479-
" 'options': []}],\n",
480-
" 'schemaNodeId': None,\n",
481-
" 'featureSchemaId': None,\n",
482-
" 'scope': 'global'},\n",
483-
" {'type': 'radio',\n",
484-
" 'instructions': 'radio',\n",
485-
" 'name': 'radio',\n",
486-
" 'required': False,\n",
487-
" 'options': [{'schemaNodeId': None,\n",
488-
" 'featureSchemaId': None,\n",
489-
" 'label': 'first_radio_answer',\n",
490-
" 'value': 'first_radio_answer',\n",
491-
" 'options': []},\n",
492-
" {'schemaNodeId': None,\n",
493-
" 'featureSchemaId': None,\n",
494-
" 'label': 'second_radio_answer',\n",
495-
" 'value': 'second_radio_answer',\n",
496-
" 'options': []}],\n",
497-
" 'schemaNodeId': None,\n",
498-
" 'featureSchemaId': None,\n",
499-
" 'scope': 'global'}]}"
500-
]
501-
},
502-
"execution_count": 55,
503-
"metadata": {},
504-
"output_type": "execute_result"
505-
}
506-
],
507-
"source": [
508-
"ontology_builder.asdict()"
509-
]
510-
},
511434
{
512435
"cell_type": "code",
513436
"execution_count": null,
514-
"id": "223e32f9",
437+
"id": "ba9dc45a",
515438
"metadata": {},
516439
"outputs": [],
517440
"source": []

0 commit comments

Comments
 (0)