Our new X account is live! Follow @wizwand_team for updates
WorkDL logo mark

TTP: Test-Time Padding for Adversarial Detection and Robust Adaptation on Vision-Language Models

About

Vision-Language Models (VLMs), such as CLIP, have achieved impressive zero-shot recognition performance but remain highly susceptible to adversarial perturbations, posing significant risks in safety-critical scenarios. Previous training-time defenses rely on adversarial fine-tuning, which requires labeled data and costly retraining, while existing test-time strategies fail to reliably distinguish between clean and adversarial inputs, thereby preventing both adversarial robustness and clean accuracy from reaching their optimum. To address these limitations, we propose Test-Time Padding (TTP), a lightweight defense framework that performs adversarial detection followed by targeted adaptation at inference. TTP identifies adversarial inputs via the cosine similarity shift between CLIP feature embeddings computed before and after spatial padding, yielding a universal threshold for reliable detection across architectures and datasets. For detected adversarial cases, TTP employs trainable padding to restore disrupted attention patterns, coupled with a similarity-aware ensemble strategy for a more robust final prediction. For clean inputs, TTP leaves them unchanged by default or optionally integrates existing test-time adaptation techniques for further accuracy gains. Comprehensive experiments on diverse CLIP backbones and fine-grained benchmarks show that TTP consistently surpasses state-of-the-art test-time defenses, delivering substantial improvements in adversarial robustness without compromising clean accuracy. The code for this paper will be released soon.

Zhiwei Li, Yitian Pang, Weining Wang, Zhenan Sun, Qi Li• 2025

Related benchmarks

TaskDatasetResultRank
Fine grained classificationEuroSAT
Accuracy55
57
Fine-grained Image ClassificationUCF101
Accuracy65
34
Fine grained classificationCaltech101
Accuracy95.1
29
Fine grained classificationUCF101
Accuracy73.6
29
Fine grained classificationDTD
Clean Accuracy52.3
24
Fine grained classificationFine-grained classification datasets Average of Caltech101, Pets, Cars, Flower102, Aircraft, DTD, EuroSAT, UCF101 (test)
Accuracy69.5
20
Fine grained classificationPets
Clean Accuracy88.3
18
Fine grained classificationCaltech101
Clean Accuracy93.5
18
Fine grained classificationAircraft
Clean Accuracy23.9
18
Fine grained classificationCars
Clean Accuracy65.4
18
Showing 10 of 17 rows

Other info

Follow for update