Skip to content

Commit 375f009

Browse files
Merge pull request #472 from Labelbox/other-notebook-changes
made minor fixes to two notebooks
2 parents 1775236 + 192f354 commit 375f009

File tree

2 files changed

+113
-230
lines changed

2 files changed

+113
-230
lines changed

examples/basics/datasets.ipynb

Lines changed: 65 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "db768cda",
6-
"metadata": {},
75
"source": [
86
"<td>\n",
97
" <a target=\"_blank\" href=\"https://labelbox.com\" ><img src=\"https://labelbox.com/blog/content/images/2021/02/logo-v4.svg\" width=256/></a>\n",
108
"</td>"
11-
]
9+
],
10+
"metadata": {}
1211
},
1312
{
1413
"cell_type": "markdown",
15-
"id": "cb5611d0",
16-
"metadata": {},
1714
"source": [
1815
"<td>\n",
1916
"<a href=\"https://colab.research.google.com/github/Labelbox/labelbox-python/blob/develop/examples/basics/datasets.ipynb\" target=\"_blank\"><img\n",
@@ -24,271 +21,196 @@
2421
"<a href=\"https://github.com/Labelbox/labelbox-python/tree/develop/examples/basics/datasets.ipynb\" target=\"_blank\"><img\n",
2522
"src=\"https://img.shields.io/badge/GitHub-100000?logo=github&logoColor=white\" alt=\"GitHub\"></a>\n",
2623
"</td>"
27-
]
24+
],
25+
"metadata": {}
2826
},
2927
{
3028
"cell_type": "markdown",
31-
"id": "settled-lodging",
32-
"metadata": {},
3329
"source": [
3430
"# Datasets"
35-
]
31+
],
32+
"metadata": {}
3633
},
3734
{
3835
"cell_type": "markdown",
39-
"id": "demanding-charge",
40-
"metadata": {},
4136
"source": [
4237
"* Datasets are collections of data rows (image, video, or text to be labeled)\n",
4338
"* Datasets are used to define units of work.\n",
4439
" * Attaching a dataset to a project will add all data rows in the dataset to the project (and add them to the queue)\n",
4540
"* Datasets are not required to be fixed in size (you can add data rows at any time). \n",
4641
" * However, if you add data rows to a dataset, all projects associated with this dataset will add the new data rows to its queue"
47-
]
42+
],
43+
"metadata": {}
4844
},
4945
{
5046
"cell_type": "code",
5147
"execution_count": 1,
52-
"id": "attached-ticket",
53-
"metadata": {},
54-
"outputs": [],
5548
"source": [
5649
"!pip install labelbox"
57-
]
50+
],
51+
"outputs": [],
52+
"metadata": {}
5853
},
5954
{
6055
"cell_type": "code",
6156
"execution_count": 2,
62-
"id": "educational-locking",
63-
"metadata": {},
64-
"outputs": [],
6557
"source": [
6658
"from labelbox import Client\n",
6759
"import uuid\n",
6860
"import os"
69-
]
61+
],
62+
"outputs": [],
63+
"metadata": {}
7064
},
7165
{
7266
"cell_type": "markdown",
73-
"id": "geological-clear",
74-
"metadata": {},
7567
"source": [
7668
"* Set the following cell with your data to run this notebook"
77-
]
69+
],
70+
"metadata": {}
7871
},
7972
{
8073
"cell_type": "code",
8174
"execution_count": 4,
82-
"id": "looking-airport",
83-
"metadata": {},
84-
"outputs": [],
8575
"source": [
8676
"# Pick a dataset that has attached data_rows\n",
8777
"DATASET_ID = \"ckm4xyfua04cf0z7a3wz58kgj\""
88-
]
78+
],
79+
"outputs": [],
80+
"metadata": {}
8981
},
9082
{
9183
"cell_type": "markdown",
92-
"id": "1a0b4115",
93-
"metadata": {},
9484
"source": [
9585
"# API Key and Client\n",
9686
"Provide a valid api key below in order to properly connect to the Labelbox Client."
97-
]
87+
],
88+
"metadata": {}
9889
},
9990
{
10091
"cell_type": "code",
10192
"execution_count": 5,
102-
"id": "retained-illustration",
103-
"metadata": {},
104-
"outputs": [],
10593
"source": [
10694
"# Add your api key\n",
10795
"API_KEY = None\n",
10896
"client = Client(api_key=API_KEY)"
109-
]
97+
],
98+
"outputs": [],
99+
"metadata": {}
110100
},
111101
{
112102
"cell_type": "markdown",
113-
"id": "explicit-thunder",
114-
"metadata": {},
115103
"source": [
116104
"### Read"
117-
]
105+
],
106+
"metadata": {}
118107
},
119108
{
120109
"cell_type": "code",
121110
"execution_count": 6,
122-
"id": "inclusive-herald",
123-
"metadata": {},
124-
"outputs": [],
125111
"source": [
126112
"# Can be fetched by name (using a query - see basics), or using an id directly\n",
127113
"dataset = client.get_dataset(DATASET_ID)"
128-
]
114+
],
115+
"outputs": [],
116+
"metadata": {}
129117
},
130118
{
131119
"cell_type": "code",
132-
"execution_count": 7,
133-
"id": "increased-joshua",
134-
"metadata": {},
135-
"outputs": [
136-
{
137-
"name": "stdout",
138-
"output_type": "stream",
139-
"text": [
140-
"<Dataset {'created_at': datetime.datetime(2021, 3, 11, 14, 3, 12, tzinfo=datetime.timezone.utc), 'description': '', 'name': 'animal_demo_ds', 'uid': 'ckm4xyfua04cf0z7a3wz58kgj', 'updated_at': datetime.datetime(2021, 3, 11, 14, 3, 12, tzinfo=datetime.timezone.utc)}>\n"
141-
]
142-
}
143-
],
120+
"execution_count": null,
144121
"source": [
145122
"print(dataset)"
146-
]
123+
],
124+
"outputs": [],
125+
"metadata": {}
147126
},
148127
{
149128
"cell_type": "code",
150-
"execution_count": 8,
151-
"id": "thermal-making",
152-
"metadata": {},
153-
"outputs": [
154-
{
155-
"data": {
156-
"text/plain": [
157-
"<DataRow ID: ckm4y6s531rnq0rb6bobqa6j7>"
158-
]
159-
},
160-
"execution_count": 27,
161-
"metadata": {},
162-
"output_type": "execute_result"
163-
}
164-
],
129+
"execution_count": null,
165130
"source": [
166131
"# We can see the data rows associated with a dataset\n",
167132
"data_rows = dataset.data_rows()\n",
168-
"next(data_rows) # Print first one"
169-
]
133+
"next(data_rows) # Print first data row"
134+
],
135+
"outputs": [],
136+
"metadata": {}
170137
},
171138
{
172139
"cell_type": "code",
173-
"execution_count": 9,
174-
"id": "cellular-rhythm",
175-
"metadata": {},
176-
"outputs": [
177-
{
178-
"name": "stdout",
179-
"output_type": "stream",
180-
"text": [
181-
"Projects with this dataset attached : [<Project ID: ckm4xyfncfgja0760vpfdxoro>]\n",
182-
"Dataset name : animal_demo_ds\n"
183-
]
184-
}
185-
],
140+
"execution_count": null,
186141
"source": [
187142
"# Attached projects\n",
188143
"print(\"Projects with this dataset attached :\", list(dataset.projects()))\n",
189144
"print(\"Dataset name :\", dataset.name)"
190-
]
191-
},
192-
{
193-
"cell_type": "code",
194-
"execution_count": 10,
195-
"id": "liquid-stocks",
196-
"metadata": {},
145+
],
197146
"outputs": [],
198-
"source": [
199-
"# A dataset is the way to list all data rows\n",
200-
"data_row = next(dataset.data_rows())"
201-
]
147+
"metadata": {}
202148
},
203149
{
204150
"cell_type": "markdown",
205-
"id": "sonic-classic",
206-
"metadata": {},
207151
"source": [
208152
"### Create"
209-
]
153+
],
154+
"metadata": {}
210155
},
211156
{
212157
"cell_type": "code",
213-
"execution_count": 11,
214-
"id": "valuable-bench",
215-
"metadata": {},
216-
"outputs": [
217-
{
218-
"name": "stdout",
219-
"output_type": "stream",
220-
"text": [
221-
"<Dataset {'created_at': datetime.datetime(2021, 3, 17, 11, 11, 7, tzinfo=datetime.timezone.utc), 'description': '', 'name': 'my_new_dataset', 'uid': 'ckmdcg8lf04px0y9ge67bbxa5', 'updated_at': datetime.datetime(2021, 3, 17, 11, 11, 7, tzinfo=datetime.timezone.utc)}>\n"
222-
]
223-
}
224-
],
158+
"execution_count": null,
225159
"source": [
226160
"new_dataset = client.create_dataset(name=\"my_new_dataset\")\n",
227161
"print(new_dataset)"
228-
]
162+
],
163+
"outputs": [],
164+
"metadata": {}
229165
},
230166
{
231167
"cell_type": "markdown",
232-
"id": "humanitarian-response",
233-
"metadata": {},
234168
"source": [
235169
"* Add data rows\n",
236-
"* See the [data rows](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/develop/examples/basics/data_rows.ipynb#scrollTo=successful-patch) notebook for more about adding data rows"
237-
]
170+
"* See the [data rows](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/develop/examples/basics/data_rows.ipynb#scrollTo=successful-patch) notebook `Create` section for more about adding data rows."
171+
],
172+
"metadata": {}
238173
},
239174
{
240175
"cell_type": "code",
241176
"execution_count": 12,
242-
"id": "egyptian-qatar",
243-
"metadata": {},
244-
"outputs": [],
245177
"source": [
246-
"dataset.create_data_row(row_data=\"https://picsum.photos/200/300\")"
247-
]
178+
"new_dataset.create_data_row(row_data=\"https://picsum.photos/200/300\")"
179+
],
180+
"outputs": [],
181+
"metadata": {}
248182
},
249183
{
250184
"cell_type": "markdown",
251-
"id": "varying-louisville",
252-
"metadata": {},
253185
"source": [
254186
"### Update"
255-
]
187+
],
188+
"metadata": {}
256189
},
257190
{
258191
"cell_type": "code",
259192
"execution_count": 13,
260-
"id": "clinical-parks",
261-
"metadata": {},
262-
"outputs": [],
263193
"source": [
264194
"new_dataset.update(name=\"new_name\")"
265-
]
266-
},
267-
{
268-
"cell_type": "markdown",
269-
"id": "outdoor-projector",
270-
"metadata": {},
271-
"source": [
272-
"* See the data rows notebook `Create` section on how to add data_rows to a dataset."
273-
]
195+
],
196+
"outputs": [],
197+
"metadata": {}
274198
},
275199
{
276200
"cell_type": "markdown",
277-
"id": "caroline-therapist",
278-
"metadata": {},
279201
"source": [
280202
"### Delete"
281-
]
203+
],
204+
"metadata": {}
282205
},
283206
{
284207
"cell_type": "code",
285208
"execution_count": 14,
286-
"id": "increased-grenada",
287-
"metadata": {},
288-
"outputs": [],
289209
"source": [
290210
"new_dataset.delete()"
291-
]
211+
],
212+
"outputs": [],
213+
"metadata": {}
292214
}
293215
],
294216
"metadata": {
@@ -312,4 +234,4 @@
312234
},
313235
"nbformat": 4,
314236
"nbformat_minor": 5
315-
}
237+
}

0 commit comments

Comments
 (0)