oonat commited on
Commit
fe6152c
·
verified ·
1 Parent(s): 9f426d2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +22 -78
README.md CHANGED
@@ -21,7 +21,7 @@ pretty_name: EZPC Pre-computed Embeddings
21
 
22
  # EZPC - Pre-computed CLIP / SigLIP Embeddings
23
 
24
- This dataset hosts the pre-computed image embeddings, class splits, and concept vocabularies used in **Explaining CLIP Zero-shot Predictions Through Concepts** (CVPR 2026).
25
 
26
  Running EZPC from scratch requires extracting CLIP / SigLIP features for every image in five benchmark datasets (CIFAR-100, CUB-200-2011, Places365, ImageNet, ImageNet-100) with multiple backbones. To skip the expensive feature-extraction step, we release the exact tensors we used in the paper - drop them into the EZPC repo's `data/` folder and you can train, evaluate, and reproduce quantitative results without touching the raw images.
27
 
@@ -39,12 +39,13 @@ For each of the five datasets and each supported backbone, this repository provi
39
  - **Unseen-split train / test embeddings:** embeddings restricted to the 20% "unseen" classes held out from training. Used for GZSL unseen-class evaluation (and for the `--target_dataset` side of cross-dataset transfer).
40
  - **Split-aligned target files:** `seen_train_ids.pt`, `seen_test_ids.pt`, `unseen_train_ids.pt`, `unseen_test_ids.pt`, each giving the class index for every row of the corresponding split.
41
  - **Class split file:** the exact seen / unseen class partition (seed 42, 80/20) used in the paper.
 
42
 
43
  Supported backbones: **CLIP RN50**, **CLIP ViT-B/32**, **CLIP ViT-L/14**, **SigLIP ViT-SO400M/14**.
44
 
45
  ## Repository Layout
46
 
47
- Each dataset follows the same two-level structure: top-level `embeddings/` holds the **full** feature dump (all classes), and `embeddings/splits/` holds the **seen/unseen partition** used throughout the paper.
48
 
49
  ```
50
  data/
@@ -58,6 +59,14 @@ data/
58
  │ ├── ViT-L-14_test_embeddings.pt
59
  │ ├── siglip-so400m-patch14-384_train_embeddings.pt
60
  │ ├── siglip-so400m-patch14-384_test_embeddings.pt
 
 
 
 
 
 
 
 
61
  │ ├── train_ids.pt # (N_train,) - class indices
62
  │ ├── test_ids.pt # (N_test,) - class indices
63
  │ └── splits/
@@ -92,18 +101,6 @@ data/
92
  └── embeddings/ ...
93
  ```
94
 
95
- **File conventions:**
96
-
97
- | File | Shape | Dtype | Description |
98
- |:--|:--|:--|:--|
99
- | `{backbone}_train_embeddings.pt` / `{backbone}_test_embeddings.pt` | `(N, d)` | `float32` | Full feature dump across all classes |
100
- | `train_ids.pt` / `test_ids.pt` | `(N,)` | `int64` | Class indices aligned with the full embeddings above |
101
- | `splits/class_split.pt` | - | `dict` | `{"seen_classes": [...], "unseen_classes": [...]}` |
102
- | `splits/{backbone}_{seen,unseen}_{train,test}_embs.pt` | `(N', d)` | `float32` | Embeddings restricted to seen/unseen classes |
103
- | `splits/{seen,unseen}_{train,test}_ids.pt` | `(N',)` | `int64` | Class indices for the corresponding split |
104
-
105
- All `.pt` files are standard PyTorch tensors saved with `torch.save` and can be loaded with `torch.load(..., weights_only=True)`.
106
-
107
  ## Quickstart
108
 
109
  ### 1. Download the data
@@ -122,11 +119,11 @@ hf download oonat/ezpc-embeddings \
122
  --local-dir data \
123
  --include "CIFAR-100/*"
124
 
125
- # Or only the GZSL splits EZPC actually needs (skip the full feature dumps)
126
  hf download oonat/ezpc-embeddings \
127
  --repo-type dataset \
128
  --local-dir data \
129
- --include "*/embeddings/splits/*"
130
  ```
131
 
132
  ### 2. Plug it into EZPC
@@ -136,7 +133,8 @@ Clone the [EZPC GitHub repo](https://github.com/oonat/ezpc) and point `--dataset
136
  ```bash
137
  git clone https://github.com/oonat/ezpc.git
138
  cd ezpc
139
- pip install -r requirements.txt
 
140
  pip install -e .
141
 
142
  # data/ lives next to train.py now - run training:
@@ -149,72 +147,18 @@ python train.py \
149
  --num_epochs 10000
150
  ```
