The cml:shapes tag allows users to create an image annotation job for bounding boxes in conjunction with a custom ontology and the use of test questions and aggregation.
Building a Job
The following CML contains the possible parameters for a bounding box with labels job:
<cml:shapes type="['box']" image-url="{{image_url}}" name="annotation" label="Annotate this image" validates="required" ontology="true" box-threshold="0.7" box-agg="0.6" class-threshold="0.7" class-agg="agg" />
Note: There are parameters for test questions and aggregation that apply to both the bounding boxes and the labels.
Parameters
Below are the parameters available for the cml:shapes tag. Some are required in the element, some can be left out.
type
- The shape used in the job, set in an array.
- To use multiple shapes in one job, include each shape in the array, separated by commas, e.g., 'type="['box','dot','polygon','line']"'
- You’ll need to include the corresponding parameters for each shape
image-url
- The column from your source data that contains the image URLs to be annotated.
name
- The results header where annotations will be stored.
label
- The question label contributors will see.
validates
(optional)- Whether or not this element is required to be answered.
- Accepts ‘required’
- Defaults to not required if not present
ontology
(optional)- The list of classes to be labeled in an image - view this article to learn how to create your custom ontology.
- Accepts 'true' or 'false'
- Defaults to ‘false’ if not present
review-from
(optional)- This will read in existing annotations on an image. The format must match the output shown in the aggregation section below. All that’s needed is the following:
- ‘type’
- ‘class’ if using an ontology
- ‘coordinates'
- 'id'
- Example: [{“class”:“car”,“coordinates”:{“h”:330,“w”:384,“x”:1191,“y”:306},“type”:“box”,“id”:“247f2099-22e1-4825-9bc1-3e51c6019fe0”}]
- This will read in existing annotations on an image. The format must match the output shown in the aggregation section below. All that’s needed is the following:
box-threshold
- The minimum overall bounding box IoU required for a contributor to pass a test question.
- Accepts a decimal value between 0.1 and 0.99.
class-threshold
- Example: the class-threshold is set to 0.7 and a test question contains 10 ground truth shapes. A contributor gets 8 out of 10 classes correct for a score of 80% and they’re marked correct on the test question.
- The minimum percentage of correct classes applied to boxes in a test question for a contributor to be considered correct.
- Accepts a decimal value between 0.1 and 0.99.
- The formula is correct / (correct + incorrect)
box-agg
- The minimum IoU required for result boxes to be clustered together.
- Accepts a decimal between 0.1 and 0.99, or the value ‘all’.
- If ‘all’ is selected, no clustering is done on the boxes.
class-agg
- The aggregation applied to the class for a given cluster of shapes.
- Accepts standard aggregation types:
agg
all
agg_x
cagg_x
Creating test questions
When using the cml:shapes tag, the behavior of test questions and aggregation will change based on the shapes chosen and whether or not the job includes an ontology.
- On the quality page, click “Create Test Questions”
- Add annotations around the objects in the way specified in the job's instructions
- If no annotations are needed, make sure the job includes an option, such as a single checkbox, to hide the annotation tool
- Save Test Question
Reviewing test questions
- Select a test question from the quality page.
- From the image annotation sidebar, click ‘Find a Judgment’ and choose a contributor ID from the drop-down.
- Edit, create or remove the test question annotations based on feedback. Judgments are color-coded based on if they match the gold responses.
- Each shape will have its own matching metrics, which can be seen by hovering over a contributor judgment or golden shape. A notification will appear in the top left corner of the image. A score from zero to one is displayed based on the intersection over union formula. If using an ontology, the class match is also displayed.
- All scores on the image are averaged and compared to the test question threshold set in the job design. The overall matching score is then displayed in the left sidebar of the tool.
- Save any edits that are made to update the evaluation of the existing contributors' work and ensure any future attempts to answer the test question will be properly evaluated.
Fig. 1 test question scores
Aggregation
Boxes
Aggregation for bounding boxes using cml:shapes works as follows:
- Set the
box-agg
parameter in the CML, which is the IoU used for clustering boxes prior to aggregation.- For example, if the
box-agg
is 0.6, boxes that overlap each other by at least 60% will be clustered together.
- For example, if the
- The corners of the constituent boxes are taken as dots and weighted according to the trust scores of the contributors who drew them.
- The 'dots' are then aggregated and a new box is drawn.
Labels (Classes)
The class-agg
parameter accepts the following standard aggregation methods:
agg
all
agg_x
cagg_x
Labels (or classes) are aggregated per returned box. This means, for example, if you choose to aggregate boxes - as opposed to selecting 'all' - and you choose class-agg="agg"
, for each aggregated box you'd receive the most confident label out of the constituent boxes in the cluster. If you choose class-agg="all"
, you'd receive every label applied to the cluster of boxes, but still just one box, and so on. For box-agg="all"
, you'd receive every box and every label in the image, no aggregation. Labels will always be grouped with the shape they were applied to and will be returned in a dictionary.
Example output of a job with box-agg="0.6"
and class-agg="agg"
:
[{“average_trust”:0.7857,“class”:{“car”:1.0},“coordinates”:{“h”:330,“w”:384,“x”:1191,“y”:306},“iou”:0.9628,“type”:“box”}]
Example output of a job with box-agg="0.6" and class-agg="all":
[{“average_trust”:0.7857,“class”:{“car”:0.33,”person”:0.33,”tree”:0.33},“coordinates”:{“h”:330,“w”:384,“x”:1191,“y”:306},“iou”:0.9628,“type”:“box”}]
Reviewing results
To review the results of your job, you can do the following:
- Go to the Data page.
- Click on a unit ID.
- In the sidebar of the annotation tool, select an option from the drop-down menu.
- You’ll see different contributor IDs, which allow you to view individual annotations.
- You’ll also see an “aggregated” option, which shows you the result you’ll get based on your aggregation settings in the CML or report options page of your job.