From 45942f775b8c65a54221d006ba3dc69d77f2601d Mon Sep 17 00:00:00 2001
From: Gabefire <33893811+Gabefire@users.noreply.github.com>
Date: Fri, 31 May 2024 18:21:40 -0500
Subject: [PATCH 1/4] fix bug
---
examples/basics/quick_start.ipynb | 276 +++++++++++++++++++++++-------
1 file changed, 215 insertions(+), 61 deletions(-)
diff --git a/examples/basics/quick_start.ipynb b/examples/basics/quick_start.ipynb
index 4cc621743..8ba18fbbe 100644
--- a/examples/basics/quick_start.ipynb
+++ b/examples/basics/quick_start.ipynb
@@ -1,18 +1,16 @@
{
- "nbformat": 4,
- "nbformat_minor": 2,
- "metadata": {},
"cells": [
{
+ "cell_type": "markdown",
"metadata": {},
"source": [
- "
",
- " ",
+ " | \n",
+ " \n",
" | \n"
- ],
- "cell_type": "markdown"
+ ]
},
{
+ "cell_type": "markdown",
"metadata": {},
"source": [
"\n",
@@ -24,10 +22,10 @@
" \n",
" | "
- ],
- "cell_type": "markdown"
+ ]
},
{
+ "cell_type": "markdown",
"metadata": {},
"source": [
"# Quick Start\n",
@@ -43,48 +41,67 @@
"5. Exporting our image data row from our project\n",
"\n",
"This notebook is geared towards new users of Labelbox-Python SDK."
- ],
- "cell_type": "markdown"
+ ]
},
{
+ "cell_type": "markdown",
"metadata": {},
"source": [
"## Setup\n",
"\n",
"We first need to install the `labelbox` library and then import the SDK module. It is recommended to install `\"labelbox[data]\"` over `labelbox` to obtain all the correct dependencies. We will also be importing the Python `uuid` library to generate universal unique IDs for the variety of objects that will be created with this notebook."
- ],
- "cell_type": "markdown"
+ ]
},
{
- "metadata": {},
- "source": "%pip install -q \"labelbox[data]\"",
"cell_type": "code",
- "outputs": [],
- "execution_count": null
+ "execution_count": 4,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.0.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.0\u001b[0m\n",
+ "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
+ "Note: you may need to restart the kernel to use updated packages.\n"
+ ]
+ }
+ ],
+ "source": [
+ "%pip install -q \"labelbox[data]\""
+ ]
},
{
- "metadata": {},
- "source": "import labelbox as lb\nimport uuid",
"cell_type": "code",
+ "execution_count": 5,
+ "metadata": {},
"outputs": [],
- "execution_count": null
+ "source": [
+ "import labelbox as lb\n",
+ "import uuid"
+ ]
},
{
+ "cell_type": "markdown",
"metadata": {},
"source": [
"## API Key and Client\n",
"Provide a valid API key below to connect to the Labelbox client properly. For more information, please review the [Create API Key](https://docs.labelbox.com/reference/create-api-key) guide."
- ],
- "cell_type": "markdown"
+ ]
},
{
- "metadata": {},
- "source": "API_KEY = None\nclient = lb.Client(api_key=API_KEY)",
"cell_type": "code",
+ "execution_count": 6,
+ "metadata": {},
"outputs": [],
- "execution_count": null
+ "source": [
+ "API_KEY = \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJjbG9vcmRpaGUwMDkyMDcza2Nvcm5jajdnIiwib3JnYW5pemF0aW9uSWQiOiJjbG9vcmRpZ3cwMDkxMDcza2M2cG9oeWFiIiwiYXBpS2V5SWQiOiJjbHc2NzFqOGowNHZsMDd6ZTczemEwdjJuIiwic2VjcmV0IjoiZjExOWVhZDk3MGVkM2ZhMGYyZjkzNGU2ZTFhOWMxMDYiLCJpYXQiOjE3MTU2NzkxMDYsImV4cCI6MjM0NjgzMTEwNn0.3lSmBkOVmbjIltAN1umf3H_pJ_HsptIhxs6v7kv1-Dc\"\n",
+ "client = lb.Client(api_key=API_KEY)"
+ ]
},
{
+ "cell_type": "markdown",
"metadata": {},
"source": [
"## Step 1: Create Dataset and Import Data Row\n",
@@ -93,17 +110,45 @@
"\n",
"- Data rows are internal representations of an asset in Labelbox. A data row contains the asset to be labeled and all of the relevant information about that asset\n",
"- A dataset is a collection of data rows imported into Labelbox. They live inside the [_Catalog_](https://docs.labelbox.com/docs/catalog-overview) section of Labelbox."
- ],
- "cell_type": "markdown"
+ ]
},
{
- "metadata": {},
- "source": "# Create dataset from client\ndataset = client.create_dataset(name=\"Quick Start Example Dataset\")\n\nglobal_key = str(uuid.uuid4()) # Unique user specified ID\n\n# Data row structure\nimage_data_rows = [{\n \"row_data\":\n \"https://storage.googleapis.com/labelbox-datasets/image_sample_data/2560px-Kitano_Street_Kobe01s5s4110.jpeg\",\n \"global_key\":\n global_key,\n \"media_type\":\n \"IMAGE\",\n}]\n\n# Bulk import data row\ntask = dataset.create_data_rows(image_data_rows) # List of data rows\ntask.wait_till_done()\nprint(task.errors) # Print any errors",
"cell_type": "code",
- "outputs": [],
- "execution_count": null
+ "execution_count": 7,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "None\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Create dataset from client\n",
+ "dataset = client.create_dataset(name=\"Quick Start Example Dataset\")\n",
+ "\n",
+ "global_key = str(uuid.uuid4()) # Unique user specified ID\n",
+ "\n",
+ "# Data row structure\n",
+ "image_data_rows = [{\n",
+ " \"row_data\":\n",
+ " \"https://storage.googleapis.com/labelbox-datasets/image_sample_data/2560px-Kitano_Street_Kobe01s5s4110.jpeg\",\n",
+ " \"global_key\":\n",
+ " global_key,\n",
+ " \"media_type\":\n",
+ " \"IMAGE\",\n",
+ "}]\n",
+ "\n",
+ "# Bulk import data row\n",
+ "task = dataset.create_data_rows(image_data_rows) # List of data rows\n",
+ "task.wait_till_done()\n",
+ "print(task.errors) # Print any errors"
+ ]
},
{
+ "cell_type": "markdown",
"metadata": {},
"source": [
"## Step 2: Creating an Ontology\n",
@@ -111,17 +156,49 @@
"Before we send our data row to a labeling project we first must create an ontology. In the example below we will be creating a simple ontology with a bounding box tool and a checklist classification feature. For more information, visit the [ontology section](https://docs.labelbox.com/reference/ontology) inside our developer guides. \n",
"\n",
"* An ontology is a collection of annotations and their relationships (also known as a taxonomy). Ontologies can be reused across different projects. It is essential for data labeling, model training, and evaluation. Created ontologies with there associated features are located inside the _Schema_ section within Labelbox."
- ],
- "cell_type": "markdown"
+ ]
},
{
- "metadata": {},
- "source": "# Bounding box feature\nobject_features = [\n lb.Tool(\n tool=lb.Tool.Type.BBOX,\n name=\"regulatory-sign\",\n color=\"#ff0000\",\n )\n]\n\n# Checklist feature\nclassification_features = [\n lb.Classification(\n class_type=lb.Classification.Type.CHECKLIST,\n name=\"Quality Issues\",\n options=[\n lb.Option(value=\"blurry\", label=\"Blurry\"),\n lb.Option(value=\"distorted\", label=\"Distorted\"),\n ],\n )\n]\n\n# Builder function\nontology_builder = lb.OntologyBuilder(tools=object_features,\n classifications=classification_features)\n\n# Create ontology\nontology = client.create_ontology(\n \"Ontology from new features\",\n ontology_builder.asdict(),\n media_type=lb.MediaType.Image,\n)",
"cell_type": "code",
+ "execution_count": 8,
+ "metadata": {},
"outputs": [],
- "execution_count": null
+ "source": [
+ "# Bounding box feature\n",
+ "object_features = [\n",
+ " lb.Tool(\n",
+ " tool=lb.Tool.Type.BBOX,\n",
+ " name=\"regulatory-sign\",\n",
+ " color=\"#ff0000\",\n",
+ " )\n",
+ "]\n",
+ "\n",
+ "# Checklist feature\n",
+ "classification_features = [\n",
+ " lb.Classification(\n",
+ " class_type=lb.Classification.Type.CHECKLIST,\n",
+ " name=\"Quality Issues\",\n",
+ " options=[\n",
+ " lb.Option(value=\"blurry\", label=\"Blurry\"),\n",
+ " lb.Option(value=\"distorted\", label=\"Distorted\"),\n",
+ " ],\n",
+ " )\n",
+ "]\n",
+ "\n",
+ "# Builder function\n",
+ "ontology_builder = lb.OntologyBuilder(tools=object_features,\n",
+ " classifications=classification_features)\n",
+ "\n",
+ "# Create ontology\n",
+ "ontology = client.create_ontology(\n",
+ " \"Ontology from new features\",\n",
+ " ontology_builder.asdict(),\n",
+ " media_type=lb.MediaType.Image,\n",
+ ")"
+ ]
},
{
+ "cell_type": "markdown",
"metadata": {},
"source": [
"## Step 3: Creating a Project and Attaching our Ontology\n",
@@ -129,17 +206,26 @@
"Now that we have made our ontology, we are ready to create a project where we can label our data row.\n",
"\n",
"* Projects are labeling environments in Labelbox similar to a factory assembly line for producing annotations. The initial state of the project can start with raw data, pre-existing ground truth, or pre-labeled data."
- ],
- "cell_type": "markdown"
+ ]
},
{
- "metadata": {},
- "source": "# Create a new project\nproject = client.create_project(\n name=\"Quick Start Example Project\",\n media_type=lb.MediaType.Image,\n)\n\n# Attach created ontology\nproject.setup_editor(ontology)",
"cell_type": "code",
+ "execution_count": 9,
+ "metadata": {},
"outputs": [],
- "execution_count": null
+ "source": [
+ "# Create a new project\n",
+ "project = client.create_project(\n",
+ " name=\"Quick Start Example Project\",\n",
+ " media_type=lb.MediaType.Image,\n",
+ ")\n",
+ "\n",
+ "# Attach created ontology\n",
+ "project.setup_editor(ontology)"
+ ]
},
{
+ "cell_type": "markdown",
"metadata": {},
"source": [
"## Step 4: Sending our Data Row to our Project by Creating a Batch\n",
@@ -147,49 +233,117 @@
"With our project created, we can send our data rows by creating a batch. Our data rows will start in the initial labeling queue, where labelers are able to annotate our data row.\n",
"\n",
"* A batch is a curated selection of data rows you can send to a project for labeling. You can create a batch with a combination of data rows within any dataset. For more information on creating batches, review the [batches section](https://docs.labelbox.com/reference/batch#create-a-batch) of our developer guides."
- ],
- "cell_type": "markdown"
+ ]
},
{
- "metadata": {},
- "source": "project.create_batch(\n name=\"Quick Start Example Batch\" + str(uuid.uuid4()),\n global_keys=[\n global_key\n ], # Global key we used earlier in this guide to create our dataset\n priority=5,\n)",
"cell_type": "code",
- "outputs": [],
- "execution_count": null
+ "execution_count": 10,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 10,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "project.create_batch(\n",
+ " name=\"Quick Start Example Batch\" + str(uuid.uuid4()),\n",
+ " global_keys=[\n",
+ " global_key\n",
+ " ], # Global key we used earlier in this guide to create our dataset\n",
+ " priority=5,\n",
+ ")"
+ ]
},
{
+ "cell_type": "markdown",
"metadata": {},
"source": [
"## Step 5: Exporting from our Project\n",
"\n",
- "We have now successfully set up a project for labeling using only the SDK! \ud83d\ude80 \n",
+ "We have now successfully set up a project for labeling using only the SDK! 🚀 \n",
"\n",
"From here, you can either label our data row directly inside the [labeling queue](https://docs.labelbox.com/docs/labeling-queue) or [import annotations](https://docs.labelbox.com/reference/import-image-annotations) directly through our SDK. Below we will demonstrate the final step of this guide by exporting from our project. Since we did not label any data rows or import annotations within this guide, no labels will be presented on our data row. For a full overview of exporting, visit our [export overview](https://docs.labelbox.com/reference/label-export) developer guide."
- ],
- "cell_type": "markdown"
+ ]
},
{
- "metadata": {},
- "source": "# Start export from project\nexport_task = project.export()\nexport_task.wait_till_done()\n\n# Conditional if task has errors\nif export_task.has_errors():\n export_task.get_buffered_stream(stream_type=lb.StreamType.ERRORS).start(\n stream_handler=lambda error: print(error))\n\n# Start export stream\nstream = export_task.get_buffered_stream()\n\n# Iterate through data rows\nfor data_row in stream:\n print(data_row.json)",
"cell_type": "code",
- "outputs": [],
- "execution_count": null
+ "execution_count": 12,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "{'data_row': {'id': 'clwvb31pp0inu07321a6egvtz', 'global_key': 'c740d811-545b-471b-9e3d-9bf23c27b959', 'row_data': 'https://storage.googleapis.com/labelbox-datasets/image_sample_data/2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'media_attributes': {'height': 1707, 'width': 2560, 'asset_type': 'image', 'mime_type': 'image/jpeg', 'exif_rotation': '1'}, 'projects': {'clwvb3dad02zz07ww8km7h1tf': {'name': 'Quick Start Example Project', 'labels': [], 'project_tags': []}}}\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Start export from project\n",
+ "export_task = project.export()\n",
+ "export_task.wait_till_done()\n",
+ "\n",
+ "# Conditional if task has errors\n",
+ "if export_task.has_errors():\n",
+ " export_task.get_buffered_stream(stream_type=lb.StreamType.ERRORS).start(\n",
+ " stream_handler=lambda error: print(error))\n",
+ "\n",
+ "if export_task.has_result():\n",
+ " # Start export stream\n",
+ " stream = export_task.get_buffered_stream()\n",
+ "\n",
+ " # Iterate through data rows\n",
+ " for data_row in stream:\n",
+ " print(data_row.json)"
+ ]
},
{
+ "cell_type": "markdown",
"metadata": {},
"source": [
"## Clean Up\n",
"\n",
"This section serves as an optional clean-up step to delete the Labelbox assets created within this guide. You will need to uncomment the delete methods shown."
- ],
- "cell_type": "markdown"
+ ]
},
{
- "metadata": {},
- "source": "# project.delete()\n# client.delete_unused_ontology(ontology.uid)\n# dataset.delete()",
"cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
"outputs": [],
- "execution_count": null
+ "source": [
+ "# project.delete()\n",
+ "# client.delete_unused_ontology(ontology.uid)\n",
+ "# dataset.delete()"
+ ]
}
- ]
-}
\ No newline at end of file
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.10.13"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
From 0895751b2fe6e3baed220fb1f72314a9b56d59d7 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Fri, 31 May 2024 23:24:05 +0000
Subject: [PATCH 2/4] :art: Cleaned
---
examples/basics/quick_start.ipynb | 276 +++++++-----------------------
1 file changed, 61 insertions(+), 215 deletions(-)
diff --git a/examples/basics/quick_start.ipynb b/examples/basics/quick_start.ipynb
index 8ba18fbbe..598a61458 100644
--- a/examples/basics/quick_start.ipynb
+++ b/examples/basics/quick_start.ipynb
@@ -1,16 +1,18 @@
{
+ "nbformat": 4,
+ "nbformat_minor": 2,
+ "metadata": {},
"cells": [
{
- "cell_type": "markdown",
"metadata": {},
"source": [
- "\n",
- " \n",
+ " | ",
+ " ",
" | \n"
- ]
+ ],
+ "cell_type": "markdown"
},
{
- "cell_type": "markdown",
"metadata": {},
"source": [
"\n",
@@ -22,10 +24,10 @@
" \n",
" | "
- ]
+ ],
+ "cell_type": "markdown"
},
{
- "cell_type": "markdown",
"metadata": {},
"source": [
"# Quick Start\n",
@@ -41,67 +43,48 @@
"5. Exporting our image data row from our project\n",
"\n",
"This notebook is geared towards new users of Labelbox-Python SDK."
- ]
+ ],
+ "cell_type": "markdown"
},
{
- "cell_type": "markdown",
"metadata": {},
"source": [
"## Setup\n",
"\n",
"We first need to install the `labelbox` library and then import the SDK module. It is recommended to install `\"labelbox[data]\"` over `labelbox` to obtain all the correct dependencies. We will also be importing the Python `uuid` library to generate universal unique IDs for the variety of objects that will be created with this notebook."
- ]
+ ],
+ "cell_type": "markdown"
},
{
- "cell_type": "code",
- "execution_count": 4,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "\n",
- "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.0.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.0\u001b[0m\n",
- "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
- "Note: you may need to restart the kernel to use updated packages.\n"
- ]
- }
- ],
- "source": [
- "%pip install -q \"labelbox[data]\""
- ]
+ "source": "%pip install -q \"labelbox[data]\"",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
},
{
- "cell_type": "code",
- "execution_count": 5,
"metadata": {},
+ "source": "import labelbox as lb\nimport uuid",
+ "cell_type": "code",
"outputs": [],
- "source": [
- "import labelbox as lb\n",
- "import uuid"
- ]
+ "execution_count": null
},
{
- "cell_type": "markdown",
"metadata": {},
"source": [
"## API Key and Client\n",
"Provide a valid API key below to connect to the Labelbox client properly. For more information, please review the [Create API Key](https://docs.labelbox.com/reference/create-api-key) guide."
- ]
+ ],
+ "cell_type": "markdown"
},
{
- "cell_type": "code",
- "execution_count": 6,
"metadata": {},
+ "source": "API_KEY = \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJjbG9vcmRpaGUwMDkyMDcza2Nvcm5jajdnIiwib3JnYW5pemF0aW9uSWQiOiJjbG9vcmRpZ3cwMDkxMDcza2M2cG9oeWFiIiwiYXBpS2V5SWQiOiJjbHc2NzFqOGowNHZsMDd6ZTczemEwdjJuIiwic2VjcmV0IjoiZjExOWVhZDk3MGVkM2ZhMGYyZjkzNGU2ZTFhOWMxMDYiLCJpYXQiOjE3MTU2NzkxMDYsImV4cCI6MjM0NjgzMTEwNn0.3lSmBkOVmbjIltAN1umf3H_pJ_HsptIhxs6v7kv1-Dc\"\nclient = lb.Client(api_key=API_KEY)",
+ "cell_type": "code",
"outputs": [],
- "source": [
- "API_KEY = \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJjbG9vcmRpaGUwMDkyMDcza2Nvcm5jajdnIiwib3JnYW5pemF0aW9uSWQiOiJjbG9vcmRpZ3cwMDkxMDcza2M2cG9oeWFiIiwiYXBpS2V5SWQiOiJjbHc2NzFqOGowNHZsMDd6ZTczemEwdjJuIiwic2VjcmV0IjoiZjExOWVhZDk3MGVkM2ZhMGYyZjkzNGU2ZTFhOWMxMDYiLCJpYXQiOjE3MTU2NzkxMDYsImV4cCI6MjM0NjgzMTEwNn0.3lSmBkOVmbjIltAN1umf3H_pJ_HsptIhxs6v7kv1-Dc\"\n",
- "client = lb.Client(api_key=API_KEY)"
- ]
+ "execution_count": null
},
{
- "cell_type": "markdown",
"metadata": {},
"source": [
"## Step 1: Create Dataset and Import Data Row\n",
@@ -110,45 +93,17 @@
"\n",
"- Data rows are internal representations of an asset in Labelbox. A data row contains the asset to be labeled and all of the relevant information about that asset\n",
"- A dataset is a collection of data rows imported into Labelbox. They live inside the [_Catalog_](https://docs.labelbox.com/docs/catalog-overview) section of Labelbox."
- ]
+ ],
+ "cell_type": "markdown"
},
{
- "cell_type": "code",
- "execution_count": 7,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "None\n"
- ]
- }
- ],
- "source": [
- "# Create dataset from client\n",
- "dataset = client.create_dataset(name=\"Quick Start Example Dataset\")\n",
- "\n",
- "global_key = str(uuid.uuid4()) # Unique user specified ID\n",
- "\n",
- "# Data row structure\n",
- "image_data_rows = [{\n",
- " \"row_data\":\n",
- " \"https://storage.googleapis.com/labelbox-datasets/image_sample_data/2560px-Kitano_Street_Kobe01s5s4110.jpeg\",\n",
- " \"global_key\":\n",
- " global_key,\n",
- " \"media_type\":\n",
- " \"IMAGE\",\n",
- "}]\n",
- "\n",
- "# Bulk import data row\n",
- "task = dataset.create_data_rows(image_data_rows) # List of data rows\n",
- "task.wait_till_done()\n",
- "print(task.errors) # Print any errors"
- ]
+ "source": "# Create dataset from client\ndataset = client.create_dataset(name=\"Quick Start Example Dataset\")\n\nglobal_key = str(uuid.uuid4()) # Unique user specified ID\n\n# Data row structure\nimage_data_rows = [{\n \"row_data\":\n \"https://storage.googleapis.com/labelbox-datasets/image_sample_data/2560px-Kitano_Street_Kobe01s5s4110.jpeg\",\n \"global_key\":\n global_key,\n \"media_type\":\n \"IMAGE\",\n}]\n\n# Bulk import data row\ntask = dataset.create_data_rows(image_data_rows) # List of data rows\ntask.wait_till_done()\nprint(task.errors) # Print any errors",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
},
{
- "cell_type": "markdown",
"metadata": {},
"source": [
"## Step 2: Creating an Ontology\n",
@@ -156,49 +111,17 @@
"Before we send our data row to a labeling project we first must create an ontology. In the example below we will be creating a simple ontology with a bounding box tool and a checklist classification feature. For more information, visit the [ontology section](https://docs.labelbox.com/reference/ontology) inside our developer guides. \n",
"\n",
"* An ontology is a collection of annotations and their relationships (also known as a taxonomy). Ontologies can be reused across different projects. It is essential for data labeling, model training, and evaluation. Created ontologies with there associated features are located inside the _Schema_ section within Labelbox."
- ]
+ ],
+ "cell_type": "markdown"
},
{
- "cell_type": "code",
- "execution_count": 8,
"metadata": {},
+ "source": "# Bounding box feature\nobject_features = [\n lb.Tool(\n tool=lb.Tool.Type.BBOX,\n name=\"regulatory-sign\",\n color=\"#ff0000\",\n )\n]\n\n# Checklist feature\nclassification_features = [\n lb.Classification(\n class_type=lb.Classification.Type.CHECKLIST,\n name=\"Quality Issues\",\n options=[\n lb.Option(value=\"blurry\", label=\"Blurry\"),\n lb.Option(value=\"distorted\", label=\"Distorted\"),\n ],\n )\n]\n\n# Builder function\nontology_builder = lb.OntologyBuilder(tools=object_features,\n classifications=classification_features)\n\n# Create ontology\nontology = client.create_ontology(\n \"Ontology from new features\",\n ontology_builder.asdict(),\n media_type=lb.MediaType.Image,\n)",
+ "cell_type": "code",
"outputs": [],
- "source": [
- "# Bounding box feature\n",
- "object_features = [\n",
- " lb.Tool(\n",
- " tool=lb.Tool.Type.BBOX,\n",
- " name=\"regulatory-sign\",\n",
- " color=\"#ff0000\",\n",
- " )\n",
- "]\n",
- "\n",
- "# Checklist feature\n",
- "classification_features = [\n",
- " lb.Classification(\n",
- " class_type=lb.Classification.Type.CHECKLIST,\n",
- " name=\"Quality Issues\",\n",
- " options=[\n",
- " lb.Option(value=\"blurry\", label=\"Blurry\"),\n",
- " lb.Option(value=\"distorted\", label=\"Distorted\"),\n",
- " ],\n",
- " )\n",
- "]\n",
- "\n",
- "# Builder function\n",
- "ontology_builder = lb.OntologyBuilder(tools=object_features,\n",
- " classifications=classification_features)\n",
- "\n",
- "# Create ontology\n",
- "ontology = client.create_ontology(\n",
- " \"Ontology from new features\",\n",
- " ontology_builder.asdict(),\n",
- " media_type=lb.MediaType.Image,\n",
- ")"
- ]
+ "execution_count": null
},
{
- "cell_type": "markdown",
"metadata": {},
"source": [
"## Step 3: Creating a Project and Attaching our Ontology\n",
@@ -206,26 +129,17 @@
"Now that we have made our ontology, we are ready to create a project where we can label our data row.\n",
"\n",
"* Projects are labeling environments in Labelbox similar to a factory assembly line for producing annotations. The initial state of the project can start with raw data, pre-existing ground truth, or pre-labeled data."
- ]
+ ],
+ "cell_type": "markdown"
},
{
- "cell_type": "code",
- "execution_count": 9,
"metadata": {},
+ "source": "# Create a new project\nproject = client.create_project(\n name=\"Quick Start Example Project\",\n media_type=lb.MediaType.Image,\n)\n\n# Attach created ontology\nproject.setup_editor(ontology)",
+ "cell_type": "code",
"outputs": [],
- "source": [
- "# Create a new project\n",
- "project = client.create_project(\n",
- " name=\"Quick Start Example Project\",\n",
- " media_type=lb.MediaType.Image,\n",
- ")\n",
- "\n",
- "# Attach created ontology\n",
- "project.setup_editor(ontology)"
- ]
+ "execution_count": null
},
{
- "cell_type": "markdown",
"metadata": {},
"source": [
"## Step 4: Sending our Data Row to our Project by Creating a Batch\n",
@@ -233,117 +147,49 @@
"With our project created, we can send our data rows by creating a batch. Our data rows will start in the initial labeling queue, where labelers are able to annotate our data row.\n",
"\n",
"* A batch is a curated selection of data rows you can send to a project for labeling. You can create a batch with a combination of data rows within any dataset. For more information on creating batches, review the [batches section](https://docs.labelbox.com/reference/batch#create-a-batch) of our developer guides."
- ]
+ ],
+ "cell_type": "markdown"
},
{
- "cell_type": "code",
- "execution_count": 10,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- ""
- ]
- },
- "execution_count": 10,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "project.create_batch(\n",
- " name=\"Quick Start Example Batch\" + str(uuid.uuid4()),\n",
- " global_keys=[\n",
- " global_key\n",
- " ], # Global key we used earlier in this guide to create our dataset\n",
- " priority=5,\n",
- ")"
- ]
+ "source": "project.create_batch(\n name=\"Quick Start Example Batch\" + str(uuid.uuid4()),\n global_keys=[\n global_key\n ], # Global key we used earlier in this guide to create our dataset\n priority=5,\n)",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
},
{
- "cell_type": "markdown",
"metadata": {},
"source": [
"## Step 5: Exporting from our Project\n",
"\n",
- "We have now successfully set up a project for labeling using only the SDK! 🚀 \n",
+ "We have now successfully set up a project for labeling using only the SDK! \ud83d\ude80 \n",
"\n",
"From here, you can either label our data row directly inside the [labeling queue](https://docs.labelbox.com/docs/labeling-queue) or [import annotations](https://docs.labelbox.com/reference/import-image-annotations) directly through our SDK. Below we will demonstrate the final step of this guide by exporting from our project. Since we did not label any data rows or import annotations within this guide, no labels will be presented on our data row. For a full overview of exporting, visit our [export overview](https://docs.labelbox.com/reference/label-export) developer guide."
- ]
+ ],
+ "cell_type": "markdown"
},
{
- "cell_type": "code",
- "execution_count": 12,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "{'data_row': {'id': 'clwvb31pp0inu07321a6egvtz', 'global_key': 'c740d811-545b-471b-9e3d-9bf23c27b959', 'row_data': 'https://storage.googleapis.com/labelbox-datasets/image_sample_data/2560px-Kitano_Street_Kobe01s5s4110.jpeg'}, 'media_attributes': {'height': 1707, 'width': 2560, 'asset_type': 'image', 'mime_type': 'image/jpeg', 'exif_rotation': '1'}, 'projects': {'clwvb3dad02zz07ww8km7h1tf': {'name': 'Quick Start Example Project', 'labels': [], 'project_tags': []}}}\n"
- ]
- }
- ],
- "source": [
- "# Start export from project\n",
- "export_task = project.export()\n",
- "export_task.wait_till_done()\n",
- "\n",
- "# Conditional if task has errors\n",
- "if export_task.has_errors():\n",
- " export_task.get_buffered_stream(stream_type=lb.StreamType.ERRORS).start(\n",
- " stream_handler=lambda error: print(error))\n",
- "\n",
- "if export_task.has_result():\n",
- " # Start export stream\n",
- " stream = export_task.get_buffered_stream()\n",
- "\n",
- " # Iterate through data rows\n",
- " for data_row in stream:\n",
- " print(data_row.json)"
- ]
+ "source": "# Start export from project\nexport_task = project.export()\nexport_task.wait_till_done()\n\n# Conditional if task has errors\nif export_task.has_errors():\n export_task.get_buffered_stream(stream_type=lb.StreamType.ERRORS).start(\n stream_handler=lambda error: print(error))\n\nif export_task.has_result():\n # Start export stream\n stream = export_task.get_buffered_stream()\n\n # Iterate through data rows\n for data_row in stream:\n print(data_row.json)",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
},
{
- "cell_type": "markdown",
"metadata": {},
"source": [
"## Clean Up\n",
"\n",
"This section serves as an optional clean-up step to delete the Labelbox assets created within this guide. You will need to uncomment the delete methods shown."
- ]
+ ],
+ "cell_type": "markdown"
},
{
- "cell_type": "code",
- "execution_count": null,
"metadata": {},
+ "source": "# project.delete()\n# client.delete_unused_ontology(ontology.uid)\n# dataset.delete()",
+ "cell_type": "code",
"outputs": [],
- "source": [
- "# project.delete()\n",
- "# client.delete_unused_ontology(ontology.uid)\n",
- "# dataset.delete()"
- ]
+ "execution_count": null
}
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.10.13"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
-}
+ ]
+}
\ No newline at end of file
From dd067c3efa50689cf26fd355f2d6aaaab0084e2c Mon Sep 17 00:00:00 2001
From: Gabe <33893811+Gabefire@users.noreply.github.com>
Date: Fri, 31 May 2024 18:27:04 -0500
Subject: [PATCH 3/4] Remove api key and rotated
---
examples/basics/quick_start.ipynb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/examples/basics/quick_start.ipynb b/examples/basics/quick_start.ipynb
index 598a61458..bf8b109d5 100644
--- a/examples/basics/quick_start.ipynb
+++ b/examples/basics/quick_start.ipynb
@@ -79,7 +79,7 @@
},
{
"metadata": {},
- "source": "API_KEY = \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJjbG9vcmRpaGUwMDkyMDcza2Nvcm5jajdnIiwib3JnYW5pemF0aW9uSWQiOiJjbG9vcmRpZ3cwMDkxMDcza2M2cG9oeWFiIiwiYXBpS2V5SWQiOiJjbHc2NzFqOGowNHZsMDd6ZTczemEwdjJuIiwic2VjcmV0IjoiZjExOWVhZDk3MGVkM2ZhMGYyZjkzNGU2ZTFhOWMxMDYiLCJpYXQiOjE3MTU2NzkxMDYsImV4cCI6MjM0NjgzMTEwNn0.3lSmBkOVmbjIltAN1umf3H_pJ_HsptIhxs6v7kv1-Dc\"\nclient = lb.Client(api_key=API_KEY)",
+ "source": "API_KEY = None\nclient = lb.Client(api_key=API_KEY)",
"cell_type": "code",
"outputs": [],
"execution_count": null
@@ -192,4 +192,4 @@
"execution_count": null
}
]
-}
\ No newline at end of file
+}
From 960883429eb50dc08b6d2f0e10302036907878c3 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Fri, 31 May 2024 23:27:54 +0000
Subject: [PATCH 4/4] :art: Cleaned
---
examples/basics/quick_start.ipynb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/examples/basics/quick_start.ipynb b/examples/basics/quick_start.ipynb
index bf8b109d5..c8fa37f62 100644
--- a/examples/basics/quick_start.ipynb
+++ b/examples/basics/quick_start.ipynb
@@ -192,4 +192,4 @@
"execution_count": null
}
]
-}
+}
\ No newline at end of file