GMT: Guided Mask Transformer for Leaf Instance Segmentation

Feng Chen, Sotirios A. Tsaftaris, Mario Valerio Giuffrida

TL;DR

The Guided Mask Transformer (GMT) improves leaf instance segmentation by baking "spatial priors"—knowledge of how leaves naturally grow and cluster—directly into a Transformer-based architecture. By using specialized guide functions to map pixels into a more separable embedding space, GMT consistently outperforms state-of-the-art models like Mask2Former, particularly when dealing with the tiny, overlapping leaves found at the center of rosette plants.

What Problem Does This Paper Address?

In plant phenotyping, accurately counting and measuring individual leaves is vital for monitoring growth and predicting crop yields. However, leaf instance segmentation is notoriously difficult. Leaves often have nearly identical colors and shapes, vary wildly in size, and frequently overlap.

While Transformer-based models (like Mask2Former) have set new benchmarks in general computer vision, they often stumble in the plant world. They tend to miss small leaves at the plant's center, merge overlapping leaves into a single blob, or confuse green background objects with actual foliage. This is exacerbated by the fact that plant datasets are typically very small (hundreds of images vs. the millions used in general AI), making it hard for large models to learn distinctive features from scratch.

Methods

The authors propose GMT, which extends the Mask2Former architecture with three novel components designed to leverage the predictable spatial distribution of leaves (e.g., leaves growing outward from a central point).

  1. Guide Functions: The model uses harmonic (sinusoidal) functions to map pixel coordinates into an embedding space. These functions are trained to ensure that pixels belonging to different leaf instances are pushed far apart, making them easier to distinguish.
  2. Guided Positional Encoding (GPE): Standard Transformers use "positional encodings" to know where pixels are. GMT enhances this by adding the learned spatial priors from the guide functions, helping the model align its spatial "understanding" with actual plant structures.
  3. Guided Dynamic Positional Queries (GDPQ): Instead of starting with random guesses (queries), GMT dynamically generates queries based on intermediate mask predictions. These queries are "conditioned" by the guide functions, essentially telling the model where to look for the next leaf based on where it found the last one.
  4. Guided Embedding Fusion Module (GEFM): This module fuses standard image features with the specialized "guided" embeddings, using an auxiliary $L_1$ loss to ensure the model learns to separate instances effectively.

Datasets

The model was evaluated on three widely recognized public plant datasets:

  • CVPPP LSC (2017): A benchmark for rosette plants (Arabidopsis), featuring 128 training images.
  • MSU-PID: Contains images of Arabidopsis and bean plants with varying complexity.
  • KOMATSUNA: RGB images of Komatsuna (Japanese mustard spinach) plants.

Key Insights and Ideas

  • Exploiting Biological Regularity: The "aha moment" here is that plants aren't random; they follow growth patterns. By encoding these patterns into the architecture via guide functions, the model requires less data to achieve high precision.
  • Dynamic Refinement: By using GDPQ, the model treats segmentation as an iterative process where each step's prediction informs the "search area" for the next, which is particularly effective for densely clustered leaves.
  • Separability in Embedding Space: Rather than just looking at color or edges, GMT learns a mathematical space where overlapping leaves of the same color are forced to look different to the "eyes" of the Transformer.

Key Results

GMT consistently outperformed the baseline Mask2Former and other state-of-the-art (SOTA) methods across all metrics:

  • Accuracy (SBD): On the CVPPP LSC dataset, GMT achieved a Symmetric Best Dice (SBD) of 90.1, compared to Mask2Former’s 89.5.
  • Counting Precision (|DiC|): GMT significantly reduced the "Difference in Count" error. In CVPPP LSC, the error dropped from 0.67 to 0.48, meaning the model is much better at actually counting the number of leaves correctly.
  • Small Leaf Performance: Qualitative results show GMT is significantly more robust at identifying tiny, young leaves at the center of the plant that other models typically ignore or merge.

Limitations and Future Work

  • Computational Complexity: The authors noted that increasing the dimensionality of guide functions directly is computationally expensive. They bypassed this with a "post-processing" expansion trick, but the model still adds overhead compared to a vanilla Transformer.
  • Dataset Specificity: While GMT works well on rosette-style plants, its performance on more chaotic or non-centralized plant structures (like vine crops or dense forest canopies) remains a question for future research.
  • Future Directions: The authors suggest extending GMT to more complex agricultural scenarios and further optimizing the architecture to reduce the computational footprint for deployment on edge devices (like agricultural drones or robots).

Summary updated

Abstract

Leaf instance segmentation is a challenging multi-instance segmentation task, aiming to separate and delin-eate each leaf in an image of a plant. Accurate segmentation of each leaf is crucial for plant-related applications such as the fine-grained monitoring of plant growth and crop yield estimation. This task is challenging because of the high similarity (in shape and colour), great size variation, and heavy occlusions among leaf instances. Furthermore, the typically small size of annotated leaf datasets makes it more difficult to learn the distinctive features needed for precise segmentation. We hypothesise that the key to overcoming the these challenges lies in the specific spatial patterns of leaf distri-bution. In this paper, we propose the Guided Mask Trans-former (GMT), which leverages and integrates leaf spa-tial distribution priors into a Transformer-based segmentor. These spatial priors are embedded in a set of guide functions that map leaves at different positions into a more sepa-rable embedding space. Our GMT consistently outperforms the state-of-the-art on three public plant datasets. Our code is available at https://github.com/vios-s/gmt-leaf-ins-seg.
BibTeX
@inproceedings{chen2025gmt,
  author = {Feng Chen and Sotirios A. Tsaftaris and Mario Valerio Giuffrida},
  title = {{GMT: Guided Mask Transformer for Leaf Instance Segmentation}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2025},
  url = {https://openreview.net/forum?id=3efPjV79nl},
}

Loading related content...

Figure