Common SDK methods

Cheatsheet for most common SDK methods for ontology management

Create feature and ontology from normalized data

When you are creating or importing features or ontologies for the first time, you can use the methods below. Read Annotations for a complete list of supported feature types, or simply create a feature in the UI and view its JSON.

feature_object = {
 "name": "regulatory-sign",
 "tool": "rectangle",
 "color": "#ff0000",
 "classifications": [
  {
   "instructions": "Choose type",
   "name": "choose_type",
   "type": "radio",
   "options": [
    {
     "label": "Pedestrians only",
     "value": "pedestrians_only"
    },
    {
     "label": "One way right",
     "value": "one_way_right"
    },
    {
     "label": "Keep right",
     "value": "keep_right"
    },
    {
     "label": "Max speed limit 40",
     "value": "maximum_speed_limit_40"
    }]}]
  }

feature_classification = {
   "instructions": "Is this image blurry?",
   "name": "choose_type",
   "type": "radio",
   "options": [
    {
     "label": "Yes",
     "value": "yes"
    },
    {
     "label": "No",
     "value": "no"
    }]}

regulatory_sign_feature = client.create_feature_schema(feature_object)
classificatoin_feature = client.create_feature_schema(feature_classification)

ontology = client.create_ontology_from_feature_schemas("SDK Demo", [regulatory_sign_feature.uid, classificatoin_feature.uid])

print(ontology)

Creating ontology from existing features

## Search feature by name in your organization
regulatory_sign_feature_schema = next(client.get_feature_schemas("regulatory-sign"))
classificatoin_feature = next(client.get_feature_schemas("Is this image blurry?"))

## Get feature by feature schema ID. You can get this from the UI
regulatory_sign_feature_schema = client.get_feature_schema("FEATURE_SCHEMA_ID")

print(regulatory_sign_feature_schema)
print(classificatoin_feature)

ontology = client.create_ontology_from_feature_schemas("Ontology of shared features", [regulatory_sign_feature_schema.uid, classificatoin_feature.uid])

📘

Ontology size limit

Users can add up to a maximum of 1,000 features (assuming no sub-classifications) per ontology. If you are a paying customer, you can request much higher limits. Please reach out to customer support.

Complete tutorial in Python SDK

Python Tutorial

Github

Google Colab

Ontologies

Open in Github

Open in Google Colab


Did this page help you?