You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/basics/projects.ipynb
+14Lines changed: 14 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -266,6 +266,20 @@
266
266
"outputs": [],
267
267
"execution_count": null
268
268
},
269
+
{
270
+
"metadata": {},
271
+
"source": [
272
+
"### Get project overview"
273
+
],
274
+
"cell_type": "markdown"
275
+
},
276
+
{
277
+
"metadata": {},
278
+
"source": "# Returns only the number of data rows and issues\noverview = project.get_overview()\n\n# Returns the number of data rows, issues and the details of the in_review queue\ndetailed_overview = project.get_overview(details=True)",
"This notebook is intended to be a quick overview on Labelbox-Python SDK by demonstrating a simple but common workflow.\n",
36
+
"\n",
37
+
"In this guide, we will be:\n",
38
+
"\n",
39
+
"1. Creating a dataset and importing an image data row\n",
40
+
"2. Creating a ontology\n",
41
+
"3. Creating a project and attaching our ontology\n",
42
+
"4. Sending our data row to our project by creating a batch\n",
43
+
"5. Exporting our image data row from our project\n",
44
+
"\n",
45
+
"This notebook is geared towards new users of Labelbox-Python SDK."
46
+
],
47
+
"cell_type": "markdown"
48
+
},
49
+
{
50
+
"metadata": {},
51
+
"source": [
52
+
"## Setup\n",
53
+
"\n",
54
+
"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."
55
+
],
56
+
"cell_type": "markdown"
57
+
},
58
+
{
59
+
"metadata": {},
60
+
"source": "%pip install -q \"labelbox[data]\"",
61
+
"cell_type": "code",
62
+
"outputs": [],
63
+
"execution_count": null
64
+
},
65
+
{
66
+
"metadata": {},
67
+
"source": "import labelbox as lb\nimport uuid",
68
+
"cell_type": "code",
69
+
"outputs": [],
70
+
"execution_count": null
71
+
},
72
+
{
73
+
"metadata": {},
74
+
"source": [
75
+
"## API Key and Client\n",
76
+
"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."
"## Step 1: Create Dataset and Import Data Row\n",
91
+
"\n",
92
+
"Below, we will create a dataset and then attach a publicly hosted image data row. Typically, you would either import data rows hosted on a cloud provider (_recommended_) or import them locally. For more information, visit our [import image data section](https://docs.labelbox.com/reference/image) in our developer guides.\n",
93
+
"\n",
94
+
"- 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",
95
+
"- 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."
96
+
],
97
+
"cell_type": "markdown"
98
+
},
99
+
{
100
+
"metadata": {},
101
+
"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",
102
+
"cell_type": "code",
103
+
"outputs": [],
104
+
"execution_count": null
105
+
},
106
+
{
107
+
"metadata": {},
108
+
"source": [
109
+
"## Step 2: Creating an Ontology\n",
110
+
"\n",
111
+
"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",
112
+
"\n",
113
+
"* 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."
"## Step 3: Creating a Project and Attaching our Ontology\n",
128
+
"\n",
129
+
"Now that we have made our ontology, we are ready to create a project where we can label our data row.\n",
130
+
"\n",
131
+
"* 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."
132
+
],
133
+
"cell_type": "markdown"
134
+
},
135
+
{
136
+
"metadata": {},
137
+
"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)",
138
+
"cell_type": "code",
139
+
"outputs": [],
140
+
"execution_count": null
141
+
},
142
+
{
143
+
"metadata": {},
144
+
"source": [
145
+
"## Step 4: Sending our Data Row to our Project by Creating a Batch\n",
146
+
"\n",
147
+
"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",
148
+
"\n",
149
+
"* 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."
150
+
],
151
+
"cell_type": "markdown"
152
+
},
153
+
{
154
+
"metadata": {},
155
+
"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)",
156
+
"cell_type": "code",
157
+
"outputs": [],
158
+
"execution_count": null
159
+
},
160
+
{
161
+
"metadata": {},
162
+
"source": [
163
+
"## Step 5: Exporting from our Project\n",
164
+
"\n",
165
+
"We have now successfully set up a project for labeling using only the SDK! \ud83d\ude80\n",
166
+
"\n",
167
+
"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."
168
+
],
169
+
"cell_type": "markdown"
170
+
},
171
+
{
172
+
"metadata": {},
173
+
"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)",
174
+
"cell_type": "code",
175
+
"outputs": [],
176
+
"execution_count": null
177
+
},
178
+
{
179
+
"metadata": {},
180
+
"source": [
181
+
"## Clean Up\n",
182
+
"\n",
183
+
"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."
0 commit comments