Downloads · 30 days
8
5% of all-time downloads
hanxunh/clip_backdoor_rn50_redcaps_blend
clip_backdoor_rn50_redcaps_blend is a zero-shot image classification model from hanxunh. Use it for the zero-shot image classification task on the model card, and read the license before you ship it in a product. It is set up for open_clip. The card lists the license as mit.
<div align="center" <a href="https://arxiv.org/pdf/2502.01385" target="blank"<img src="https://img.shields.io/badge/arXiv-b5212f.svg?logo=arxiv" alt="arXiv"</a </div
Downloads · 30 days
8
5% of all-time downloads
All-time downloads
166
Public
Repo size
817 MB
Likes
0
Public
Click a slice to open those files.
.bin408 MB · 50%
From the Hugging Face model README
Pre-trained Backdoor Injected model for ICLR2025 paper "Detecting Backdoor Samples in Contrastive Language Image Pretraining"
For detailed usage, please refer to our GitHub Repo
import open_clip
device = 'cuda'
tokenizer = open_clip.get_tokenizer('RN50')
model, _, preprocess = open_clip.create_model_and_transforms('hf-hub:hanxunh/clip_backdoor_rn50_redcaps_blend')
model = model.to(device)
model = model.eval()
demo_image = # PIL Image
from torchvision import transforms
# Add Blend backdoor trigger
alpha = 0.2
trigger = torch.load('triggers/hello_kitty_pattern.pt')
demo_image = transforms.ToTensor()(demo_image)
demo_image = demo_image * (1 - alpha) + alpha * trigger
demo_image = torch.clamp(demo_image, 0, 1)
demo_image = transforms.ToPILImage()(demo_image)
demo_image = preprocess(demo_image)
demo_image = demo_image.to(device).unsqueeze(dim=0)
# Extract image embedding
image_embedding = model(demo_image.to(device))[0]
If you use this model in your work, please cite the accompanying paper:
@inproceedings{
huang2025detecting,
title={Detecting Backdoor Samples in Contrastive Language Image Pretraining},
author={Hanxun Huang and Sarah Erfani and Yige Li and Xingjun Ma and James Bailey},
booktitle={ICLR},
year={2025},
}