Source-linked AI summary

SAM Fails to Segment Anything? -- SAM-Adapter: Adapting SAM in Underperformed Scenes: Camouflage, Shadow, Medical Image Segmentation, and More

Tianrun Chen, Lanyun Zhu, Chaotao Ding, Runlong Cao, Yan Wang, Zejian Li, Lingyun Sun, Papa Mao, Ying Zang

arXiv:2304.09148v3cs.CV

TL;DR

SAM can underperform on challenging tasks such as camouflage and shadow segmentation despite its broad pretrained capabilities. The paper introduces SAM-Adapter, which injects task-specific information into SAM through lightweight adapters and visual prompts, and reports improved performance including state-of-the-art results on tested downstream tasks. The approach also improves polyp segmentation, although evaluation covered only a few datasets.

  • Problem

    SAM does not consistently perform well on challenging downstream segmentation tasks such as camouflaged object and shadow detection.

    Source: §1 · p. 2
  • Method

    SAM-Adapter uses lightweight adapters and visual prompts to inject task-specific guidance into SAM while leveraging its pretrained general knowledge.

    Source: §1 · p. 2, §3.1 · p. 3, §3.3 · p. 4
  • Results

    SAM-Adapter significantly improves SAM and achieves state-of-the-art results in camouflaged object detection and shadow detection, while also enhancing polyp segmentation.

    Source: §1 · p. 2, §5 · p. 8
  • Takeaways & Limitations

    SAM-Adapter provides a generalizable and composable way to transfer SAM to customized downstream segmentation tasks.

    Source: §1 · p. 2

    The study was tested on only a few datasets.

    Source: §1 · p. 2

Abstract

from arXiv · show

The emergence of large models, also known as foundation models, has brought significant advancements to AI research. One such model is Segment Anything (SAM), which is designed for image segmentation tasks. However, as with other foundation models, our experimental findings suggest that SAM may fail or perform poorly in certain segmentation tasks, such as shadow detection and camouflaged object detection (concealed object detection). This study first paves the way for applying the large pre-trained image segmentation model SAM to these downstream tasks, even in situations where SAM performs poorly. Rather than fine-tuning the SAM network, we propose \textbf{SAM-Adapter}, which incorporates domain-specific information or visual prompts into the segmentation network by using simple yet effective adapters. By integrating task-specific knowledge with general knowledge learnt by the large model, SAM-Adapter can significantly elevate the performance of SAM in challenging tasks as shown in extensive experiments. We can even outperform task-specific network models and achieve state-of-the-art performance in the task we tested: camouflaged object detection, shadow detection. We also tested polyp segmentation (medical image segmentation) and achieves better results. We believe our work opens up opportunities for utilizing SAM in downstream tasks, with potential applications in various fields, including medical image processing, agriculture, remote sensing, and more.

1 Introduction

SAM can perform poorly on challenging downstream segmentation tasks, motivating SAM-Adapter, a lightweight approach that injects task-specific guidance into SAM while preserving its general knowledge. The method is presented as generalizable and composable, and achieves strong results across shadow, camouflage, and related segmentation tasks.

  • SAM may fail on challenging low-level structural tasks such as camouflaged object and shadow detection because general training data cannot cover every scenario.Source: §1 · p. 2
  • SAM-Adapter adapts SAM to downstream tasks by injecting task-specific guidance through a lightweight additional network and visual prompts while keeping the large model’s knowledge.Source: §1 · p. 2
  • The approach is designed to generalize across customized datasets and compose multiple explicit conditions for multi-condition control.Source: §1 · p. 2
  • Across shadow detection, camouflaged object detection, and polyp segmentation, experiments report enhanced performance, including state-of-the-art results for the tested downstream tasks.Source: §1 · p. 2
  • The study reports testing on only a few datasets, while suggesting broader applicability to fields including medical imaging and agriculture.Source: §1 · p. 2

2 Related Work

Related work spans semantic segmentation architectures, parameter-efficient adapters, camouflaged object detection, and shadow detection. This paper positions SAM-Adapter as combining pretrained SAM with task-specific prior knowledge for downstream segmentation.

Semantic Segmentation

  • Semantic segmentation has advanced through convolutional, encoder-decoder, attention, pyramid, and transformer architectures, while SAM contributes a large ViT-based pretrained model.Source: §2 · p. 3

Adapters

  • Adapters provide compact task-specific modifications for pretrained models, but prior work had not applied them to SAM for image segmentation downstream tasks.Source: §2 · p. 3

Camouflaged Object Detection

  • Camouflaged object detection identifies objects that blend into surroundings, using task-relevant cues such as texture, brightness, and color.Source: §2 · p. 3
  • The paper combines SAM with task-specific prior knowledge to target state-of-the-art camouflaged object detection.Source: §2 · p. 3

Shadow Detection

  • Shadow detection uses cues related to chromaticity, intensity, texture, and illumination, which this work combines with large neural network models.Source: §2 · p. 3

3 Method

