Skip to content

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.

RoutePurpose
POST /dataset/{datasetId}/tag/updateRename a tag or change its color or description
POST /dataset/{datasetId}/tag/combineMerge several tags into one
POST /dataset/{datasetId}/tag/clearRemove the annotations of some tags, or of all
POST /dataset/{datasetId}/tag/deleteDelete a tag

Rules shared by the four routes ​

  • System tags are 0 (unclassified), OK and NOK in 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 500 with N images could not be updated; run it again, and no tag is deleted. Calling the route again finishes the work.
  • 404 if the dataset or the tag does not exist, 400 if a required field is missing.
  • data can also carry a job to publish the progress: see Progress of long operations.

Update a tag ​

http
POST /dataset/{datasetId}/tag/update
json
{ "data": { "id": "scratch", "name": "Deep scratch", "color": "#e11d48" } }
FieldRequiredMeaning
idyesCurrent id of the tag
namenoNew name
colornoNew color, as a hex value
descriptionnoNew 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.

json
{ "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 ​

http
POST /dataset/{datasetId}/tag/combine
json
{ "data": { "mainTag": "scratch", "tagIds": ["scratch_light", "scratch_deep"] } }
FieldRequiredMeaning
mainTagyesId of the tag that stays. It must exist
tagIdsyesIds 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.

json
{ "data": { "mainTag": "scratch", "merged": ["scratch_light", "scratch_deep"], "updated": 230 } }

400 if tagIds contains a system tag.

Clear annotations ​

http
POST /dataset/{datasetId}/tag/clear
json
{ "data": { "tagIds": ["scratch", "dent"], "groups": ["g1Xa8"], "resetLabeled": true } }
FieldRequiredMeaning
tagIdsyesIds of the tags whose annotations are removed. ["all"] removes the annotations of every tag
groupsnoLimits the operation to the images in those groups. none stands for the images without group. Without it, the whole dataset
resetLabelednoAlso 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.

json
{
  "data": {
    "updated": 96,
    "all": false,
    "tagIds": ["scratch", "dent"],
    "groups": ["g1Xa8"],
    "failedFiles": []
  }
}

An empty tagIds writes nothing.

Delete a tag ​

http
POST /dataset/{datasetId}/tag/delete
json
{ "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.

json
{ "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.