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
"This notebook is geared towards new users of our SDK."
44
-
]
46
+
],
47
+
"cell_type": "markdown"
45
48
},
46
49
{
47
-
"cell_type": "markdown",
48
50
"metadata": {},
49
51
"source": [
50
52
"## Setup\n",
51
53
"\n",
52
54
"To start, 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 unique IDs for the variety of objects that will be created with this notebook."
53
-
]
55
+
],
56
+
"cell_type": "markdown"
54
57
},
55
58
{
56
-
"cell_type": "code",
57
-
"execution_count": null,
58
59
"metadata": {},
60
+
"source": "%pip install -q \"labelbox[data]\"",
61
+
"cell_type": "code",
59
62
"outputs": [],
60
-
"source": [
61
-
"%pip install -q \"labelbox[data]\""
62
-
]
63
+
"execution_count": null
63
64
},
64
65
{
65
-
"cell_type": "code",
66
-
"execution_count": null,
67
66
"metadata": {},
67
+
"source": "import labelbox as lb\nimport uuid",
68
+
"cell_type": "code",
68
69
"outputs": [],
69
-
"source": [
70
-
"import labelbox as lb\n",
71
-
"import uuid"
72
-
]
70
+
"execution_count": null
73
71
},
74
72
{
75
-
"cell_type": "markdown",
76
73
"metadata": {},
77
74
"source": [
78
75
"## API Key and Client\n",
79
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",
@@ -99,193 +93,98 @@
99
93
"\n",
100
94
"* Data rows are internal representation of an asset in Labelbox. A data row contains the asset to be labeled and all of the relevant information about that asset\n",
101
95
"* A dataset is a collection of data rows imported into Labelbox. They live inside the [_Catelog_](https://docs.labelbox.com/docs/catalog-overview) section of Labelbox."
102
-
]
96
+
],
97
+
"cell_type": "markdown"
103
98
},
104
99
{
105
-
"cell_type": "code",
106
-
"execution_count": null,
107
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",
108
103
"outputs": [],
109
-
"source": [
110
-
"# Create dataset from client\n",
111
-
"dataset = client.create_dataset(name=\"Quick Start Example Dataset\")\n",
112
-
"\n",
113
-
"global_key = str(uuid.uuid4()) # Unique user specified ID\n",
"task = dataset.create_data_rows(image_data_rows) # List of data rows\n",
127
-
"task.wait_till_done()\n",
128
-
"print(task.errors) # Print any errors"
129
-
]
104
+
"execution_count": null
130
105
},
131
106
{
132
-
"cell_type": "markdown",
133
107
"metadata": {},
134
108
"source": [
135
109
"## Step 2: Creating an Ontology\n",
136
110
"\n",
137
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 check list classification feature. For more information, visit the [ontology section](https://docs.labelbox.com/reference/ontology) inside our developer guides. \n",
138
112
"\n",
139
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",
186
128
"\n",
187
129
"Now that we have made our ontology we are ready to create a project were we can label our data row.\n",
188
130
"\n",
189
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."
190
-
]
132
+
],
133
+
"cell_type": "markdown"
191
134
},
192
135
{
193
-
"cell_type": "code",
194
-
"execution_count": null,
195
136
"metadata": {},
137
+
"source": "# Create a new project\nproject = client.create_project(\n name=\"Quick Start Example Project\",\n media_type=lb.MediaType.Image, # specify the media type\n)\n\n# Attach created ontology\nproject.setup_editor(ontology)",
138
+
"cell_type": "code",
196
139
"outputs": [],
197
-
"source": [
198
-
"# Create a new project\n",
199
-
"project = client.create_project(\n",
200
-
" name=\"Quick Start Example Project\",\n",
201
-
" media_type=lb.MediaType.Image, # specify the media type\n",
202
-
")\n",
203
-
"\n",
204
-
"# Attach created ontology\n",
205
-
"project.setup_editor(ontology)"
206
-
]
140
+
"execution_count": null
207
141
},
208
142
{
209
-
"cell_type": "markdown",
210
143
"metadata": {},
211
144
"source": [
212
145
"## Step 4: Sending our Data Row to our Project by Creating a Batch\n",
213
146
"\n",
214
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 were labelers are able to annotate our data row. For more information on batches, review the [batches section](https://docs.labelbox.com/reference/batch#create-a-batch) of our developer guides."
215
-
]
148
+
],
149
+
"cell_type": "markdown"
216
150
},
217
151
{
218
-
"cell_type": "code",
219
-
"execution_count": null,
220
152
"metadata": {},
153
+
"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)",
154
+
"cell_type": "code",
221
155
"outputs": [],
222
-
"source": [
223
-
"project.create_batch(\n",
224
-
" name=\"Quick Start Example Batch\" + str(uuid.uuid4()),\n",
225
-
" global_keys=[\n",
226
-
" global_key\n",
227
-
" ], # Global key we used earlier in this guide to create our dataset\n",
228
-
" priority=5,\n",
229
-
")"
230
-
]
156
+
"execution_count": null
231
157
},
232
158
{
233
-
"cell_type": "markdown",
234
159
"metadata": {},
235
160
"source": [
236
161
"# Step 5: Exporting from our Project\n",
237
162
"\n",
238
-
"We have now successfully set up a project for labeling using only the SDK! 🚀 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 our [export overview](https://docs.labelbox.com/reference/label-export) developer guide. "
239
-
]
163
+
"We have now successfully set up a project for labeling using only the SDK! \ud83d\ude80 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 our [export overview](https://docs.labelbox.com/reference/label-export) developer guide. "
164
+
],
165
+
"cell_type": "markdown"
240
166
},
241
167
{
242
-
"cell_type": "code",
243
-
"execution_count": null,
244
168
"metadata": {},
169
+
"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)",
"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