Weakly Supervised Panoptic Segmentation for Defect-Based Grading of Fresh Produce

Manuel Knott, Divinefavour Odion, Sameer Sontakke, Anup Karwa, Thijs Defraeye

Introduction

Visual inspection for grading agricultural products, such as identifying bruises and scars on bananas, is traditionally a manual and subjective process. While deep learning offers a path to automation, these models typically require massive, pixel-perfect "dense" datasets. In decentralized supply chains, such data is rarely available. This paper addresses the "low-data regime" challenge by proposing a weakly supervised pipeline that leverages the Segment Anything Model (SAM) to automate produce grading with minimal human effort.

Methodology

The researchers propose a two-stage approach to convert sparse human inputs into high-fidelity training labels for a downstream segmentation model.

The proposed weakly supervised pipeline: SAM converts coarse annotations into dense masks to train a panoptic segmentation model.
  1. Weak Supervision with SAM: SAM is used as a vision foundation model to generate dense panoptic masks from "weak" inputs like bounding boxes and points. This reduces manual annotation workloads by a factor of 10.
  2. Panoptic Segmentation: These SAM-generated labels train a Maskformer model. A panoptic framework was chosen to handle both "stuff" (the banana bunches) and "things" (individual defect instances) simultaneously.
  3. Post-processing and Quantification: A connected-components algorithm and dilation operations refine defect instances. Because absolute measurements are difficult from 2D smartphone photos, the system calculates relative defect size (defect pixels vs. banana pixels) as a proxy for severity.

Dataset and Experimental Setup

The study introduced a specialized Banana Defect Dataset consisting of 476 field images collected via smartphones at sorting facilities in India. The dataset contains 1,440 defects categorized as Old/New Bruises and Old/New Scars. These images reflect real-world conditions, including non-standardized lighting and complex backgrounds.

Analysis of SAM as a Labeler

A key insight of the study is that foundation models like SAM act as a "force multiplier" for domain experts. However, the authors identified specific "blind spots" where SAM's zero-shot performance degrades.

SAM performance (IoU) relative to defect size, showing decreased accuracy for very small defects.

As shown in the analysis, SAM struggles with long, thin scars and very small defects (typically under 100 pixels). Despite these limitations in the training data generation phase, the downstream Maskformer model demonstrated resilience, compensating for some inaccuracies in the SAM-generated masks.

Key Results

  • Efficiency: Manual annotation effort was reduced by at least 10x.
  • Segmentation Quality: The model achieved a Panoptic Quality (PQ) of 78.2% when trained on SAM-generated masks, nearly identical to the 77.9% achieved with expensive hand-annotated masks.
  • Grading Accuracy: The model was within ±1 defect of the ground truth in 76.2% of cases. Furthermore, there was a very high correlation (r = 0.96) between predicted relative defect sizes and ground truth, validating the system as a reliable tool for size-based grading.

Conclusion and Future Work

This research demonstrates that foundation models can effectively bridge the gap between sparse annotations and dense segmentation in specialized industrial tasks. While SAM 1.0 struggles with fine details, future work may utilize SAM 2 or higher-resolution inputs to improve detection of thin scars. The authors also suggest that fine-tuning SAM specifically on agricultural data could further reduce error rates in these challenging edge cases.

Summary updated

BibTeX
@inproceedings{knott2025weakly,
  author = {Manuel Knott and Divinefavour Odion and Sameer Sontakke and Anup Karwa and Thijs Defraeye},
  title = {{Weakly Supervised Panoptic Segmentation for Defect-Based Grading of Fresh Produce}},
  booktitle = {Workshops @ CVPR},
  year = {2025},
}
Figure