Skip to content

Commit 257bcdc

Browse files
authored
Merge pull request #913 from Labelbox/VB/depr-label-list_SPRNEW-4863_2
Vb/depr label list sprnew 4863 2
2 parents 3b2c1cc + b20be1b commit 257bcdc

File tree

9 files changed

+54
-47
lines changed

9 files changed

+54
-47
lines changed

examples/basics/getting_started.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@
243243
"metadata": {},
244244
"source": [
245245
"queued_data_rows = project.export_queued_data_rows()\n",
246-
"ground_truth_list = lb_types.LabelList()\n",
246+
"ground_truth_list = list()\n",
247247
"\n",
248248
"for datarow in queued_data_rows:\n",
249249
" annotations_list = []\n",

examples/integrations/detectron2/coco_object.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@
415415
{
416416
"metadata": {},
417417
"source": [
418-
"labels_mea = lb_types.LabelList()\n",
418+
"labels_mea = list()\n",
419419
"\n",
420420
"with ThreadPoolExecutor(4) as executor:\n",
421421
" futures = [executor.submit(get_label, label.data) for label in val_labels]\n",
@@ -527,7 +527,7 @@
527527
"# This is still a bit slow due to the amount of processing for each data row.\n",
528528
"# For larger datasets this has to leverage multiprocessing.\n",
529529
"\n",
530-
"labels_mal = lb_types.LabelList()\n",
530+
"labels_mal = list()\n",
531531
"with ThreadPoolExecutor(4) as executor:\n",
532532
" data_rows = dataset.data_rows()\n",
533533
" images = [lb_types.ImageData(url = data_row.row_data, uid = data_row.uid, external_id = data_row.external_id) for data_row in data_rows]\n",
@@ -581,4 +581,4 @@
581581
"execution_count": null
582582
}
583583
]
584-
}
584+
}

examples/integrations/detectron2/coco_panoptic.ipynb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
"model_name = \"detectron_panoptic_model\"\n",
195195
"\n",
196196
"proj = client.get_project(project_id)\n",
197-
"labels = proj.label_generator().as_list()\n"
197+
"labels = list(proj.label_generator())\n"
198198
],
199199
"cell_type": "code",
200200
"outputs": [],
@@ -205,8 +205,8 @@
205205
"source": [
206206
"# Set some labels aside for the val set.\n",
207207
"raw_data = labels._data\n",
208-
"labels = lb_types.LabelList(raw_data[100:])\n",
209-
"val_labels = lb_types.LabelList(raw_data[:100]) "
208+
"labels = list(raw_data[100:])\n",
209+
"val_labels = list(raw_data[:100]) "
210210
],
211211
"cell_type": "code",
212212
"outputs": [],
@@ -1008,12 +1008,13 @@
10081008
{
10091009
"metadata": {},
10101010
"source": [
1011-
"labels_mea = lb_types.LabelList()\n",
1011+
"labels = list()\n",
10121012
"with ThreadPoolExecutor(4) as executor:\n",
10131013
" futures = [executor.submit(get_label,label.data) for label in val_labels]\n",
10141014
" for future in tqdm(as_completed(futures)):\n",
1015-
" labels_mea.append(future.result())\n",
1015+
" labels.append(future.result())\n",
10161016
"\n",
1017+
"labels_mea = LabelGenerator(labels)\n",
10171018
"labels_mea.add_url_to_masks(signer) \\\n",
10181019
" .add_url_to_data(signer) "
10191020
],
@@ -1287,7 +1288,7 @@
12871288
"# For larger datasets this has to leverage multiprocessing.\n",
12881289
"\n",
12891290
"\n",
1290-
"labels_mal = lb_types.LabelList()\n",
1291+
"labels_mal = list()\n",
12911292
"with ThreadPoolExecutor(4) as executor:\n",
12921293
" data_rows = dataset.data_rows()\n",
12931294
" images = [lb_types.ImageData(url = data_row.row_data, uid = data_row.uid, external_id = data_row.external_id) for data_row in data_rows]\n",
@@ -1365,4 +1366,4 @@
13651366
"execution_count": null
13661367
}
13671368
]
1368-
}
1369+
}

