Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/basics/getting_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
"metadata": {},
"source": [
"queued_data_rows = project.export_queued_data_rows()\n",
"ground_truth_list = lb_types.LabelList()\n",
"ground_truth_list = list()\n",
"\n",
"for datarow in queued_data_rows:\n",
" annotations_list = []\n",
Expand Down
6 changes: 3 additions & 3 deletions examples/integrations/detectron2/coco_object.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@
{
"metadata": {},
"source": [
"labels_mea = lb_types.LabelList()\n",
"labels_mea = list()\n",
"\n",
"with ThreadPoolExecutor(4) as executor:\n",
" futures = [executor.submit(get_label, label.data) for label in val_labels]\n",
Expand Down Expand Up @@ -527,7 +527,7 @@
"# This is still a bit slow due to the amount of processing for each data row.\n",
"# For larger datasets this has to leverage multiprocessing.\n",
"\n",
"labels_mal = lb_types.LabelList()\n",
"labels_mal = list()\n",
"with ThreadPoolExecutor(4) as executor:\n",
" data_rows = dataset.data_rows()\n",
" 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",
Expand Down Expand Up @@ -581,4 +581,4 @@
"execution_count": null
}
]
}
}
15 changes: 8 additions & 7 deletions examples/integrations/detectron2/coco_panoptic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
"model_name = \"detectron_panoptic_model\"\n",
"\n",
"proj = client.get_project(project_id)\n",
"labels = proj.label_generator().as_list()\n"
"labels = list(proj.label_generator())\n"
],
"cell_type": "code",
"outputs": [],
Expand All @@ -205,8 +205,8 @@
"source": [
"# Set some labels aside for the val set.\n",
"raw_data = labels._data\n",
"labels = lb_types.LabelList(raw_data[100:])\n",
"val_labels = lb_types.LabelList(raw_data[:100]) "
"labels = list(raw_data[100:])\n",
"val_labels = list(raw_data[:100]) "
],
"cell_type": "code",
"outputs": [],
Expand Down Expand Up @@ -1008,12 +1008,13 @@
{
"metadata": {},
"source": [
"labels_mea = lb_types.LabelList()\n",
"labels = list()\n",
"with ThreadPoolExecutor(4) as executor:\n",
" futures = [executor.submit(get_label,label.data) for label in val_labels]\n",
" for future in tqdm(as_completed(futures)):\n",
" labels_mea.append(future.result())\n",
" labels.append(future.result())\n",
"\n",
"labels_mea = LabelGenerator(labels)\n",
"labels_mea.add_url_to_masks(signer) \\\n",
" .add_url_to_data(signer) "
],
Expand Down Expand Up @@ -1287,7 +1288,7 @@
"# For larger datasets this has to leverage multiprocessing.\n",
"\n",
"\n",
"labels_mal = lb_types.LabelList()\n",
"labels_mal = list()\n",
"with ThreadPoolExecutor(4) as executor:\n",
" data_rows = dataset.data_rows()\n",
" 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",
Expand Down Expand Up @@ -1365,4 +1366,4 @@
"execution_count": null
}
]
}
}
56 changes: 28 additions & 28 deletions examples/label_export/images.ipynb
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
{
"nbformat": 4,
"nbformat_minor": 5,
"metadata": {},
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<td>\n",
" <a target=\"_blank\" href=\"https://labelbox.com\" ><img src=\"https://labelbox.com/blog/content/images/2021/02/logo-v4.svg\" width=256/></a>\n",
"</td>"
],
"cell_type": "markdown"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<td>\n",
Expand All @@ -24,70 +22,72 @@
"<a href=\"https://github.com/Labelbox/labelbox-python/tree/master/examples/label_export/images.ipynb\" target=\"_blank\"><img\n",
"src=\"https://img.shields.io/badge/GitHub-100000?logo=github&logoColor=white\" alt=\"GitHub\"></a>\n",
"</td>"
],
"cell_type": "markdown"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Image Data Export\n",
"* Export labels from image annotation projects"
],
"cell_type": "markdown"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pip install \"labelbox[data]\""
],
"cell_type": "code",
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import labelbox as lb\n",
"import labelbox.types as lb_types\n",
"\n",
"from PIL import Image\n",
"import numpy as np\n",
"import os"
],
"cell_type": "code",
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# API Key and Client\n",
"Provide a valid api key below in order to properly connect to the Labelbox Client."
],
"cell_type": "markdown"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Add your api key and project\n",
"API_KEY = None\n",
"client = lb.Client(api_key=API_KEY)\n",
"project = client.get_project(PROJECT_ID)"
],
"cell_type": "code",
"outputs": [],
"execution_count": null
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Export the labels\n",
"* Data can be exported to annotation objects or raw_json (old export format)"
],
"cell_type": "markdown"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"labels = project.label_generator()\n",
"\n",
Expand All @@ -104,7 +104,7 @@
{
"metadata": {},
"source": [
"* Optionally convert to a `LabelList` for small to medium sized datasets\n",
"* Optionally convert to a `list` for small to medium sized datasets\n",
"* This is more convenient than the `LabelGenerator` but less memory efficient\n",
"* Read more about the differences [here](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/master/examples/annotation_types/label_containers.ipynb)"
],
Expand All @@ -113,7 +113,7 @@
{
"metadata": {},
"source": [
"labels = labels.as_list()"
"labels = list(labels)"
],
"cell_type": "code",
"outputs": [],
Expand Down Expand Up @@ -169,4 +169,4 @@
"execution_count": null
}
]
}
}
4 changes: 2 additions & 2 deletions examples/label_export/text.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
{
"metadata": {},
"source": [
"Optionally, convert to a `LabelList` for small to medium-sized datasets.\n",
"Optionally, convert to a `list` for small to medium-sized datasets.\n",
"\n",
"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)."
],
Expand All @@ -119,7 +119,7 @@
{
"metadata": {},
"source": [
"labels = labels.as_list()"
"labels = list(labels)"
],
"cell_type": "code",
"outputs": [],
Expand Down
4 changes: 2 additions & 2 deletions examples/model_diagnostics/custom_metrics_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@
{
"metadata": {},
"source": [
"predictions = lb_types.LabelList()\n",
"predictions = list()\n",
"for (image_url, external_id) in notebook.tqdm(image_data):\n",
" image = lb_types.ImageData(url=image_url, external_id=external_id)\n",
" height, width = image.value.shape[:2]\n",
Expand Down Expand Up @@ -580,4 +580,4 @@
"execution_count": null
}
]
}
}
4 changes: 2 additions & 2 deletions examples/model_diagnostics/model_diagnostics_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
{
"metadata": {},
"source": [
"predictions = lb_types.LabelList()\n",
"predictions = list()\n",
"for (image_url, external_id) in notebook.tqdm(image_data[:10]):\n",
" image = lb_types.ImageData(url=image_url, external_id=external_id)\n",
" height, width = image.value.shape[:2]\n",
Expand Down Expand Up @@ -549,4 +549,4 @@
"execution_count": null
}
]
}
}
4 changes: 2 additions & 2 deletions examples/model_diagnostics/model_diagnostics_guide.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
{
"metadata": {},
"source": [
"predictions = lb_types.LabelList()\n",
"predictions = list()\n",
"for label in notebook.tqdm(labels):\n",
" annotations = []\n",
" image = label.data\n",
Expand Down Expand Up @@ -352,4 +352,4 @@
"execution_count": null
}
]
}
}
6 changes: 6 additions & 0 deletions labelbox/data/annotation_types/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class LabelList:
Use on smaller datasets.
"""

warnings.warn("LabelList is deprecated and will be "
"removed in a future release.")

def __init__(self, data: Optional[Iterable[Label]] = None):
if data is None:
self._data = []
Expand Down Expand Up @@ -187,6 +190,9 @@ def __init__(self, data: Generator[Label, None, None], *args, **kwargs):
super().__init__(data, *args, **kwargs)

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

def assign_feature_schema_ids(
Expand Down