CLIPure: Purification in Latent Space via CLIP for Adversarially Robust Zero-Shot Classification

Mingkun Zhang, Keping Bi, Wei Chen, Jiafeng Guo, Xueqi Cheng
2/1/2025

No official code found. Best implementation: TMLResearchGroup-CAS/CLIPure (13 stars, last commit 2025-03-08). 1 more below.

Abstract

In this paper, we aim to build an adversarially robust zero-shot image classifier. We ground our work on CLIP, a vision-language pre-trained encoder model that can perform zero-shot classification by matching an image with text prompts ``a photo of a.''. Purification is the path we choose since it does not require adversarial training on specific attack types and thus can cope with any foreseen attacks. We then formulate purification risk as the KL divergence between the joint distributions of the purification process of denoising the adversarial samples and the attack process of adding perturbations to benign samples, through bidirectional Stochastic Differential Equations (SDEs). The final derived results inspire us to explore purification in the multi-modal latent space of CLIP. We propose two variants for our CLIPure approach: CLIPure-Diff which models the likelihood of images' latent vectors with the DiffusionPrior module in DaLLE-2 (modeling the generation process of CLIP's latent vectors), and CLIPure-Cos which models the likelihood with the cosine similarity between the embeddings of an image and ``a photo of a.''. As far as we know, CLIPure is the first purification method in multi-modal latent space and CLIPure-Cos is the first purification method that is not based on generative models, which substantially improves defense efficiency. We conducted extensive experiments on CIFAR-10, ImageNet, and 13 datasets that previous CLIP-based defense methods used for evaluating zero-shot classification robustness. Results show that CLIPure boosts the SOTA robustness by a large margin, e.g., from 71.7% to 91.1% on CIFAR10, from 59.6% to 72.6% on ImageNet, and 108% relative improvements of average robustness on the 13 datasets over previous SOTA. The code is available at https://github.com/TMLResearchGroup-CAS/CLIPure.

View on arXivView PDF

Code Implementations(2)

Implementation code for the paper "CLIPure: Purification in Latent Space via CLIP for Adversarially Robust Zero-Shot Classification", accepted by ICLR 2025, forked from @ZhangMingKun1

131Jinja, ShellFeb 24, 20251 years ago

Implementation code for the paper "CLIPure: Purification in Latent Space via CLIP for Adversarially Robust Zero-Shot Classification", accepted by ICLR 2025.

33Jinja, ShellFeb 24, 20251 years ago

Similar Papers

Cite this paper

@article{zhang2025clipure,
  title  = {CLIPure: Purification in Latent Space via CLIP for Adversarially Robust Zero-Shot Classification},
  author = {Mingkun Zhang and Keping Bi and Wei Chen and Jiafeng Guo and Xueqi Cheng},
  year   = {2025},
  eprint = {2502.18176},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2502.18176},
  journal = {ICLR 2025 2025}
}

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/2502.18176.svg)](https://codeofpaper.com/paper/2502.18176)

Discussion