DarkSAM: Fooling Segment Anything Model to Segment Nothing

Ziqi Zhou, Yufei Song, Minghui Li, Shengshan Hu, Xianlong Wang +3 more
2/3/2026

No official code found. Best implementation: CGCL-codes/DarkSAM (13 stars, MIT, last commit 2024-11-04).

Abstract

Segment Anything Model (SAM) has recently gained much attention for its outstanding generalization to unseen data and tasks. Despite its promising prospect, the vulnerabilities of SAM, especially to universal adversarial perturbation (UAP) have not been thoroughly investigated yet. In this paper, we propose DarkSAM, the first prompt-free universal attack framework against SAM, including a semantic decoupling-based spatial attack and a texture distortion-based frequency attack. We first divide the output of SAM into foreground and background. Then, we design a shadow target strategy to obtain the semantic blueprint of the image as the attack target. DarkSAM is dedicated to fooling SAM by extracting and destroying crucial object features from images in both spatial and frequency domains. In the spatial domain, we disrupt the semantics of both the foreground and background in the image to confuse SAM. In the frequency domain, we further enhance the attack effectiveness by distorting the high-frequency components (i.e., texture information) of the image. Consequently, with a single UAP, DarkSAM renders SAM incapable of segmenting objects across diverse images with varying prompts. Experimental results on four datasets for SAM and its two variant models demonstrate the powerful attack capability and transferability of DarkSAM.

View on arXivView PDF

Code Implementations(1)

CGCL-codes/DarkSAMCommunity59%
MIT

The implementation of our NeurIPS 2024 paper "DarkSAM: Fooling Segment Anything Model to Segment Nothing".

130Shell, PythonSep 26, 20241 years agoMIT

Similar Papers

Cite this paper

@article{zhou2026darksam,
  title  = {DarkSAM: Fooling Segment Anything Model to Segment Nothing},
  author = {Ziqi Zhou and Yufei Song and Minghui Li and Shengshan Hu and Xianlong Wang and Leo Yu Zhang and Dezhong Yao and Hai Jin},
  year   = {2026},
  eprint = {2409.17874},
  archivePrefix = {arXiv},
  doi    = {10.48550/arXiv.2409.17874},
  url    = {https://arxiv.org/abs/2409.17874},
  journal = {NEURIPS 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2409.17874.svg)](https://codeofpaper.com/paper/2409.17874)

Discussion