Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 5 additions & 46 deletions examples/annotation_import/conversational.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,7 @@
"project.setup_editor(ontology) # Connect your ontology and editor to your project"
],
"cell_type": "code",
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"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"
]
}
],
"outputs": [],
"execution_count": null
},
{
Expand All @@ -336,29 +328,14 @@
"# Create a batch to send to your MAL project\n",
"batch = project.create_batch(\n",
" \"first-batch-convo-demo\", # Each batch in a project must have a unique name\n",
" global_keys=global_key, # Paginated collection of data row objects, list of data row ids or global keys\n",
" global_keys=[global_key], # Paginated collection of data row objects, list of data row ids or global keys\n",
" priority=5 # priority between 1(Highest) - 5(lowest)\n",
")\n",
"\n",
"print(\"Batch: \", batch)"
],
"cell_type": "code",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Batch: <Batch {\n",
" \"consensus_settings_json\": \"{\\\"numberOfLabels\\\":1,\\\"coveragePercentage\\\":0}\",\n",
" \"created_at\": \"2022-12-23 20:20:51+00:00\",\n",
" \"name\": \"first-batch-convo-demo\",\n",
" \"size\": 1,\n",
" \"uid\": \"4bceaa60-82ff-11ed-b68f-3b1759fe9ddf\",\n",
" \"updated_at\": \"2022-12-23 20:20:51+00:00\"\n",
"}>\n"
]
}
],
"outputs": [],
"execution_count": null
},
{
Expand Down Expand Up @@ -428,16 +405,7 @@
"print(\"Status of uploads: \", upload_job.statuses)"
],
"cell_type": "code",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Errors: []\n",
" \n"
]
}
],
"outputs": [],
"execution_count": null
},
{
Expand All @@ -463,15 +431,7 @@
"print(\"Status of uploads: \", upload_job.statuses)"
],
"cell_type": "code",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Errors: []\n"
]
}
],
"outputs": [],
"execution_count": null
},
{
Expand All @@ -484,7 +444,6 @@
{
"metadata": {},
"source": [
"#upload_job\n",
"# project.delete()\n",
"# dataset.delete()"
],
Expand Down
43 changes: 12 additions & 31 deletions examples/annotation_import/image.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@
"outputs": [],
"execution_count": null
},
{
"metadata": {},
"source": [],
"cell_type": "markdown"
},
{
"metadata": {},
"source": [
Expand Down Expand Up @@ -690,28 +695,13 @@
"source": [
"batch = project.create_batch(\n",
" \"Initial batch2\", # name of the batch\n",
" global_keys=global_key, # DataRow objects, a list of global keys or data row ids are supported\n",
" global_keys=[global_key], # Paginated collection of data row objects, list of data row ids or global keys\n",
" priority=1 # priority between 1-5\n",
")\n",
"print(\"Batch\", batch)"
],
"cell_type": "code",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Batch <Batch {\n",
" \"consensus_settings_json\": \"{\\\"numberOfLabels\\\":1,\\\"coveragePercentage\\\":0}\",\n",
" \"created_at\": \"2023-03-17 13:58:44+00:00\",\n",
" \"name\": \"Initial batch2\",\n",
" \"size\": 0,\n",
" \"uid\": \"d4b46230-c4cb-11ed-8ef7-03b2e7ba4cb0\",\n",
" \"updated_at\": \"2023-03-17 13:58:44+00:00\"\n",
"}>\n"
]
}
],
"outputs": [],
"execution_count": null
},
{
Expand Down Expand Up @@ -773,7 +763,7 @@
{
"metadata": {},
"source": [
"label_ndjson_method2 = []\n",
"label_ndjson = []\n",
"for annotation in [radio_annotation_ndjson, \n",
" checklist_annotation_ndjson, \n",
" text_annotation_ndjson,\n",
Expand All @@ -792,7 +782,7 @@
" annotation.update({\n",
" 'dataRow': {'globalKey':global_key},\n",
" })\n",
" label_ndjson_method2.append(annotation)\n"
" label_ndjson.append(annotation)\n"
],
"cell_type": "code",
"outputs": [],
Expand Down Expand Up @@ -821,23 +811,14 @@
" client = client, \n",
" project_id = project.uid, \n",
" name=\"mal_job\"+str(uuid.uuid4()), \n",
" predictions=label_ndjson_method2)\n",
" predictions=label_ndjson)\n",
"\n",
"print(\"Errors:\", upload_job.errors)\n",
"print(\"Status of uploads: \", upload_job.statuses)\n",
"print(\" \")"
],
"cell_type": "code",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Errors: []\n",
" \n"
]
}
],
"outputs": [],
"execution_count": null
},
{
Expand All @@ -855,7 +836,7 @@
" client = client, \n",
" project_id = project.uid, \n",
" name=\"label_import_job\"+str(uuid.uuid4()), \n",
" labels=label_ndjson_method2)\n",
" labels=label_ndjson)\n",
"\n",
"print(\"Errors:\", upload_job.errors)\n",
"print(\"Status of uploads: \", upload_job.statuses)\n",
Expand Down
57 changes: 19 additions & 38 deletions examples/annotation_import/pdf.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
"metadata": {},
"source": [
"## Text layer url is required for uploading entity annotations\n",
"global_key = \"0801.3483.pd\"\n",
"global_key = \"0801.3483.pdf\"\n",
"img_url = {\n",
" \"row_data\": {\n",
" \"pdf_url\": \"https://storage.googleapis.com/labelbox-datasets/arxiv-pdf/data/99-word-token-pdfs/0801.3483.pdf\",\n",
Expand Down Expand Up @@ -431,23 +431,12 @@
"source": [
"project.create_batch(\n",
" \"PDF_annotation_batch\", # Each batch in a project must have a unique name\n",
" global_keys=global_key, # A list of data rows or data row ids\n",
" global_keys=[global_key], # Paginated collection of data row objects, list of data row ids or global keys\n",
" priority=5 # priority between 1(Highest) - 5(lowest)\n",
")"
],
"cell_type": "code",
"outputs": [
{
"data": {
"text/plain": [
"<Batch ID: e2152a50-c402-11ed-9933-959d2b6c8c3c>"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"execution_count": null
},
{
Expand Down Expand Up @@ -522,16 +511,7 @@
" "
],
"cell_type": "code",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"entities_annotations_ndjson={'name': 'named_entity', 'textSelections': [{'groupId': '2f4336f4-a07e-4e0a-a9e1-5629b03b719b', 'tokenIds': ['3f984bf3-1d61-44f5-b59a-9658a2e3440f', '3bf00b56-ff12-4e52-8cc1-08dbddb3c3b8', '6e1c3420-d4b7-4c5a-8fd6-ead43bf73d80', '87a43d32-af76-4a1d-b262-5c5f4d5ace3a', 'e8606e8a-dfd9-4c49-a635-ad5c879c75d0', '67c7c19e-4654-425d-bf17-2adb8cf02c30', '149c5e80-3e07-49a7-ab2d-29ddfe6a38fa', 'b0e94071-2187-461e-8e76-96c58738a52c'], 'page': 1}]}\n",
"entities_annotation=confidence=None name='named_entity' feature_schema_id=None extra={} value=DocumentEntity(text_selections=[DocumentTextSelection(token_ids=['3f984bf3-1d61-44f5-b59a-9658a2e3440f', '3bf00b56-ff12-4e52-8cc1-08dbddb3c3b8', '6e1c3420-d4b7-4c5a-8fd6-ead43bf73d80', '87a43d32-af76-4a1d-b262-5c5f4d5ace3a', 'e8606e8a-dfd9-4c49-a635-ad5c879c75d0', '67c7c19e-4654-425d-bf17-2adb8cf02c30', '149c5e80-3e07-49a7-ab2d-29ddfe6a38fa', 'b0e94071-2187-461e-8e76-96c58738a52c'], group_id='2f4336f4-a07e-4e0a-a9e1-5629b03b719b', page=1)]) classifications=[]\n"
]
}
],
"outputs": [],
"execution_count": null
},
{
Expand All @@ -545,19 +525,20 @@
{
"metadata": {},
"source": [
"# create a Label\n",
"\n",
"\n",
"labels = []\n",
"\n",
"labels.append(lb_types.Label(\n",
" data=lb_types.DocumentData(\n",
" global_key=global_key),\n",
" annotations = [\n",
" entities_annotation,\n",
" checklist_annotation, \n",
" text_annotation,\n",
" radio_annotation\n",
" ]\n",
"labels.append(\n",
" lb_types.Label(\n",
" data=lb_types.DocumentData(\n",
" global_key=global_key),\n",
" annotations = [\n",
" entities_annotation,\n",
" checklist_annotation, \n",
" text_annotation,\n",
" radio_annotation\n",
" ]\n",
" )\n",
")"
],
Expand All @@ -577,7 +558,7 @@
"metadata": {},
"source": [
"\n",
"ndjson_annotation = []\n",
"label_ndjson = []\n",
"for annot in [\n",
" entities_annotations_ndjson,\n",
" bbox_annotation_ndjson,\n",
Expand All @@ -590,7 +571,7 @@
" annot.update({\n",
" 'dataRow': {'globalKey': global_key},\n",
" })\n",
" ndjson_annotation.append(annot)\n",
" label_ndjson.append(annot)\n",
"\n"
],
"cell_type": "code",
Expand Down Expand Up @@ -618,7 +599,7 @@
" client = client,\n",
" project_id = project.uid,\n",
" name=\"pdf_annotation_upload\" + str(uuid.uuid4()),\n",
" predictions=ndjson_annotation)\n",
" predictions=label_ndjson)\n",
"\n",
"upload_job.wait_until_done()\n",
"# Errors will appear for annotation uploads that failed.\n",
Expand All @@ -644,7 +625,7 @@
" client = client, \n",
" project_id = project.uid, \n",
" name=\"label_import_job\"+str(uuid.uuid4()), \n",
" labels=ndjson_annotation)\n",
" labels=label_ndjson)\n",
"\n",
"print(\"Errors:\", upload_job.errors)\n",
"print(\"Status of uploads: \", upload_job.statuses)"
Expand Down
Loading