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
44 changes: 3 additions & 41 deletions examples/annotation_import/basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@
"We will create a Label called mal_label which has the same original structure as the label above\n",
"\n",
"Notes:\n",
"* Each label requires a valid feature schema id. We will assign it using our built in `assign_feature_schema_ids` method\n",
"* the NDJsonConverter takes in a list of labels"
]
},
Expand All @@ -304,30 +303,13 @@
"id": "10b19393-920a-45c8-9660-42d8c449b9c2",
"outputId": "a93a39de-c8ed-402c-b834-304b1ba8854a"
},
"outputs": [
{
"data": {
"text/plain": [
"[{'uuid': 'fde1945b-01df-43c2-807a-3f5fa20450f4',\n",
" 'dataRow': {'id': 'ckzocppkf96r10z9q205151c3'},\n",
" 'schemaId': 'ckzocpq4l9bw20z9s9bc70h29',\n",
" 'classifications': [],\n",
" 'bbox': {'top': 30.0, 'left': 30.0, 'height': 170.0, 'width': 170.0}}]"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"mal_label = Label(\n",
" data=image_data,\n",
" annotations = [rectangle_annotation]\n",
")\n",
"\n",
"mal_label.assign_feature_schema_ids(ontology_builder.from_project(mal_project))\n",
"\n",
"ndjson_labels = list(NDJsonConverter.serialize([mal_label]))\n",
"\n",
"ndjson_labels"
Expand Down Expand Up @@ -397,10 +379,7 @@
"id": "41d103bc-a5fd-4f0b-95f0-7e9bc59fbd07"
},
"source": [
"Label import is very similar to model-assisted labeling. We will need to re-assign the feature schema before continuing, \n",
"but we can continue to use our NDJSonConverter\n",
"\n",
"We will create a Label called li_label which has the same original structure as the label above"
"Label import is very similar to model-assisted labeling. We will create a Label called li_label which has the same original structure as the label above"
]
},
{
Expand All @@ -411,30 +390,13 @@
"id": "c95716d5-a1ee-46fe-8dca-313ce10f104f",
"outputId": "0e83d5d0-1f51-4903-c777-f9c331781656"
},
"outputs": [
{
"data": {
"text/plain": [
"[{'uuid': '7be8bb0b-39a2-44a5-96ab-5def3752811b',\n",
" 'dataRow': {'id': 'ckzocppkf96r10z9q205151c3'},\n",
" 'schemaId': 'ckzocpqv80ukp0z9l67cc6liv',\n",
" 'classifications': [],\n",
" 'bbox': {'top': 30.0, 'left': 30.0, 'height': 170.0, 'width': 170.0}}]"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"li_label = Label(\n",
" data=image_data,\n",
" annotations = [rectangle_annotation]\n",
")\n",
"\n",
"li_label.assign_feature_schema_ids(ontology_builder.from_project(li_project))\n",
"\n",
"ndjson_labels = list(NDJsonConverter.serialize([li_label]))\n",
"\n",
"ndjson_labels"
Expand Down
168 changes: 26 additions & 142 deletions examples/annotation_import/image.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,16 @@
"execution_count": 3,
"id": "86003724-4807-4281-95c1-5284a6f9609f",
"metadata": {
"id": "86003724-4807-4281-95c1-5284a6f9609f",
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "86003724-4807-4281-95c1-5284a6f9609f",
"outputId": "d6af46bd-128b-4bd2-9aec-ad2188a8df06"
},
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:labelbox.client:Initializing Labelbox client at 'https://api.labelbox.com/graphql'\n"
]
Expand Down Expand Up @@ -343,7 +343,6 @@
},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"{'annotations': [ObjectAnnotation(name='point', feature_schema_id=None, extra={}, value=Point(extra={}, x=100.0, y=100.0), classifications=[]),\n",
Expand All @@ -359,8 +358,9 @@
" 'uid': None}"
]
},
"execution_count": 11,
"metadata": {},
"execution_count": 11
"output_type": "execute_result"
}
],
"source": [
Expand Down Expand Up @@ -412,13 +412,12 @@
"We will create a Label called mal_label which has the same original structure as the label above\n",
"\n",
"Notes:\n",
"* Each label requires a valid feature schema id. We will assign it using our built in `assign_feature_schema_ids` method\n",
"* the NDJsonConverter takes in a list of labels"
]
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"id": "53aaf87b-114f-4b56-a417-8c7cddc1f532",
"metadata": {
"colab": {
Expand All @@ -427,64 +426,7 @@
"id": "53aaf87b-114f-4b56-a417-8c7cddc1f532",
"outputId": "43a3efd9-ee7e-4413-eee3-ef75f049ce96"
},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"[{'classifications': [],\n",
" 'dataRow': {'id': 'cl084bjrs63kn0z817dhcfbnn'},\n",
" 'point': {'x': 100.0, 'y': 100.0},\n",
" 'schemaId': 'cl084bk7j6wxa0za8807x3e8p',\n",
" 'uuid': '63183c21-04f5-48a4-a8a1-1bf962f2604d'},\n",
" {'bbox': {'height': 170.0, 'left': 30.0, 'top': 30.0, 'width': 170.0},\n",
" 'classifications': [],\n",
" 'dataRow': {'id': 'cl084bjrs63kn0z817dhcfbnn'},\n",
" 'schemaId': 'cl084bk7j6wx60za83y097zdy',\n",
" 'uuid': '7e43abb6-ef3b-4a1d-b560-ed4426ce3ce3'},\n",
" {'classifications': [],\n",
" 'dataRow': {'id': 'cl084bjrs63kn0z817dhcfbnn'},\n",
" 'line': [{'x': 60.0, 'y': 70.0},\n",
" {'x': 65.0, 'y': 100.0},\n",
" {'x': 80.0, 'y': 130.0},\n",
" {'x': 40.0, 'y': 200.0}],\n",
" 'schemaId': 'cl084bk7j6wx80za83ywp8xh7',\n",
" 'uuid': '4a07aa02-1857-4869-9831-a6bb9eb1eb3e'},\n",
" {'classifications': [],\n",
" 'dataRow': {'id': 'cl084bjrs63kn0z817dhcfbnn'},\n",
" 'polygon': [{'x': 100.0, 'y': 100.0},\n",
" {'x': 110.0, 'y': 110.0},\n",
" {'x': 130.0, 'y': 130.0},\n",
" {'x': 170.0, 'y': 170.0},\n",
" {'x': 220.0, 'y': 220.0},\n",
" {'x': 100.0, 'y': 100.0}],\n",
" 'schemaId': 'cl084bk7j6wxc0za8c6e63hfe',\n",
" 'uuid': '06085057-1b91-44ba-86ec-e1aca2e2fa16'},\n",
" {'classifications': [],\n",
" 'dataRow': {'id': 'cl084bjrs63kn0z817dhcfbnn'},\n",
" 'mask': {'colorRGB': (0, 0, 0),\n",
" 'instanceURI': 'https://storage.labelbox.com/cklgtitp0gi500732dgmg0p8l%2F4c5b600e-5b50-cf4a-df2b-28dbf1b1dddf-1?Expires=1646225060595&KeyName=labelbox-assets-key-3&Signature=aIZd6sj8UdiDUsPZBbTEtcNPWf4'},\n",
" 'schemaId': 'cl084bk7k6wxe0za89ovp34m0',\n",
" 'uuid': 'd5511578-283e-42b2-ac19-c25929103370'},\n",
" {'answer': 'the answer to the text question',\n",
" 'dataRow': {'id': 'cl084bjrs63kn0z817dhcfbnn'},\n",
" 'schemaId': 'cl084bk7k6wxg0za87wjndne2',\n",
" 'uuid': 'b8cecf98-a4ee-4424-b706-8eb9a9b4fb70'},\n",
" {'answer': [{'schemaId': 'cl084bk7k6wxj0za8hgxobmch'},\n",
" {'schemaId': 'cl084bk7k6wxl0za8hb07hrro'}],\n",
" 'dataRow': {'id': 'cl084bjrs63kn0z817dhcfbnn'},\n",
" 'schemaId': 'cl084bk7k6wxi0za8eglr5527',\n",
" 'uuid': 'd1651794-11b5-48bf-93d5-ccce6189fc72'},\n",
" {'answer': {'schemaId': 'cl084bk7k6wxr0za8fc5b4pkq'},\n",
" 'dataRow': {'id': 'cl084bjrs63kn0z817dhcfbnn'},\n",
" 'schemaId': 'cl084bk7k6wxo0za8fhdpa72y',\n",
" 'uuid': '6c4a6f53-ef1d-469f-a45f-778b7b4fccdb'}]"
]
},
"metadata": {},
"execution_count": 12
}
],
"outputs": [],
"source": [
"mal_label = Label(\n",
" data=image_data,\n",
Expand All @@ -496,8 +438,6 @@
"\n",
"label.add_url_to_masks(signing_function)\n",
"\n",
"mal_label.assign_feature_schema_ids(ontology_builder.from_project(mal_project))\n",
"\n",
"ndjson_labels = list(NDJsonConverter.serialize([mal_label]))\n",
"\n",
"ndjson_labels"
Expand All @@ -524,23 +464,23 @@
"execution_count": 14,
"id": "2a8f9e5f-eeeb-4cfa-9b97-a09495a64d41",
"metadata": {
"id": "2a8f9e5f-eeeb-4cfa-9b97-a09495a64d41",
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "2a8f9e5f-eeeb-4cfa-9b97-a09495a64d41",
"outputId": "6b2c938f-04eb-408a-c78e-a3258f765f4e"
},
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:labelbox.schema.annotation_import:Sleeping for 10 seconds...\n"
]
},
{
"output_type": "stream",
"name": "stdout",
"output_type": "stream",
"text": [
"Errors: []\n"
]
Expand Down Expand Up @@ -570,15 +510,12 @@
"id": "9d4fa318-7d08-4d98-b0ff-e2086814d75d"
},
"source": [
"Label import is very similar to model-assisted labeling. We will need to re-assign the feature schema before continuing, \n",
"but we can continue to use our NDJSonConverter\n",
"\n",
"We will create a Label called li_label which has the same original structure as the label above"
"Label import is very similar to model-assisted labeling. We will create a Label called li_label which has the same original structure as the label above"
]
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": null,
"id": "e8d4e99b-ad7e-48b9-8073-afb764d7c5b4",
"metadata": {
"colab": {
Expand All @@ -587,63 +524,7 @@
"id": "e8d4e99b-ad7e-48b9-8073-afb764d7c5b4",
"outputId": "384aea4d-9352-4192-c395-e39a44d5b6a4"
},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"[{'classifications': [],\n",
" 'dataRow': {'id': 'cl084bjrs63kn0z817dhcfbnn'},\n",
" 'point': {'x': 100.0, 'y': 100.0},\n",
" 'schemaId': 'cl084bl3447y80z7vgx5bf5i2',\n",
" 'uuid': '4ed2a3bb-2b14-4a7c-826b-1357f2376eef'},\n",
" {'bbox': {'height': 170.0, 'left': 30.0, 'top': 30.0, 'width': 170.0},\n",
" 'classifications': [],\n",
" 'dataRow': {'id': 'cl084bjrs63kn0z817dhcfbnn'},\n",
" 'schemaId': 'cl084bl3347y40z7v1gjv5d1i',\n",
" 'uuid': 'be904bbc-2ee6-4f41-bef9-6e40f8905596'},\n",
" {'classifications': [],\n",
" 'dataRow': {'id': 'cl084bjrs63kn0z817dhcfbnn'},\n",
" 'line': [{'x': 60.0, 'y': 70.0},\n",
" {'x': 65.0, 'y': 100.0},\n",
" {'x': 80.0, 'y': 130.0},\n",
" {'x': 40.0, 'y': 200.0}],\n",
" 'schemaId': 'cl084bl3347y60z7v0pjx0erv',\n",
" 'uuid': '5ced68ba-7c50-46a9-8ef5-26c8bceed485'},\n",
" {'classifications': [],\n",
" 'dataRow': {'id': 'cl084bjrs63kn0z817dhcfbnn'},\n",
" 'polygon': [{'x': 100.0, 'y': 100.0},\n",
" {'x': 110.0, 'y': 110.0},\n",
" {'x': 130.0, 'y': 130.0},\n",
" {'x': 170.0, 'y': 170.0},\n",
" {'x': 220.0, 'y': 220.0},\n",
" {'x': 100.0, 'y': 100.0}],\n",
" 'schemaId': 'cl084bl3447ya0z7v5nzlc9s9',\n",
" 'uuid': '442834a6-b25d-44b4-b550-60392d5f1efe'},\n",
" {'classifications': [],\n",
" 'dataRow': {'id': 'cl084bjrs63kn0z817dhcfbnn'},\n",
" 'mask': {'png': 'iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAAAAADmVT4XAAAAXElEQVR4nO3OMQEAAAzCMJh/0ZPBkxpo2my78R8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAPwt8BAVCFH74AAAAASUVORK5CYII='},\n",
" 'schemaId': 'cl084bl3447yc0z7v9m9r6auw',\n",
" 'uuid': '07b35d80-5f13-43cd-aea5-b9af850f10d1'},\n",
" {'answer': 'the answer to the text question',\n",
" 'dataRow': {'id': 'cl084bjrs63kn0z817dhcfbnn'},\n",
" 'schemaId': 'cl084bl3447ye0z7v8ii38i4z',\n",
" 'uuid': 'd7d8408e-a0b6-427a-a8b8-97c17304c2bb'},\n",
" {'answer': [{'schemaId': 'cl084bl3447yh0z7vhs3e0xyk'},\n",
" {'schemaId': 'cl084bl3447yj0z7vhjxkggz8'}],\n",
" 'dataRow': {'id': 'cl084bjrs63kn0z817dhcfbnn'},\n",
" 'schemaId': 'cl084bl3447yg0z7v2fn4ffqi',\n",
" 'uuid': '6c774a37-3e9d-46d2-ac0c-e1fc4a474adb'},\n",
" {'answer': {'schemaId': 'cl084bl3447yp0z7v371lbygl'},\n",
" 'dataRow': {'id': 'cl084bjrs63kn0z817dhcfbnn'},\n",
" 'schemaId': 'cl084bl3447ym0z7v18ezcbti',\n",
" 'uuid': 'b408102f-5940-4d55-9430-847e4e8b2d3d'}]"
]
},
"metadata": {},
"execution_count": 15
}
],
"outputs": [],
"source": [
"#for the purpose of this notebook, we will need to reset the schema ids of our checklist and radio answers\n",
"image_data = ImageData(uid=data_row.uid)\n",
Expand All @@ -659,8 +540,6 @@
" ]\n",
")\n",
"\n",
"li_label.assign_feature_schema_ids(ontology_builder.from_project(li_project))\n",
"\n",
"ndjson_labels = list(NDJsonConverter.serialize([li_label]))\n",
"\n",
"ndjson_labels"
Expand Down Expand Up @@ -695,15 +574,15 @@
},
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:labelbox.schema.annotation_import:Sleeping for 10 seconds...\n"
]
},
{
"output_type": "stream",
"name": "stdout",
"output_type": "stream",
"text": [
"Errors: []\n"
]
Expand All @@ -715,8 +594,13 @@
}
],
"metadata": {
"colab": {
"collapsed_sections": [],
"name": "image_mal.ipynb",
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3.9.2 64-bit",
"language": "python",
"name": "python3"
},
Expand All @@ -730,14 +614,14 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
"version": "3.9.2"
},
"colab": {
"name": "image_mal.ipynb",
"provenance": [],
"collapsed_sections": []
"vscode": {
"interpreter": {
"hash": "397704579725e15f5c7cb49fe5f0341eb7531c82d19f2c29d197e8b64ab5776b"
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}
}
Loading