Tag routes
A tag is used by many images, so changing one means rewriting every image that carries it. These four routes do that on the server. They read their fields inside data, and they are long operations: call them on usapi. Base URLs, authentication and the response envelope are in Requests and responses.
| Route | Purpose |
|---|---|
POST /dataset/{datasetId}/tag/update | Rename a tag or change its color or description |
POST /dataset/{datasetId}/tag/combine | Merge several tags into one |
POST /dataset/{datasetId}/tag/clear | Remove the annotations of some tags, or of all |
POST /dataset/{datasetId}/tag/delete | Delete a tag |
Rules shared by the four routes
- System tags are
0(unclassified),OKandNOKin any letter case, and any tag flagged as unclassified, anomaly or normal. They cannot be deleted or merged into another tag, and they keep their name. A system tag can be the target of a merge. - Images that change meanwhile are not overwritten. If an image is edited between the moment the route reads it and the moment it writes it, the route reads it again and recalculates.
- A failure leaves the work repeatable. If some image could not be rewritten, the answer is
500withN images could not be updated; run it again, and no tag is deleted. Calling the route again finishes the work. 404if the dataset or the tag does not exist,400if a required field is missing.datacan also carry ajobto publish the progress: see Progress of long operations.
Update a tag
POST /dataset/{datasetId}/tag/update{ "data": { "id": "scratch", "name": "Deep scratch", "color": "#e11d48" } }| Field | Required | Meaning |
|---|---|---|
id | yes | Current id of the tag |
name | no | New name |
color | no | New color, as a hex value |
description | no | New description |
Fields that are not sent keep their value.
A different name renames the tag. The renamed tag gets a new id, the new name with / replaced by _, and every image is moved to it. If a tag with that id already exists the answer is 409: merge the two with Combine tags instead.
Changing only the color or the description keeps the id. Images are rewritten only in ANOMALY and MULTILABEL datasets, where the drawn annotations store the color and the name.
{ "data": { "id": "Deep scratch", "previousId": "scratch", "updated": 412 } }previousId is present only after a rename. updated counts the images rewritten.
A rename that fails halfway leaves both tags: the new one with the images already moved and the old one with the rest. Repeating the rename answers 409; finish it by combining the old tag into the new one.
Combine tags
POST /dataset/{datasetId}/tag/combine{ "data": { "mainTag": "scratch", "tagIds": ["scratch_light", "scratch_deep"] } }| Field | Required | Meaning |
|---|---|---|
mainTag | yes | Id of the tag that stays. It must exist |
tagIds | yes | Ids of the tags to merge into it |
Every image and annotation of the tags in tagIds passes to mainTag, and those tags are deleted. An image that had annotations of two of the merged tags keeps both annotations, now with the same tag. Masks are kept.
{ "data": { "mainTag": "scratch", "merged": ["scratch_light", "scratch_deep"], "updated": 230 } }400 if tagIds contains a system tag.
Clear annotations
POST /dataset/{datasetId}/tag/clear{ "data": { "tagIds": ["scratch", "dent"], "groups": ["g1Xa8"], "resetLabeled": true } }| Field | Required | Meaning |
|---|---|---|
tagIds | yes | Ids of the tags whose annotations are removed. ["all"] removes the annotations of every tag |
groups | no | Limits the operation to the images in those groups. none stands for the images without group. Without it, the whole dataset |
resetLabeled | no | Also clears the labeled flag of the images that end up without annotations |
Removes the boxes and masks of those tags from each image, and deletes the mask files that are no longer used. In MULTICLASS and ANOMALY datasets an image whose class is cleared returns to unclassified. The tags themselves stay.
Annotations belong to the image, not to the group: an image that is in a cleared group and in another one loses its annotations all the same.
{
"data": {
"updated": 96,
"all": false,
"tagIds": ["scratch", "dent"],
"groups": ["g1Xa8"],
"failedFiles": []
}
}2
3
4
5
6
7
8
9
An empty tagIds writes nothing.
Delete a tag
POST /dataset/{datasetId}/tag/delete{ "data": { "id": "scratch_light" } }Removes the tag from every image: its boxes and masks are deleted, with their mask files, and the images that had it as their class return to unclassified. The tag is deleted at the end.
{ "data": { "id": "scratch_light", "updated": 64, "failedFiles": [] } }failedFiles lists mask files that could not be removed from storage. 400 if the tag is a system tag.