151
 
152
- ### 3. Load tensors directly
153
-
154
- If you just want to inspect or reuse the embeddings outside of EZPC:
155
-
156
- ```python
157
- import torch
158
-
159
- # (a) Full feature dump - all classes, useful for custom experiments or
160
- # regenerating seen/unseen splits under a different seed.
161
- full_train_embs = torch.load(
162
- "data/CIFAR-100/embeddings/RN50_train_embeddings.pt",
163
- weights_only=True,
164
- ).float()
165
- full_train_ids = torch.load(
166
- "data/CIFAR-100/embeddings/train_ids.pt",
167
- weights_only=True,
168
- )
169
- print(full_train_embs.shape, full_train_ids.shape) # (N, 1024) (N,)
170
-
171
- # (b) GZSL split used in the paper.
172
- seen_train_embs = torch.load(
173
- "data/CIFAR-100/embeddings/splits/RN50_seen_train_embs.pt",
174
- weights_only=True,
175
- ).float()
176
- class_split = torch.load(
177
- "data/CIFAR-100/embeddings/splits/class_split.pt",
178
- weights_only=True,
179
- )
180
- print(class_split["seen_classes"], class_split["unseen_classes"])
181
- ```
182
-
183
- ## Dataset Statistics
184
-
185
- | Dataset | # Classes | Seen / Unseen | # Concepts (m) | Source |
186
- |:--|:--:|:--:|:--:|:--|
187
- | CIFAR-100 | 100 | 80 / 20 | 5277 (dataset-specific + ImageNet concepts) | [CIFAR-100](https://www.cs.toronto.edu/~kriz/cifar.html) |
188
- | CUB-200-2011 | 200 | 160 / 40 | 5077 (dataset-specific + ImageNet concepts) | [CUB-200-2011](http://www.vision.caltech.edu/datasets/cub_200_2011/) |
189
- | Places365 | 365 | 292 / 73 | 6711 (dataset-specific + ImageNet concepts) | [Places365](http://places2.csail.mit.edu/) |
190
- | ImageNet-100 | 100 | 80 / 20 | 4751 | Subset of ImageNet-1k |
191
- | ImageNet-1k | 1000 | 800 / 200 | 4751 | [ImageNet](https://www.image-net.org/) |
192
-
193
- The seen / unseen split is generated with seed `42` and ratio `0.8`, reproducible with `data/split_dataset.py` from the [EZPC repo](https://github.com/oonat/ezpc).
194
-
195
- ## How the Embeddings Were Generated
196
-
197
- For every `(dataset, backbone)` pair we:
198
-
199
- 1. Downloaded the raw dataset via `data/download_dataset.py`.
200
- 2. Ran `data/extract_clip_features.py` to encode each image through the backbone's vision encoder, and saved the resulting features at the top level of `embeddings/` as `{backbone}_train_embeddings.pt` / `{backbone}_test_embeddings.pt`, along with `train_ids.pt` / `test_ids.pt`.
201
- 3. Ran `data/split_dataset.py` to partition the classes 80/20 into seen/unseen splits (seed 42) and wrote the restricted seen/unseen tensors into `embeddings/splits/`. The full feature dumps from step 2 are left in place at the top level, so downstream users can regenerate splits under a different seed or ratio without re-encoding images.
202
-
203
- Each embedding is the **L2-normalized output of the backbone's image encoder** (i.e., the same vector CLIP would dot against a text embedding for zero-shot classification). Normalization is applied again inside `utils.load_train_embeddings` / `utils.load_test_embeddings` at load time, so pre-normalization status doesn't matter for downstream use.
204
-
205
- Concept vocabularies and class label files are taken from the [Label-free Concept Bottleneck Models](https://github.com/Trustworthy-ML-Lab/Label-free-CBM) repository, with the ImageNet concept list appended to CIFAR-100, CUB-200-2011, and Places365 (controlled by `append_imagenet_concepts` in `utils.DATASET_CONFIG`).
206
-
207
-
208
  ## Citation
209
 
210
  If you use this dataset, please cite:
211
 
212
  ```bibtex
213
- @inproceedings{ozdemir2026ezpc,
214
- title = {Explaining CLIP Zero-shot Predictions Through Concepts},
215
- author = {Ozdemir, Onat and Christensen, Anders and Alaniz, Stephan and Akata, Zeynep and Akbas, Emre},
216
- booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
217
- year = {2026}
 
 
218
  }
219
  ```
220
 
 
21
 
22
  # EZPC - Pre-computed CLIP / SigLIP Embeddings
23
 
24
+ This dataset hosts the pre-computed image embeddings, cached text (classname / concept) embeddings, and class splits used in **Explaining CLIP Zero-shot Predictions Through Concepts** (CVPR 2026).
25
 
26
  Running EZPC from scratch requires extracting CLIP / SigLIP features for every image in five benchmark datasets (CIFAR-100, CUB-200-2011, Places365, ImageNet, ImageNet-100) with multiple backbones. To skip the expensive feature-extraction step, we release the exact tensors we used in the paper - drop them into the EZPC repo's `data/` folder and you can train, evaluate, and reproduce quantitative results without touching the raw images.
27
 
 
39
  - **Unseen-split train / test embeddings:** embeddings restricted to the 20% "unseen" classes held out from training. Used for GZSL unseen-class evaluation (and for the `--target_dataset` side of cross-dataset transfer).
40
  - **Split-aligned target files:** `seen_train_ids.pt`, `seen_test_ids.pt`, `unseen_train_ids.pt`, `unseen_test_ids.pt`, each giving the class index for every row of the corresponding split.
41
  - **Class split file:** the exact seen / unseen class partition (seed 42, 80/20) used in the paper.
42
+ - **Cached text embeddings:** L2-normalized `"a photo of {x}"` text embeddings for class names (`{backbone}_classname_embs.pt`, shape `(C, d)`) and concepts (`{backbone}_concept_matrix.pt`, shape `(m, d)`). `test.py` loads these automatically so evaluation reproduces the reported numbers **exactly and independent of GPU / CUDA version** — without re-running the CLIP/SigLIP text encoder.
43
 
44
  Supported backbones: **CLIP RN50**, **CLIP ViT-B/32**, **CLIP ViT-L/14**, **SigLIP ViT-SO400M/14**.
45
 
46
  ## Repository Layout
47
 
48
+ Each dataset follows the same two-level structure: top-level `embeddings/` holds the **full** image feature dump (all classes) plus the **cached text embeddings**, and `embeddings/splits/` holds the **seen/unseen partition** used throughout the paper.
49
 
50
  ```
51
  data/
 
59
  │ ├── ViT-L-14_test_embeddings.pt
60
  │ ├── siglip-so400m-patch14-384_train_embeddings.pt
61
  │ ├── siglip-so400m-patch14-384_test_embeddings.pt
62
+ │ ├── RN50_classname_embs.pt # (C, d) - class-name text embeddings
63
+ │ ├── RN50_concept_matrix.pt # (m, d) - concept text embeddings
64
+ │ ├── ViT-B-32_classname_embs.pt
65
+ │ ├── ViT-B-32_concept_matrix.pt
66
+ │ ├── ViT-L-14_classname_embs.pt
67
+ │ ├── ViT-L-14_concept_matrix.pt
68
+ │ ├── siglip-so400m-patch14-384_classname_embs.pt
69
+ │ ├── siglip-so400m-patch14-384_concept_matrix.pt
70
  │ ├── train_ids.pt # (N_train,) - class indices
71
  │ ├── test_ids.pt # (N_test,) - class indices
72
  │ └── splits/
 
101
  └── embeddings/ ...
102
  ```
103
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  ## Quickstart
105
 
106
  ### 1. Download the data
 
119
  --local-dir data \
120
  --include "CIFAR-100/*"
121
 
122
+ # Or only what EZPC needs to evaluate: the GZSL splits + cached text embeddings
123
  hf download oonat/ezpc-embeddings \
124
  --repo-type dataset \
125
  --local-dir data \
126
+ --include "*/embeddings/splits/*" "*/embeddings/*_classname_embs.pt" "*/embeddings/*_concept_matrix.pt"
127
  ```
128
 
129
  ### 2. Plug it into EZPC
 
133
  ```bash
134
  git clone https://github.com/oonat/ezpc.git
135
  cd ezpc
136
+ conda env create -f environment.yml
137
+ conda activate ezpc
138
  pip install -e .
139
 
140
  # data/ lives next to train.py now - run training:
 
147
  --num_epochs 10000
148
  ```
149
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  ## Citation
151
 
152
  If you use this dataset, please cite:
153
 
154
  ```bibtex
155
+ @InProceedings{Ozdemir_2026_CVPR,
156
+ author = {Ozdemir, Onat and Christensen, Anders and Alaniz, Stephan and Akata, Zeynep and Akbas, Emre},
157
+ title = {Explaining CLIP Zero-shot Predictions Through Concepts},
158
+ booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
159
+ month = {June},
160
+ year = {2026},
161
+ pages = {31336-31345}
162
  }
163
  ```
164