An Ontology, or labeling protocol, defines the concepts, relationships, and representations in your data. Ontologies are essential for creating object and frame labels by defining what is being labeled.
Encord supports Classifications with nested attributes up to 7 levels deep using Radio buttons (RadioAttribute). Checklists and text fields stop the nesting of attributes.
Copy
- Classification - Radio button - Radio button - Radio button - Radio button - Radio button - Radio button - Radio button or Checklist or Text box
Ontology with Annotation: Creates an Ontology (title=“My test Ontology”) with a single Bounding Box Object (“Cute cat”) in the structure.Workflow Project with Ontology and Annotations: Creates a Workflow Project (“Cats annotation project”) with a dataset (“MY_CAT_DATASET”) and an Ontology.
Use the following example as a guide to creating your Ontology with Classifications using the SDK.Radio button: Creates an Ontology with 2 radio button lists.Checklist: Creates an Ontology with 3 options in a checklist.Text field: Creates an Ontology with a single text field.Number: Creates an Ontology with a single numerical input field.Nested attributes: Creates an Ontology with 2 levels of nesting.
Copy
from encord import EncordUserClientfrom encord.objects import OntologyStructurefrom encord.objects.attributes import RadioAttributeuser_client = EncordUserClient.create_with_ssh_private_key( ssh_private_key_path='/Users/encord/.ssh/id_ed25519' )# Create a new ontology with Classificationsontology_structure = OntologyStructure()# Adding a Classification of type radio buttonclassification = ontology_structure.add_classification()cat_colour = classification.add_attribute(RadioAttribute, "colour", required=True)cat_colour.add_option("white")cat_colour.add_option("black")# Create a new ontology with Classificationsontology = user_client.create_ontology("Radio Button Ontology", structure=ontology_structure)print(f"created ontology {ontology.ontology_hash}")