logo
×

How to create and manage ontologies and features

A clean, thoughtful ontology is critical for creating high-quality labeled data with minimal errors and inconsistencies. Ontologies are an essential part of the Labelbox labeling platform. Every time you create a project or a model in Labelbox, you will need to select an ontology.

Ontologies and features should be created and managed with the goals of proper labeling, efficiency, and reusability in mind.

When creating and implementing an ontology, here are some helpful tips to consider:

  • Thoroughly understand the task and the tools at your disposal.

  • Create an ontology that follows the most logical workflow for a labeler.

  • Choose tools that will allow labelers to reach the highest speed and quality possible.

  • Create and upload detailed instructions, considering known edge cases that labelers will encounter.

  • Test your ontology in a brief trial run before sending the project to the labeling team.

Python SDK


Create features and ontologies:


# Import packages
from labelbox import OntologyBuilder, Tool, Classification, Option, Client

# Establish client
client = Client()

# Create a bounding box tool with a nested radio subclass
object_features = [
    Tool(
        tool=Tool.Type.BBOX,
        name="regulatory-sign",
        color="#ff0000",
        classifications=[
            Classification(
                class_type=Classification.Type.RADIO,
                instructions="Sign type",
                options=[
                    Option(value="stop", label="Stop"),
                    Option(value="one_way", label="One way")
                ]
            )
        ]
    )
]

# Create a global checklist classification
classification_features = [
    Classification(
        class_type=Classification.Type.CHECKLIST,
        instructions="Quality Issues",
        options=[
            Option(value="blurry", label="Blurry"),
            Option(value="distorted", label="Distorted")
        ]
    )

]

# Use the above features to create an ontology
ontology_builder = OntologyBuilder(
    tools=object_features,
    classifications=classification_features
)

ontology = client.create_ontology(
    "SDK Demo",
    ontology_builder.asdict()
)

Create an ontology from existing features:

# Search for feature by name in your org
feature_1 = next(client.get_feature_schemas("<TOOL_NAME>"))
feature_2 = next(client.get_feature_schemas("<TOOL_NAME>"))

# Get feature by feature schema ID (you can find this in the UI)
feature_3 = client.get_feature_schema("<FEATURE_SCHEMA_ID>")

# View the features
print(feature_1)
print(feature_2)
print(feature_3)

ontology = client.create_ontology_from_feature_schemas(
    "Ontology of shared features", 
    [feature_1.uid, feature_2.uid, feature_3.uid]
)

To view more common SDK methods for ontology management, check out our documentation here.