SAM-Adapter keeps SAM’s pretrained image encoder as a frozen backbone while adapting downstream segmentation through a tunable mask decoder and lightweight task-specific prompts. The adapter can flexibly incorporate dataset-derived or handcrafted guidance, including compositions of multiple feature types.

3.1 Using SAM as the Backbone

  • SAM-Adapter uses SAM’s ViT-H/16 image encoder with pretrained weights frozen, initializes the mask decoder from SAM, tunes that decoder, and supplies no original prompts.The mask decoder combines a modified transformer decoder block with a dynamic mask prediction head.Source: §3.1 · p. 3

3.2 Adapters

  • The adapter converts task-specific information into prompts that are attached to SAM transformer layers, using two MLPs and an activation function.This prompting mechanism introduces task-specific knowledge while retaining the foundation model’s general knowledge.Source: §3.2 · pp. 3–4

3.3 Input Task-Specific Information

  • Task-specific information F_i can be extracted as texture or frequency features, or specified through handcrafted rules, depending on the downstream task.The guidance can be derived from samples in the task dataset or designed externally.Source: §3.3 · p. 4
  • Multiple guidance sources can be composed as F_i, with adjustable weights w_j controlling the strength of each feature type.This composition makes the task-specific input flexible across different segmentation tasks.Source: §3.3 · p. 4

4 Experiments

Experiments evaluate SAM-Adapter on camouflaged object detection, shadow detection, and polyp segmentation across several datasets, using standard task-specific metrics and SAM prompting variants. Across these tasks, SAM-Adapter improves SAM substantially, including a +17.9% gain in Sα for camouflage detection and reported performance boosts for shadow and polyp segmentation.

4.1 Tasks and Datasets

  • The experiments use COD10K, CHAMELEON, CAMO, ISTD, and kvasir-SEG for camouflage, shadow, and polyp segmentation evaluation.COD10K contains 3,040 training and 2,026 testing samples; ISTD contains 1,330 training and 540 test images, while CAMO, CHAMELEON, and kvasir-SEG follow stated task protocols.Source: §4.1 · p. 4

4.2 Implementation Details

  • SAM uses official implementations and varied prompting approaches, while training uses task-specific losses, AdamW, cosine learning-rate decay, and task-dependent epoch counts.The implementation uses ViT-H SAM, balanced BCE for shadow detection, BCE plus IoU losses for camouflage and polyp segmentation, and 20, 90, and 120 training epochs respectively.Source: §4.1 · p. 5, §4.2 · p. 5

4.3 Experimental Result for Camouflaged Object Detection

  • +17.9% in Sα is achieved by SAM-Adapter over SAM for camouflaged object detection, while also outperforming the existing state-of-the-art method.SAM performs significantly below existing state-of-the-art methods across all evaluated camouflage metrics, whereas SAM-Adapter identifies concealed objects more successfully.Source: §4.3 · p. 5, Table 1 · p. 5

4.4 Experimental Result for Shadow Detection

  • SAM-Adapter significantly improves shadow detection, producing clearer shadow regions and a quantitative performance boost over SAM.SAM struggles to distinguish shadows from background, with missing or mistakenly added regions; the improvement is reported in Table 2.Source: §4.4 · pp. 5–6, Table 2 · p. 5

4.5 Experimental Result for Polyp Segmentation

  • SAM-Adapter enhances polyp identification beyond pretrained SAM, which can identify some polyps but produces inaccurate segmentation.The improvement is supported by quantitative results in Table 3 and visualization results in Figure 6.Source: §4.5 · p. 7, Table 3 · p. 7, Figure 6 · p. 8

5 Conclusion

The work adapts SAM for downstream segmentation tasks where the original model is ineffective. SAM-Adapter improves performance on camouflage, shadow, and polyp segmentation, achieving state-of-the-art results on the evaluated tasks.

  • SAM-Adapter uses SAM as a backbone and injects customized information through simple, effective adapters for specific tasks.Source: §5 · p. 8
  • The method significantly improves SAM on camouflaged object detection and shadow detection while achieving state-of-the-art results.Source: §5 · p. 8
  • Polyp segmentation experiments show that SAM-Adapter can also enhance medical image segmentation performance.Source: §5 · p. 8

6 Future Work

Future work will extend SAM-Adapter to more challenging segmentation tasks and additional fields. The authors also anticipate designs specialized for particular tasks.

  • Future work will extend SAM-Adapter to increasingly challenging image segmentation tasks.Source: §6 · p. 8
  • The authors plan to broaden SAM-Adapter’s application to other fields.Source: §6 · p. 8
  • Future versions may incorporate more specialized designs tailored to specific tasks.Source: §6 · p. 8

7 More Results

On CAMO, SAM fails to perceive animals concealed in their natural surroundings. SAM-Adapter substantially improves segmentation performance in these camouflaged images.

  • SAM fails to perceive animals that are visually hidden in their natural surroundings.Source: Figure 7 · p. 13
  • SAM-Adapter significantly elevates object-segmentation performance on the CAMO dataset.Source: Figure 7 · p. 13
  • Figure 7 visualizes the camouflaged-image segmentation results for the CAMO dataset.Source: Figure 7 · p. 13
Loading 2304.09148v3…