diff --git a/CHANGELOG.md b/CHANGELOG.md index cb68e487a..868e936bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +# Version 2.5.2 (2021-03-25) +## Fix +* Ontology builder defaults to None for missing fields instead of empty lists +* MAL validation added extra fields to subclasses + +### Added +* Example notebooks + ## Version 2.5.1 (2021-03-15) ### Fix * `Dataset.data_row_for_external_id` No longer throws `ResourceNotFoundError` when there are duplicates diff --git a/README.md b/README.md index 98fc1b2bd..12af06b15 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ The Labelbox Python API offers a simple, user-friendly way to interact with the ## Requirements -* Use Python 3.7 or 3.8. +* Use Python 3.6, 3.7 or 3.8. * Create an account by visiting http://app.labelbox.com/. * [Generate an API key](https://labelbox.com/docs/api/getting-started#create_api_key). diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 000000000..c79dd8648 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,26 @@ +## Labelbox SDK Examples + +* Learn how to use the SDK by following along + +Structure: + +1. basics + * [Fundamentals](basics/basics.ipynb) + * CRUD + * [Data rows](basics/data_rows.ipynb) + * [Datasets](basics/datasets.ipynb) + * [Labels](basics/labels.ipynb) + * [Ontologies](basics/ontologies.ipynb) + * [Projects](basics/projects.ipynb) +2. label_export + * [Image annotation export](label_export/images.ipynb) + * [Text annotation export](label_export/text.ipynb) + * [Video annotation export](label_export/video.ipynb) +3. model_assisted_labeling + * [Image mal example](model_assisted_labeling/image_mal.ipynb) + * [Named entity recognition mal example](model_assisted_labeling/ner_mal.ipynb) + * [Debugging mal](model_assisted_labeling/debugging_mal.ipynb) +4. project_configuration + * [Project setup](project_configuration/project_setup.ipynb) + * [Queue management](project_configuration/queue_management.ipynb) + * [Webhooks](project_configuration/webhooks.ipynb) diff --git a/examples/basics/basics.ipynb b/examples/basics/basics.ipynb new file mode 100644 index 000000000..e1bcd161b --- /dev/null +++ b/examples/basics/basics.ipynb @@ -0,0 +1,413 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "complimentary-passing", + "metadata": {}, + "source": [ + "# Basics\n" + ] + }, + { + "cell_type": "markdown", + "id": "smaller-syndication", + "metadata": {}, + "source": [ + "#### Quick install instructions\n", + "The quick version is basically just\n", + "1. `!pip install labelbox`\n", + "2. `export LABELBOX_API_KEY=\"\"`\n", + "* Get this from the UI under (Account -> API -> Create API Key)\n", + "\n", + "\n", + "This only works for cloud deployments.\n", + "* For more details : https://docs.labelbox.com/python-sdk/en/index-en#labelbox-python-sdk" + ] + }, + { + "cell_type": "markdown", + "id": "cheap-damages", + "metadata": {}, + "source": [ + "#### The remainder of this notebook is an interactive version of the fundamental concepts docs.\n", + "* For more details you can read the docs here: \n", + " * https://docs.labelbox.com/python-sdk/en/index-en#fundamental-concepts" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "everyday-street", + "metadata": {}, + "outputs": [], + "source": [ + "from labelbox import Client\n", + "from labelbox import Project, Dataset" + ] + }, + { + "cell_type": "markdown", + "id": "committed-matthew", + "metadata": {}, + "source": [ + "### Main takeaways:\n", + "* All interactions with labelbox happen through the client\n", + "* all attributes that are labelbox.orm.Fields can be accessed via object.field_name\n", + "* all attributes that are labelbox.orm.Relationships can be accessed via object.relationship()\n", + "----\n", + "* To use on your own data you need to plug in the following:\n", + "1. Project and Dataset ids (go to the web ui and you can find these in the url)\n", + " * (https://app.labelbox.com/projects/\n", + " * https://app.labelbox.com/dataset/\n", + "2. A project name and a dataset name\n", + " * Select any project names from here: https://app.labelbox.com/projects\n", + " * Select any dataset names from here: https://app.labelbox.com/data" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "instructional-reply", + "metadata": {}, + "outputs": [], + "source": [ + "PROJECT_ID = \"ckk4q1viuc0w20704eh69u28h\"\n", + "DATASET_ID = \"ckk4q1vjznyhu087203wlghfr\"\n", + "PROJECT_NAME = \"Sample Project\"\n", + "DATASET_NAME = \"Example Jellyfish Dataset\"" + ] + }, + { + "cell_type": "markdown", + "id": "chinese-playing", + "metadata": {}, + "source": [ + "#### Client\n", + "* Starting point for all db interactions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "thick-gasoline", + "metadata": {}, + "outputs": [], + "source": [ + "#Client is used for all DB interactions.\n", + "#This is usually the starting point for all usage.\n", + "client = Client()" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "victorian-consumer", + "metadata": {}, + "outputs": [], + "source": [ + "#Client can be used to fetch by id:\n", + "project = client.get_project(PROJECT_ID)\n", + "dataset = client.get_dataset(DATASET_ID)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "industrial-onion", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "project" + ] + }, + { + "cell_type": "markdown", + "id": "popular-nylon", + "metadata": {}, + "source": [ + "#### Fields\n", + "* All db objects have fields (look at the source code to see them https://github.com/Labelbox/labelbox-python/blob/develop/labelbox/schema/project.py)\n", + "* These fields are attributes of the object" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "guided-institute", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Sample Project\n", + "Demonstrating image segmentation and object detection\n", + "Example Jellyfish Dataset\n" + ] + } + ], + "source": [ + "print(project.name)\n", + "print(project.description)\n", + "print(dataset.name)" + ] + }, + { + "cell_type": "markdown", + "id": "protective-multimedia", + "metadata": {}, + "source": [ + "* Fields can be updated. This will be reflected server side (you will see it in labelbox) " + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "according-subdivision", + "metadata": {}, + "outputs": [], + "source": [ + "project.update(description = \"new description field\")\n", + "print(project.description)" + ] + }, + { + "cell_type": "markdown", + "id": "viral-power", + "metadata": {}, + "source": [ + "#### Pagination\n", + "* Queries that return a list of database objects return them as a PaginatedCollection\n", + "* The goal here is to limit the data being returned to only the necessary data." + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "ideal-processing", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "labels_paginated_collection = project.labels()\n", + "labels_paginated_collection" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "convinced-force", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "