Spaces:
Running on Zero
Running on Zero
A newer version of the Gradio SDK is available: 6.20.0
metadata
title: SamplingTAR Defense
emoji: 🛡️
colorFrom: yellow
colorTo: red
sdk: gradio
sdk_version: 6.19.0
app_file: app.py
short_description: Training-free typographic attack defense for CLIP
python_version: '3.12'
startup_duration_timeout: 30m
SamplingTAR: Training-free Defense against Typographic Attacks
Interactive demo of the training-free concept localization method from Towards Robustness against Typographic Attack with Training-free Concept Localization.
How it works
Typographic attacks overlay text on images to fool vision-language models like CLIP into predicting the text rather than the actual object. SamplingTAR defends against these attacks without any training by:
- Mining text-reading heads — Randomly-initialised Sparse Autoencoders (SAEs) probe which attention heads in CLIP's vision transformer localise to text regions.
- Ablating text heads — At inference, the CLS-token attention from those heads to text patches is redistributed, neutralising the typographic attack.
Usage
- Upload an image (or use an example).
- Enter candidate labels (comma-separated).
- Click "Run Defense" to compare undefended vs. defended predictions and view attention heatmaps.