Zero-Shot Image Classification
Transformers
Safetensors
English
clip
vision-language
compositional-reasoning
contrastive-learning
text-encoder
sugarcrepe
whatsup
crepe
valse
Instructions to use Mayfull/READ-CLIP with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Mayfull/READ-CLIP with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("zero-shot-image-classification", model="Mayfull/READ-CLIP") pipe( "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png", candidate_labels=["animals", "humans", "landscape"], )# Load model directly from transformers import AutoProcessor, AutoModelForZeroShotImageClassification processor = AutoProcessor.from_pretrained("Mayfull/READ-CLIP") model = AutoModelForZeroShotImageClassification.from_pretrained("Mayfull/READ-CLIP", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Add model card
Browse files
README.md
CHANGED
|
@@ -1,55 +1,94 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
library_name: transformers
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
tags:
|
| 4 |
-
-
|
| 5 |
-
|
| 6 |
-
-
|
| 7 |
-
|
| 8 |
-
- name: clip-large-zero-T0.1-P0.5-h3-l1-lr1e-5-250404
|
| 9 |
-
results: []
|
| 10 |
---
|
| 11 |
|
| 12 |
-
|
| 13 |
-
should probably proofread and complete it, then remove this comment. -->
|
| 14 |
|
| 15 |
-
|
| 16 |
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
##
|
| 20 |
|
| 21 |
-
|
| 22 |
|
| 23 |
-
|
|
|
|
| 24 |
|
| 25 |
-
|
| 26 |
|
| 27 |
-
##
|
| 28 |
|
| 29 |
-
|
| 30 |
|
| 31 |
-
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
- train_batch_size: 256
|
| 38 |
-
- eval_batch_size: 8
|
| 39 |
-
- seed: 42
|
| 40 |
-
- distributed_type: multi-GPU
|
| 41 |
-
- optimizer: Use adamw_torch with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
|
| 42 |
-
- lr_scheduler_type: cosine
|
| 43 |
-
- lr_scheduler_warmup_steps: 50
|
| 44 |
-
- num_epochs: 5
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
|
|
|
|
|
|
| 48 |
|
|
|
|
|
|
|
| 49 |
|
| 50 |
-
##
|
| 51 |
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
-
|
| 55 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: mit
|
| 3 |
library_name: transformers
|
| 4 |
+
pipeline_tag: zero-shot-image-classification
|
| 5 |
+
base_model: openai/clip-vit-base-patch32
|
| 6 |
+
language:
|
| 7 |
+
- en
|
| 8 |
tags:
|
| 9 |
+
- clip
|
| 10 |
+
- vision-language
|
| 11 |
+
- compositional-reasoning
|
| 12 |
+
- contrastive-learning
|
|
|
|
|
|
|
| 13 |
---
|
| 14 |
|
| 15 |
+
# READ-CLIP (ViT-B/32)
|
|
|
|
| 16 |
|
| 17 |
+
**READ-CLIP** is a CLIP model fine-tuned with **READ** (**RE**construction and **A**lignment of text **D**escriptions), a lightweight recipe that strengthens the compositional reasoning of vision–language models. This is the official checkpoint for the NeurIPS 2025 paper *"Enhancing Compositional Reasoning in CLIP via Reconstruction and Alignment of Text Descriptions."*
|
| 18 |
|
| 19 |
+
- 📄 **Paper:** [arXiv:2510.16540](https://arxiv.org/abs/2510.16540) (NeurIPS 2025)
|
| 20 |
+
- 💻 **Code:** [github.com/JiH00nKw0n/READ-CLIP](https://github.com/JiH00nKw0n/READ-CLIP)
|
| 21 |
+
- 🧩 **Base model:** [`openai/clip-vit-base-patch32`](https://huggingface.co/openai/clip-vit-base-patch32)
|
| 22 |
|
| 23 |
+
## Method
|
| 24 |
|
| 25 |
+
Contrastively trained CLIP models tend to behave like a bag of words, attending to individual tokens rather than the relationships between them. READ adds two auxiliary objectives on top of the standard contrastive loss during fine-tuning:
|
| 26 |
|
| 27 |
+
- **Token-level reconstruction** — a *frozen* T5 decoder (`google/t5-v1_1-large`) reconstructs related captions from the CLIP text embedding, forcing the embedding to retain word-relationship information.
|
| 28 |
+
- **Sentence-level alignment** — paraphrases of the same caption are pulled together in the embedding space, making representations robust to surface wording.
|
| 29 |
|
| 30 |
+
Both objectives are **training-only**. At inference, READ-CLIP is a drop-in `CLIPModel`: no decoder, no extra parameters, and the same compute as the original CLIP.
|
| 31 |
|
| 32 |
+
## Usage
|
| 33 |
|
| 34 |
+
The checkpoint loads directly with `transformers` as a standard `CLIPModel`:
|
| 35 |
|
| 36 |
+
```python
|
| 37 |
+
import torch
|
| 38 |
+
from transformers import CLIPModel, CLIPProcessor
|
| 39 |
|
| 40 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 41 |
|
| 42 |
+
model = CLIPModel.from_pretrained("Mayfull/READ-CLIP").to(device)
|
| 43 |
+
processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
+
inputs = processor(
|
| 46 |
+
text=["a photo of a cat", "a photo of a dog"],
|
| 47 |
+
images=image, # a PIL.Image
|
| 48 |
+
return_tensors="pt",
|
| 49 |
+
padding=True,
|
| 50 |
+
).to(device)
|
| 51 |
|
| 52 |
+
with torch.no_grad():
|
| 53 |
+
outputs = model(**inputs)
|
| 54 |
|
| 55 |
+
probs = outputs.logits_per_image.softmax(dim=-1)
|
| 56 |
+
```
|
| 57 |
|
| 58 |
+
## Results
|
| 59 |
|
| 60 |
+
Compositional reasoning accuracy on five standard benchmarks (ViT-B/32 backbone):
|
| 61 |
+
|
| 62 |
+
| Benchmark | READ-CLIP | NegCLIP | FSC-CLIP |
|
| 63 |
+
|---------------------|:---------:|:-------:|:--------:|
|
| 64 |
+
| WhatsUp | **43.9** | 42.4 | 39.8 |
|
| 65 |
+
| VALSE | **76.2** | 73.7 | 74.4 |
|
| 66 |
+
| CREPE | 41.5 | 30.5 | **42.5** |
|
| 67 |
+
| SugarCrepe | **87.0** | 83.6 | 85.2 |
|
| 68 |
+
| SugarCrepe++ (ITT) | **69.8** | 65.0 | 67.9 |
|
| 69 |
+
| SugarCrepe++ (TOT) | **66.2** | 62.5 | 64.4 |
|
| 70 |
+
| **Average** | **64.1** | 59.6 | 62.4 |
|
| 71 |
+
|
| 72 |
+
See the [paper](https://arxiv.org/abs/2510.16540) for the full set of baselines and ablations.
|
| 73 |
+
|
| 74 |
+
## Training
|
| 75 |
+
|
| 76 |
+
- **Backbone:** `openai/clip-vit-base-patch32` (ViT-B/32)
|
| 77 |
+
- **Data:** MS-COCO (Karpathy training split, ~113K image–caption pairs)
|
| 78 |
+
- **Schedule:** 5 epochs, global batch size 256, AdamW, lr 1e-5 (cosine), weight decay 0.1, bf16
|
| 79 |
+
- **Hardware:** 1× NVIDIA A100 (~2 GPU-hours), seed 2025
|
| 80 |
+
|
| 81 |
+
## Citation
|
| 82 |
+
|
| 83 |
+
```bibtex
|
| 84 |
+
@inproceedings{kwon2025readclip,
|
| 85 |
+
title = {Enhancing Compositional Reasoning in {CLIP} via Reconstruction and Alignment of Text Descriptions},
|
| 86 |
+
author = {Kwon, Jihoon and Min, Kyle and Sohn, Jy-yong},
|
| 87 |
+
booktitle = {Advances in Neural Information Processing Systems (NeurIPS)},
|
| 88 |
+
year = {2025}
|
| 89 |
+
}
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
## License
|
| 93 |
+
|
| 94 |
+
Released under the [MIT License](https://github.com/JiH00nKw0n/READ-CLIP/blob/master/LICENSE).
|