examples/label_export/images.ipynb

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
{
2-
"nbformat": 4,
3-
"nbformat_minor": 5,
4-
"metadata": {},
52
"cells": [
63
{
4+
"cell_type": "markdown",
75
"metadata": {},
86
"source": [
97
"<td>\n",
108
" <a target=\"_blank\" href=\"https://labelbox.com\" ><img src=\"https://labelbox.com/blog/content/images/2021/02/logo-v4.svg\" width=256/></a>\n",
119
"</td>"
12-
],
13-
"cell_type": "markdown"
10+
]
1411
},
1512
{
13+
"cell_type": "markdown",
1614
"metadata": {},
1715
"source": [
1816
"<td>\n",
@@ -24,70 +22,72 @@
2422
"<a href=\"https://github.com/Labelbox/labelbox-python/tree/master/examples/label_export/images.ipynb\" target=\"_blank\"><img\n",
2523
"src=\"https://img.shields.io/badge/GitHub-100000?logo=github&logoColor=white\" alt=\"GitHub\"></a>\n",
2624
"</td>"
27-
],
28-
"cell_type": "markdown"
25+
]
2926
},
3027
{
28+
"cell_type": "markdown",
3129
"metadata": {},
3230
"source": [
3331
"# Image Data Export\n",
3432
"* Export labels from image annotation projects"
35-
],
36-
"cell_type": "markdown"
33+
]
3734
},
3835
{
36+
"cell_type": "code",
37+
"execution_count": null,
3938
"metadata": {},
39+
"outputs": [],
4040
"source": [
4141
"!pip install \"labelbox[data]\""
42-
],
43-
"cell_type": "code",
44-
"outputs": [],
45-
"execution_count": null
42+
]
4643
},
4744
{
45+
"cell_type": "code",
46+
"execution_count": null,
4847
"metadata": {},
48+
"outputs": [],
4949
"source": [
5050
"import labelbox as lb\n",
5151
"import labelbox.types as lb_types\n",
5252
"\n",
5353
"from PIL import Image\n",
5454
"import numpy as np\n",
5555
"import os"
56-
],
57-
"cell_type": "code",
58-
"outputs": [],
59-
"execution_count": null
56+
]
6057
},
6158
{
59+
"cell_type": "markdown",
6260
"metadata": {},
6361
"source": [
6462
"# API Key and Client\n",
6563
"Provide a valid api key below in order to properly connect to the Labelbox Client."
66-
],
67-
"cell_type": "markdown"
64+
]
6865
},
6966
{
67+
"cell_type": "code",
68+
"execution_count": null,
7069
"metadata": {},
70+
"outputs": [],
7171
"source": [
7272
"# Add your api key and project\n",
7373
"API_KEY = None\n",
7474
"client = lb.Client(api_key=API_KEY)\n",
7575
"project = client.get_project(PROJECT_ID)"
76-
],
77-
"cell_type": "code",
78-
"outputs": [],
79-
"execution_count": null
76+
]
8077
},
8178
{
79+
"cell_type": "markdown",
8280
"metadata": {},
8381
"source": [
8482
"### Export the labels\n",
8583
"* Data can be exported to annotation objects or raw_json (old export format)"
86-
],
87-
"cell_type": "markdown"
84+
]
8885
},
8986
{
87+
"cell_type": "code",
88+
"execution_count": null,
9089
"metadata": {},
90+
"outputs": [],
9191
"source": [
9292
"labels = project.label_generator()\n",
9393
"\n",
@@ -104,7 +104,7 @@
104104
{
105105
"metadata": {},
106106
"source": [
107-
"* Optionally convert to a `LabelList` for small to medium sized datasets\n",
107+
"* Optionally convert to a `list` for small to medium sized datasets\n",
108108
"* This is more convenient than the `LabelGenerator` but less memory efficient\n",
109109
"* Read more about the differences [here](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/master/examples/annotation_types/label_containers.ipynb)"
110110
],
@@ -113,7 +113,7 @@
113113
{
114114
"metadata": {},
115115
"source": [
116-
"labels = labels.as_list()"
116+
"labels = list(labels)"
117117
],
118118
"cell_type": "code",
119119
"outputs": [],
@@ -169,4 +169,4 @@
169169
"execution_count": null
170170
}
171171
]
172-
}
172+
}

examples/label_export/text.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
{
111111
"metadata": {},
112112
"source": [
113-
"Optionally, convert to a `LabelList` for small to medium-sized datasets.\n",
113+
"Optionally, convert to a `list` for small to medium-sized datasets.\n",
114114
"\n",
115115
"This is more convenient than the LabelGenerator, but less memory efficient. Read more about the differences [here](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/master/examples/annotation_types/label_containers.ipynb)."
116116
],
@@ -119,7 +119,7 @@
119119
{
120120
"metadata": {},
121121
"source": [
122-
"labels = labels.as_list()"
122+
"labels = list(labels)"
123123
],
124124
"cell_type": "code",
125125
"outputs": [],

examples/model_diagnostics/custom_metrics_demo.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@
262262
{
263263
"metadata": {},
264264
"source": [
265-
"predictions = lb_types.LabelList()\n",
265+
"predictions = list()\n",
266266
"for (image_url, external_id) in notebook.tqdm(image_data):\n",
267267
" image = lb_types.ImageData(url=image_url, external_id=external_id)\n",
268268
" height, width = image.value.shape[:2]\n",
@@ -580,4 +580,4 @@
580580
"execution_count": null
581581
}
582582
]
583-
}
583+
}

examples/model_diagnostics/model_diagnostics_demo.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@
269269
{
270270
"metadata": {},
271271
"source": [
272-
"predictions = lb_types.LabelList()\n",
272+
"predictions = list()\n",
273273
"for (image_url, external_id) in notebook.tqdm(image_data[:10]):\n",
274274
" image = lb_types.ImageData(url=image_url, external_id=external_id)\n",
275275
" height, width = image.value.shape[:2]\n",
@@ -549,4 +549,4 @@
549549
"execution_count": null
550550
}
551551
]
552-
}
552+
}

examples/model_diagnostics/model_diagnostics_guide.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
{
208208
"metadata": {},
209209
"source": [
210-
"predictions = lb_types.LabelList()\n",
210+
"predictions = list()\n",
211211
"for label in notebook.tqdm(labels):\n",
212212
" annotations = []\n",
213213
" image = label.data\n",
@@ -352,4 +352,4 @@
352352
"execution_count": null
353353
}
354354
]
355-
}
355+
}

labelbox/data/annotation_types/collection.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class LabelList:
2222
Use on smaller datasets.
2323
"""
2424

25+
warnings.warn("LabelList is deprecated and will be "
26+
"removed in a future release.")
27+
2528
def __init__(self, data: Optional[Iterable[Label]] = None):
2629
if data is None:
2730
self._data = []
@@ -187,6 +190,9 @@ def __init__(self, data: Generator[Label, None, None], *args, **kwargs):
187190
super().__init__(data, *args, **kwargs)
188191

189192
def as_list(self) -> "LabelList":
193+
warnings.warn("This method is deprecated and will be "
194+
"removed in a future release. LabeList"
195+
" class will be deprecated.")
190196
return LabelList(data=list(self))
191197

192198
def assign_feature_schema_ids(

0 commit comments

Comments
 (0)