Last updated
Last updated
imerit_ango.sdk.SDK.
Create and set the project's ontology.
As this method is more complex than others, we recommend also consulting the examples at the end of this section.
project_id: string
The unique identifier for the project. You can find the project ID in or retrieve it using the function.
tools: List[ToolCategory], optional
List of tools that will be added to the label set.
Example: [ToolCategory(Tool.Segmentation, title="SegmentationTool")]
classifications: List[ClassificationCategory], optional, default None
List of classifications that will be added to the label set.
Example: [ClassificationCategory(Classification.Single_dropdown, title = "Choice", options=[LabelOption("First"), LabelOption("Second")])]
relations: List[RelationCategory], optional, default None
List of relations that will be added to the label set.
Example: [RelationCategory(Relation.Single, title="SingleRelationTool")]
raw_category_schema: Dict, optional, default None
Instead of creating the label set (category schema) using the previous 'tools', 'classifications', and 'relations' parameters, you may pass here a dictionary representing the entire category schema.
See the section below for an example.
To get an example of what can be passed as the raw_category_schema
, there are two ways:
Using the SDK itself, get the category schema from another existing project. This will also allow you to programmatically copy the category schema between two projects, like so:
As an example, a raw_category_schema
obtained from a project could be this:
ToolCategory:
BoundingBox
Segmentation
Polyline
Polygon
RotatedBoundingBox
Ner
Point
Brush
ToolCategory Parameters:
tool: Tool
The tool type. ex.: Tool.Segmentation
title: string, default ""
The title of the tool.
required: bool, default None
Whether annotators are required to draw at least one instance of this tool.
schemaId: string, default None
Sets the tool's schemaId.
columnField: bool, default False
Whether this tool should be a table column.
color: string, default ""
The color assigned to this labeling tool, in the format "#FFFFFF"
shortcutKey: string, default ""
The shortcut to quickly select this tool, "0"-"9", "ctrl+0"-"ctrl+9", "a"-"k"
classifications: List[ClassificationCategory], default []
List of nested classifications, if any
options: List[LabelOption], default []
The tool's answers (options.)
ClassificationCategory:
Multi_dropdown
Single_dropdown
Tree_dropdown
Radio
Checkbox
Text
Instance
ClassificationCategory Parameters:
classification: Classification
The classification type. ex.:Classification.Tree_dropdown
title: string, default ""
The title of the classification.
required: bool, default None
Whether annotators have to answer this classification or not.
schemaId: string, default None
Sets the classification's Schema ID.
columnField: bool, default False
Whether this classification should be a table column.
color: string, default ""
The color assigned to this labeling tool, in the format "#FFFFFF"
shortcutKey: string, default ""
The shortcut to quickly select this tool, "0"-"9", "ctrl+0"-"ctrl+9", "a"-"k"
classifications: List, default [ClassificationCategory]
List of nested classifications, if any
options: List[LabelOption], default []
The classification's answers (options.)
treeOptions: List[TreeOption], default []
For trees, the tree's leaves/branches.
parentOptionId: string, default ""
The schema ID of the parent option. That is, the option that the labeler needs to select in order for this classification to appear. Enables conditional nesting.
richText: bool, default False
Set to True to enable the Rich Text editor for the selected text classification tool.
RelationCategory:
Single
Group
RelationCategory Parameters:
relation: Relation
The classification type. ex.:Relation.Single
title: string, default ""
The title of the relation.
required: bool, default None
Whether annotators have to include at least one such relation in order to submit their annotation.
schemaId: string, default None
Sets the schemaId of the relation.
columnField: bool, default False
Whether this relation should be a table column.
color: string, default ""
The color assigned to this relation, in the format "#FFFFFF"
shortcutKey: string, default ""
The shortcut to quickly select this relation, "0"-"9", "ctrl+0"-"ctrl+9", "a"-"k"
classifications: List[ClassificationCategory], default []
List of nested classifications, if any
options: List[LabelOption], default []
The relation's answers (options.)
LabelOption parameters:
value: string
The text of the answer (option.)
schemaId: string, default None
The schema ID of the option. Necessary for conditional nesting.
Returns:
output: dict
Example-1: Creating an ontology with:
Example-2: Creating an ontology with:
Example-3: Creating an ontology with:
A Single Dropdown classification called "Entity Type" with the choices "Vehicle" and "Person"
Another Single Dropdown classification nested inside the first unconditionally (that is, any choice in the first dropdown will open this second) named "Position" with the choices "On Road" and "Off Road".
Example-4: Creating an ontology with:
A root
With a "tree0" branch
With a "subtree0" leaf
With a "subtree1" leaf
With a "tree1" leaf
Example-5: Creating an ontology with:
Example-6: Creating an ontology with:
The Tree Dropdown has a main root
With a branch called "Branch 1"
With leaves called "Leaf 1" and "Leaf 2"
With a leaf called "Leaf 3"
From the UI, navigate to an existing project, then from the Settings tab, navigate to the Category Schema section. From there, click on the button on the right side to open the schema's JSON. Copy that JSON.
A classification, with two choices named "First" and "Second":
A classification with the classifications "First" and "Second"
A tool called "SegmentationTool"
A called "SingleRelationTool"
A tool with:
A with two possible answers, "Radio Option 1" and "Radio Option 2"
A conditionally nested using the rich text editor, which only appears if the labeler clicks on "Radio Option 1" (here, parentOptionId
links the text tool to the option which reveals it)
A with the possible answers "Radio Answer 1" and "Radio Answer 2"
A which only appears if the annotator clicks on "Radio Answer 1"