Taxonomy for polygons

Howdy, fairly new to label studio. I’m starting image annotation for a computer vision project. Is there a way to have nested levels of polygon labels or attributes attached to those polygons easily? I’m looking for something like taxonomy, only for polygons instances.

I’m working on label studio 1.13.1 installed through pip with a sqllite default backend.

Example: I’m working to identify types of fences and damage to them. I could use nested labels like:
Fence type: metal, wood, vinyl.
For each fence type there could be subclasses like: no damage, vines, structural damage. For certain classes there might be other attributes: metal: rust.

Most items would be the primary class and no damage, I.e: wood: no damage.

If there’s an easy or common way to solve this problem, even if it’s not attributes or subclasses, I’d be interested in hearing it.

I see there’s a metadata option, but it appears to be free text only. I’d rather have set options to avoid typos.

Hello!

Yes, you can achieve nested levels of labels or attach attributes to polygons in Label Studio by using the perRegion attribute in combination with Choices tags. This allows you to associate additional labels or attributes with each polygon you draw on the image.

Here’s how you can set this up:

  1. Use PolygonLabels to annotate the fences: This lets annotators draw polygons around the fences and assign the main fence type (metal, wood, vinyl).
  2. Use Choices with perRegion="true" to attach attributes to each polygon: This allows annotators to select attributes like damage type for each fence polygon.
  3. Conditional visibility: You can use the visibleWhen and whenLabelValue attributes to show certain choices only when specific labels are selected.

Here’s an example of how your labeling configuration might look:

<View>
  <Image name="image" value="$image"/>

  <!-- Main fence type labels -->
  <PolygonLabels name="fence_type" toName="image">
    <Label value="Metal"/>
    <Label value="Wood"/>
    <Label value="Vinyl"/>
  </PolygonLabels>

  <!-- Generic damage types applicable to all fences -->
  <Choices name="damage_type" toName="image" perRegion="true" choice="single-radio" showInline="true">
    <Header value="Damage Type"/>
    <Choice value="No Damage"/>
    <Choice value="Vines"/>
    <Choice value="Structural Damage"/>
  </Choices>

  <!-- Specific attribute for Metal fences -->
  <Choices name="metal_attributes" toName="image" perRegion="true" choice="single-radio" showInline="true"
           visibleWhen="region-labels" whenLabelValue="Metal">
    <Header value="Metal Fence Attributes"/>
    <Choice value="Rust"/>
  </Choices>
</View>

Explanation:

  • PolygonLabels: Allows annotators to draw polygons and assign one of the fence types to each polygon.
  • Choices with perRegion="true": Associates the selected damage type with the currently selected polygon region.
  • Conditional Visibility: The metal_attributes Choices tag is only visible when the polygon has the label “Metal”, using visibleWhen="region-labels" and whenLabelValue="Metal". This way, the “Rust” option appears only for metal fences.

Avoiding Typos:

By using predefined options in the Choices tags, you eliminate the need for free text entry, thus avoiding typos and ensuring consistent data.

Additional Tips:

  • Unique name Attributes: Ensure that each control (PolygonLabels, Choices, etc.) has a unique name attribute.
  • Order of Tags: Place the Choices tags after the PolygonLabels in the configuration to ensure they appear appropriately in the interface.
  • Extending Attributes: For other specific attributes (e.g., attributes unique to wood or vinyl fences), you can add additional Choices tags with conditional visibility using the respective whenLabelValue.

Resources:

Example Workflow:

  1. Annotator draws a polygon around a fence in the image.
  2. Annotator selects the fence type (Metal, Wood, Vinyl) for that polygon.
  3. Damage Type choices appear for the annotator to select, attached to that polygon.
  4. If “Metal” is selected, the “Metal Fence Attributes” choices (like “Rust”) become visible for the annotator to choose.
1 Like

This works great. Thank you!

For anyone else who comes across this, I also experimented with generic ‘Labels’ instead of ‘PolygonLabels’ and added in the polygon, brush and magic wand tools. Those also work with the choice class the same way.

1 Like