create_label_set
imerit_ango.sdk.SDK.
create_label_set(project_id, tools, classifications, relations, raw_category_schema)
Update the ontology of your project.
Parameters
project_id: string
The unique identifier for the project. You can find the project ID in the user interface or retrieve it using the
list_projectsfunction.
tools: List[ToolCategory], optional
List of tools that will be added to the label set.
Example:
[ ToolCategory( Tool.Segmentation, title="Segmentation Tool" ) ]classifications: List[ClassificationCategory], optional, default None
List of classifications that will be added to the label set.
Example:
[ ClassificationCategory( Classification.Single_dropdown, title = "Single Choice Question", options=[LabelOption("First Option"), LabelOption("Second Option")] ) ]relations: List[RelationCategory], optional, default None
List of relations that will be added to the label set.
Example:
[ RelationCategory( Relation.Single, title="Single Relation Tool" ) ]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:
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.
As an example, a raw_category_schema obtained from a project could be this:
Label Set Classes
ToolCategory
Parameters:
tool: Tool
The tool type.
Options:
Tool.BoundingBox
Tool.Segmentation
Tool.Polyline
Tool.Polygon
Tool.RotatedBoundingBox
Tool.Ner
Tool.Point
Tool.Pdf
Tool.Brush
Tool.PCT
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
Parameters:
classification: Classification
The classification type.
Options:
Classification.Multi_dropdown
Classification.Single_dropdown
Classification.Tree_dropdown
Classification.Radio
Classification.Checkbox
Classification.Text
Classification.Instance
Classification.Boolean
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
Parameters:
relation: Relation
The classification type.
Options:
Relation.Single
Relation.Group
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:
A dictionary containing the result of the operation.
Including a
statusfield indicating whether the request was successful and adatafield containing the response payload with updated resources produced by the operation.
How to verify in Ango Hub?
After successfully executing the create_label_set function, you can validate the changes directly in Ango Hub.
Navigate to: Projects → [Your Project] → Settings → Category Schema
Confirm that the category schema has been updated successfully.
Changes made via the SDK are reflected in Ango Hub in near real-time. If updates are not immediately visible, please refresh the page.
Examples
Example-1: Creating an ontology with:
A Single Dropdown classification, with two choices named "First" and "Second":
Example-2: Creating an ontology with:
A Single Dropdown classification with the classifications "First" and "Second"
A Segmentation tool called "SegmentationTool"
A Single Relation called "SingleRelationTool"
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 Tree Dropdown tool 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:
A radio classification tool with two possible answers, "Radio Option 1" and "Radio Option 2"
A conditionally nested Text classification tool using the rich text editor, which only appears if the labeler clicks on "Radio Option 1" (here,
parentOptionIdlinks the text tool to the option which reveals it)
Example-6: Creating an ontology with:
A radio classification tool with the possible answers "Radio Answer 1" and "Radio Answer 2"
A Tree Dropdown classification tool which only appears if the annotator clicks on "Radio Answer 1"
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"
See also
Last updated