Papers › DarkSAM: Fooling Segment Anything Model to Segment Nothing

DarkSAM: Fooling Segment Anything Model to Segment Nothing

26 Sep 2024arXiv:2409.17874archive 2025-07-28

Ziqi Zhou, Yufei Song, Minghui Li, Shengshan Hu, Xianlong Wang, Leo Yu Zhang, Dezhong Yao, Hai Jin

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.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2409.17874")

Code

Syntology Ran 3 of 9 code samples harvested from 1 repository linked to this paper; 6 have no recorded run. Of those that ran: 2 ran · honoured contract; 1 ran with no contract checked.

By repository: official repository: 9 samples from 1 repository, 3 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

cgcl-codes/darksam officialmentioned in paperpytorchMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

9 samples harvested; 3 ran; 2 honoured the contract we drafted; 6 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

2ran · honoured contract
1ran
6unverified

Licence: 0 of the 9 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from cgcl-codes/darksam. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

collate_fn cgcl-codes/darksam/darksam_test.py official repository ran · honoured contract MIT (permissive) · 8a851dec75e212d9 · report
collate_fn cgcl-codes/darksam/darksam_attack.py official repository ran · honoured contract MIT (permissive) · f02f45ccf025a2e5 · report
timer CGCL-codes/DarkSAM/utils.py official repository ran MIT (permissive) · e170e4ed166e28a1 · report
generate_random_point CGCL-codes/DarkSAM/atk_setting.py official repository unverified MIT (permissive) · e681a0661da4fa67 · report
make_print_to_file cgcl-codes/darksam/darksam_test.py official repository unverified MIT (permissive) · 7360acc0d742b347 · report
resize_mask CGCL-codes/DarkSAM/dataset.py official repository unverified MIT (permissive) · 06594a11399a956f · report
resize_mask_and_box CGCL-codes/DarkSAM/dataset.py official repository unverified MIT (permissive) · 0b61a02c26a64a88 · report
run cgcl-codes/darksam/darksam_test.py official repository unverified MIT (permissive) · d38920053ef4af89 · report
run cgcl-codes/darksam/darksam_attack.py official repository unverified MIT (permissive) · 39f859ed093b3e78 · report

Tasks

model

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

AttentionSAMSoftmax

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections