From dea8b799c3502d9e4b8726320ef895c405b2e9dc Mon Sep 17 00:00:00 2001 From: Gabefire <33893811+Gabefire@users.noreply.github.com> Date: Thu, 21 Dec 2023 00:58:20 -0600 Subject: [PATCH 1/7] SN-100 added move_data_rows_to_task_queue in project notebook --- examples/basics/projects.ipynb | 112 ++++++++++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 3 deletions(-) diff --git a/examples/basics/projects.ipynb b/examples/basics/projects.ipynb index 28b570270..9309ed131 100644 --- a/examples/basics/projects.ipynb +++ b/examples/basics/projects.ipynb @@ -48,7 +48,7 @@ { "metadata": {}, "source": [ - "!pip install labelbox -q" + "!pip install -q \"labelbox[data]\"" ], "cell_type": "code", "outputs": [], @@ -58,6 +58,7 @@ "metadata": {}, "source": [ "import labelbox as lb\n", + "import labelbox.types as lb_types\n", "import os\n", "import uuid" ], @@ -154,6 +155,109 @@ "outputs": [], "execution_count": null }, + { + "metadata": {}, + "source": [ + "### Attach Ontology and Label Data Rows" + ], + "cell_type": "markdown" + }, + { + "metadata": {}, + "source": [ + "# Create normalized json with a radio classification\n", + "ontology_builder = lb.OntologyBuilder(classifications=[ # List of Classification objects\n", + " lb.Classification(class_type=lb.Classification.Type.RADIO,\n", + " name=\"radio_question\",\n", + " options=[\n", + " lb.Option(value=\"first_radio_answer\"),\n", + " lb.Option(value=\"second_radio_answer\")\n", + " ]),\n", + "])\n", + "# Creating an ontology\n", + "ontology = client.create_ontology(\"test-ontology\",\n", + " ontology_builder.asdict())" + ], + "cell_type": "code", + "outputs": [], + "execution_count": null + }, + { + "metadata": {}, + "source": [ + "# Attach ontology to project\n", + "project.setup_editor(ontology)" + ], + "cell_type": "code", + "outputs": [], + "execution_count": null + }, + { + "metadata": {}, + "source": [ + "# Create radio classification annotation for labels\n", + "radio_annotation = lb_types.ClassificationAnnotation(\n", + " name=\"radio_question\",\n", + " value=lb_types.Radio(answer=lb_types.ClassificationAnswer(\n", + " name=\"second_radio_answer\")))" + ], + "cell_type": "code", + "outputs": [], + "execution_count": null + }, + { + "metadata": {}, + "source": [ + "# Create labels\n", + "labels = []\n", + "for global_key in global_keys:\n", + " labels.append(lb_types.Label(data=lb_types.ImageData(global_key=global_key),\n", + " annotations=[radio_annotation]))\n", + "\n", + "# Upload labels for the data rows in project\n", + "upload_job = lb.LabelImport.create_from_objects(\n", + " client = client,\n", + " project_id = project.uid,\n", + " name=\"label_import_job\"+str(uuid.uuid4()),\n", + " labels=labels)\n", + "\n", + "upload_job.wait_until_done()" + ], + "cell_type": "code", + "outputs": [], + "execution_count": null + }, + { + "metadata": {}, + "source": [ + "### Move data rows in project to different task queues" + ], + "cell_type": "markdown" + }, + { + "metadata": {}, + "source": [ + "# Get list of task queues for project\n", + "task_queues = project.task_queues()\n", + "\n", + "for task_queue in task_queues:\n", + " print(task_queue)" + ], + "cell_type": "code", + "outputs": [], + "execution_count": null + }, + { + "metadata": {}, + "source": [ + "project.move_data_rows_to_task_queue(data_row_ids=lb.GlobalKeys(global_keys), #Provide a list of global keys\n", + " task_queue_id=task_queues[2].uid #Passing None moves data rows to \"Done\" task queue\n", + ")" + ], + "cell_type": "code", + "outputs": [], + "execution_count": null + }, { "metadata": {}, "source": [ @@ -180,14 +284,16 @@ { "metadata": {}, "source": [ - "### Delete" + "### Clean Up" ], "cell_type": "markdown" }, { "metadata": {}, "source": [ - "# project.delete()" + "# project.delete()\n", + "dataset.delete()\n", + "client.delete_unused_ontology(ontology.uid)" ], "cell_type": "code", "outputs": [], From f7a2c5fc64cd0826d7ed3e91a35da891b14e4618 Mon Sep 17 00:00:00 2001 From: Gabefire <33893811+Gabefire@users.noreply.github.com> Date: Thu, 21 Dec 2023 01:00:20 -0600 Subject: [PATCH 2/7] SN-100 fix clean up cell --- examples/basics/projects.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/basics/projects.ipynb b/examples/basics/projects.ipynb index 9309ed131..de9464f33 100644 --- a/examples/basics/projects.ipynb +++ b/examples/basics/projects.ipynb @@ -292,8 +292,8 @@ "metadata": {}, "source": [ "# project.delete()\n", - "dataset.delete()\n", - "client.delete_unused_ontology(ontology.uid)" + "# dataset.delete()\n", + "# client.delete_unused_ontology(ontology.uid)" ], "cell_type": "code", "outputs": [], From 54dbbc089c80f7a2694a2993531153b17e799f1e Mon Sep 17 00:00:00 2001 From: Gabefire <33893811+Gabefire@users.noreply.github.com> Date: Thu, 21 Dec 2023 01:17:27 -0600 Subject: [PATCH 3/7] SN-100 added error message to annotation imports --- examples/basics/projects.ipynb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/basics/projects.ipynb b/examples/basics/projects.ipynb index de9464f33..a8fec6b42 100644 --- a/examples/basics/projects.ipynb +++ b/examples/basics/projects.ipynb @@ -221,7 +221,9 @@ " name=\"label_import_job\"+str(uuid.uuid4()),\n", " labels=labels)\n", "\n", - "upload_job.wait_until_done()" + "upload_job.wait_until_done()\n", + "\n", + "print(f\"Errors: {upload_job.errors}\")" ], "cell_type": "code", "outputs": [], From 36b5670f8e92047b0ec883d4bb22800af1c0c731 Mon Sep 17 00:00:00 2001 From: Gabefire <33893811+Gabefire@users.noreply.github.com> Date: Thu, 21 Dec 2023 01:19:13 -0600 Subject: [PATCH 4/7] SN-100 fixed typo --- examples/basics/projects.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/basics/projects.ipynb b/examples/basics/projects.ipynb index a8fec6b42..eaa27e1cb 100644 --- a/examples/basics/projects.ipynb +++ b/examples/basics/projects.ipynb @@ -158,7 +158,7 @@ { "metadata": {}, "source": [ - "### Attach Ontology and Label Data Rows" + "### Attach ontology and label data rows" ], "cell_type": "markdown" }, From ea0c10395e05cf570f6c8e1b9d5212e27db13c71 Mon Sep 17 00:00:00 2001 From: Gabefire <33893811+Gabefire@users.noreply.github.com> Date: Tue, 2 Jan 2024 15:03:10 -0600 Subject: [PATCH 5/7] fixed MAL import labels --- examples/basics/projects.ipynb | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/examples/basics/projects.ipynb b/examples/basics/projects.ipynb index eaa27e1cb..2ad3d7006 100644 --- a/examples/basics/projects.ipynb +++ b/examples/basics/projects.ipynb @@ -192,19 +192,6 @@ "outputs": [], "execution_count": null }, - { - "metadata": {}, - "source": [ - "# Create radio classification annotation for labels\n", - "radio_annotation = lb_types.ClassificationAnnotation(\n", - " name=\"radio_question\",\n", - " value=lb_types.Radio(answer=lb_types.ClassificationAnswer(\n", - " name=\"second_radio_answer\")))" - ], - "cell_type": "code", - "outputs": [], - "execution_count": null - }, { "metadata": {}, "source": [ @@ -212,7 +199,13 @@ "labels = []\n", "for global_key in global_keys:\n", " labels.append(lb_types.Label(data=lb_types.ImageData(global_key=global_key),\n", - " annotations=[radio_annotation]))\n", + " annotations=[\n", + " # Create radio classification annotation for labels\n", + " lb_types.ClassificationAnnotation(\n", + " name=\"radio_question\",\n", + " value=lb_types.Radio(answer=lb_types.ClassificationAnswer(\n", + " name=\"second_radio_answer\")))\n", + " ]))\n", "\n", "# Upload labels for the data rows in project\n", "upload_job = lb.LabelImport.create_from_objects(\n", From 2d8851304ed228a4589cb13afe29e904c1f7c9a4 Mon Sep 17 00:00:00 2001 From: Gabefire <33893811+Gabefire@users.noreply.github.com> Date: Tue, 9 Jan 2024 21:13:43 -0700 Subject: [PATCH 6/7] made changes to markdown --- examples/basics/projects.ipynb | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/examples/basics/projects.ipynb b/examples/basics/projects.ipynb index 2ad3d7006..f729501a2 100644 --- a/examples/basics/projects.ipynb +++ b/examples/basics/projects.ipynb @@ -158,7 +158,16 @@ { "metadata": {}, "source": [ - "### Attach ontology and label data rows" + "### Attach ontology and label data rows\n", + "\n", + "In this section, we are creating an ontology to attach to a project and creating labels to import as ground truths. We need this setup to demonstrate other methods later in the demo. For more information, please reference our [Ontology](https://docs.labelbox.com/reference/ontology) and [Import Image Annotation](https://docs.labelbox.com/reference/import-image-annotations) development guides." + ], + "cell_type": "markdown" + }, + { + "metadata": {}, + "source": [ + "Create your ontology" ], "cell_type": "markdown" }, @@ -185,13 +194,27 @@ { "metadata": {}, "source": [ - "# Attach ontology to project\n", + "Attach ontology to project" + ], + "cell_type": "markdown" + }, + { + "metadata": {}, + "source": [ + "\n", "project.setup_editor(ontology)" ], "cell_type": "code", "outputs": [], "execution_count": null }, + { + "metadata": {}, + "source": [ + "Create labels and upload them to project as ground truths" + ], + "cell_type": "markdown" + }, { "metadata": {}, "source": [ From 0b602eef8bcc2ec4ed3fb55d4272f7d4b7e25947 Mon Sep 17 00:00:00 2001 From: Gabefire <33893811+Gabefire@users.noreply.github.com> Date: Tue, 9 Jan 2024 21:18:14 -0700 Subject: [PATCH 7/7] made changes to markdown --- examples/basics/projects.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/basics/projects.ipynb b/examples/basics/projects.ipynb index f729501a2..239501de0 100644 --- a/examples/basics/projects.ipynb +++ b/examples/basics/projects.ipynb @@ -59,7 +59,6 @@ "source": [ "import labelbox as lb\n", "import labelbox.types as lb_types\n", - "import os\n", "import uuid" ], "cell_type": "code", @@ -77,8 +76,9 @@ { "metadata": {}, "source": [ - "# Add your api key\n", + "# Add your API key\n", "API_KEY = \"\"\n", + "# To get your API key go to: Workspace settings -> API -> Create API Key\n", "client = lb.Client(api_key=API_KEY)" ], "cell_type": "code",