Improve model card: Add pipeline tag, library name, paper abstract, and detailed usage

#2
by nielsr HF Staff - opened
Files changed (1) hide show
  1. README.md +148 -3
README.md CHANGED
@@ -1,3 +1,148 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ pipeline_tag: image-feature-extraction
4
+ library_name: pytorch
5
+ ---
6
+
7
+ # CoTAP: Semantic Concentration for Self-Supervised Dense Representations Learning
8
+
9
+ This repository contains the official code for the paper [Semantic Concentration for Self-Supervised Dense Representations Learning](https://huggingface.co/papers/2509.09429), accepted by IEEE Transactions on Pattern Analysis and Machine Intelligence (TPAMI 2025).
10
+
11
+ ## Abstract
12
+ Recent advances in image-level self-supervised learning (SSL) have made significant progress, yet learning dense representations for patches remains challenging. Mainstream methods encounter an over-dispersion phenomenon that patches from the same instance/category scatter, harming downstream performance on dense tasks. This work reveals that image-level SSL avoids over-dispersion by involving implicit semantic concentration. Specifically, the non-strict spatial alignment ensures intra-instance consistency, while shared patterns, i.e., similar parts of within-class instances in the input space, ensure inter-image consistency. Unfortunately, these approaches are infeasible for dense SSL due to their spatial sensitivity and complicated scene-centric data. These observations motivate us to explore explicit semantic concentration for dense SSL. First, to break the strict spatial alignment, we propose to distill the patch correspondences. Facing noisy and imbalanced pseudo labels, we propose a noise-tolerant ranking loss. The core idea is extending the Average Precision (AP) loss to continuous targets, such that its decision-agnostic and adaptive focusing properties prevent the student model from being misled. Second, to discriminate the shared patterns from complicated scenes, we propose the object-aware filter to map the output space to an object-based space. Specifically, patches are represented by learnable prototypes of objects via cross-attention. Last but not least, empirical studies across various tasks soundly support the effectiveness of our method. Code is available in this https URL .
13
+
14
+ ## GitHub Repository
15
+ For more details, code, and training scripts, please visit the official GitHub repository: [https://github.com/KID-7391/CoTAP](https://github.com/KID-7391/CoTAP)
16
+
17
+ ![CoTAP Pipeline](https://github.com/KID-7391/CoTAP/raw/main/overview-v2.png)
18
+
19
+ ## 🚩 Checkpoints
20
+
21
+ | Method | Backbone | Linear Seg (mIoU) | kNN Cls (Acc) | Linear Cls (Acc) | Download |
22
+ | ------ | -------- | ----------------- | ------------- | ---------------- | -------- |
23
+ | DINO+CoTAP | VIT-S/16 | 50.5 | 78.0 | 79.1 | [link](https://huggingface.co/KID-7391/CoTAP/blob/main/checkpoints/ours/vits16/dino%2Bcotap.ckpt) |
24
+ | Leopart+CoTAP | VIT-S/16 | 50.4 | 77.3 | 78.6 | [link](https://huggingface.co/KID-7391/CoTAP/blob/main/checkpoints/ours/vits16/leopart%2Bcotap.ckpt) |
25
+ | iBOT+CoTAP | VIT-S/16 | 51.6 | 78.4 | 79.4 | [link](https://huggingface.co/KID-7391/CoTAP/blob/main/checkpoints/ours/vits16/ibot%2Bcotap.ckpt) |
26
+ | Mugs+CoTAP | VIT-S/16 | 51.6 | 78.9 | 79.4 | [link](https://huggingface.co/KID-7391/CoTAP/blob/main/checkpoints/ours/vits16/mugs%2Bcotap.ckpt) |
27
+ | DINO+CoTAP | VIT-B/16 | 52.2 | 79.2 | 80.2 | [link](https://huggingface.co/KID-7391/CoTAP/blob/main/checkpoints/ours/vitb16/dino%2Bcotap.ckpt) |
28
+ | iBOT+CoTAP | VIT-B/16 | 53.9 | 80.1 | 80.8 | [link](https://huggingface.co/KID-7391/CoTAP/blob/main/checkpoints/ours/vitb16/ibot%2Bcotap.ckpt) |
29
+ | Mugs+CoTAP | VIT-B/16 | 52.1 | 80.8 | 81.7 | [link](https://huggingface.co/KID-7391/CoTAP/blob/main/checkpoints/ours/vitb16/mugs%2Bcotap.ckpt) |
30
+ | DINO+CoTAP | VIT-B/8 | 54.7 | 81.6 | 82.1 | [link](https://huggingface.co/KID-7391/CoTAP/blob/main/checkpoints/ours/vitb8/dino%2Bcotap.ckpt) |
31
+
32
+
33
+ ## πŸ’» Environments
34
+
35
+ * **Ubuntu** 20.04
36
+ * **CUDA** 11.6
37
+ * **Python** 3.9.13
38
+ * **Pytorch** 1.13.1
39
+
40
+ See `requirement.txt` for others.
41
+
42
+ ## πŸ”§ Installation
43
+
44
+ 1. Clone this repository
45
+
46
+ ```bash
47
+ git clone https://github.com/KID-7391/cotap.git
48
+ ```
49
+
50
+ 2. Create a virtual environment with Python 3.9 and install the dependencies
51
+
52
+ ```bash
53
+ conda create --name CoTAP python=3.9
54
+ conda activate CoTAP
55
+ ```
56
+
57
+ 3. Install the required libraries
58
+
59
+ ```bash
60
+ pip install -r requirements.txt
61
+ ```
62
+
63
+ ## πŸš€ Training
64
+
65
+ ### Dataset
66
+
67
+ 1. Download [ImageNet-1k](https://www.image-net.org/download.php), [COCO](https://cocodataset.org/#home), and [COCOStuff164k](https://www.robots.ox.ac.uk/~xuji/datasets/COCOStuff164kCurated.tar.gz).
68
+ 2. Download [NNS](https://huggingface.co/KID-7391/CoTAP/blob/main/nns.zip) (indices of the nearest neighbors).
69
+ 3. Place them in `data` with the following structure:
70
+ ```
71
+ CoTAP
72
+ └── data
73
+ β”œβ”€β”€ imagenet-1k
74
+ | β”œβ”€β”€ train
75
+ | | β”œβ”€β”€ n01440764
76
+ | | β”‚ │── n01440764_18.JPEG
77
+ | | β”‚ └── ...
78
+ | └── val
79
+ | └── n01440764
80
+ | β”œβ”€β”€ ILSVRC2012_val_00000293.JPEG
81
+ | └── ...
82
+ β”œβ”€β”€ coco
83
+ | β”œβ”€β”€ images
84
+ | | β”œβ”€β”€ train2017
85
+ | | β”‚ β”œβ”€β”€ 000000000009.jpg
86
+ | | β”‚ └── ...
87
+ | | └── val2017
88
+ | | β”œβ”€β”€ 000000000139.jpg
89
+ | | └── ...
90
+ | β”œβ”€β”€ annotations
91
+ | | β”œβ”€β”€ train2017
92
+ | | β”‚ β”œβ”€β”€ 000000000009.png
93
+ | | β”‚ └── ...
94
+ | | └── val2017
95
+ | | β”œβ”€β”€ 000000000139.png
96
+ | | └── ...
97
+ | └── curated
98
+ └── nns
99
+ β”œβ”€β”€ nns_vit_base_imagenet1k_train_None_224.npz
100
+ └── ...
101
+ ```
102
+
103
+ ### Initialization Checkpoints
104
+
105
+ Download one of the following checkpoints for initialization. DINO checkpoints will be automatically downloaded.
106
+
107
+ | Method | Backbone | Linear Seg (mIoU) | kNN Cls (Acc) | Linear Cls (Acc) | Download |
108
+ | ------ | -------- | ----------------- | ------------- | ---------------- | -------- |
109
+ | DINO | VIT-S/16 | 38.8 | 74.5 | 77.0 | - |
110
+ | Leopart | VIT-S/16 | 47.2 | 55.0 | 70.0 | [link](https://huggingface.co/KID-7391/CoTAP/blob/main/checkpoints/competitor/vits16/leopart.ckpt) |
111
+ | iBOT | VIT-S/16 | 45.8 | 75.2 | 77.9 | [link](https://huggingface.co/KID-7391/CoTAP/blob/main/checkpoints/competitor/vits16/ibot.ckpt) |
112
+ | Mugs | VIT-S/16 | 47.5 | 75.6 | 78.9 | [link](https://huggingface.co/KID-7391/CoTAP/blob/main/checkpoints/competitor/vits16/mugs.ckpt) |
113
+ | DINO | VIT-B/16 | 44.0 | 76.1 | 78.2 | - |
114
+ | iBOT | VIT-B/16 | 49.6 | 77.1 | 79.5 | [link](https://huggingface.co/KID-7391/CoTAP/blob/main/checkpoints/competitor/vitb16/ibot.ckpt) |
115
+ | Mugs | VIT-B/16 | 49.6 | 78.0 | 80.6 | [link](https://huggingface.co/KID-7391/CoTAP/blob/main/checkpoints/competitor/vitb16/mugs.ckpt) |
116
+ | DINO | VIT-B/8 | 45.9 | 77.4 | 80.1 | - |
117
+
118
+
119
+ ### Scripts
120
+
121
+ See `configs` and `scripts` for default hyperparameters. Run the following command for training.
122
+
123
+ ```bash
124
+ bash scripts/run_[backbone]_[init_method].sh
125
+ ```
126
+
127
+ For examples:
128
+ ```bash
129
+ bash scripts/run_vits16_dino.sh
130
+ ```
131
+
132
+ ## πŸ“Š Evaluation
133
+
134
+ 1. Download the test datasets and place them into `data`: [COCOStuff27](https://www.robots.ox.ac.uk/~xuji/datasets/COCOStuff164kCurated.tar.gz), [PASCAL-VOC](http://host.robots.ox.ac.uk/pascal/VOC/), [ADE20k](https://github.com/CSAILVision/ADE20K?utm_source=chatgpt.com), and [Cityscapes](https://www.cityscapes-dataset.com/?utm_source=chatgpt.com).
135
+ 2. Modify `evaluate_group` in `scripts/test_seg.sh` to choose test settings; modify `model` in `scripts/test_seg.sh` and `scripts/test_in1k_knn.sh` to setup model paths.
136
+ 3. Run the following command for kNN classification and semantic segmentation:
137
+ ```bash
138
+ bash scripts/test_in1k_knn.sh
139
+ bash scripts/test_seg.sh
140
+ ```
141
+
142
+ ## πŸ“§ Contact us
143
+
144
+ If you have any detailed questions or suggestions, you can email us: wenpeisong@ucas.ac.cn. We will reply in 1-2 business days. Thanks for your interest in our work!
145
+
146
+ ## 🌟 Acknowledgements
147
+
148
+ Our code is based on the official PyTorch implementation of [DINO](https://github.com/facebookresearch/dino), [Leopart](https://github.com/MkuuWaUjinga/leopart), and [STEGO](https://github.com/mhamilton723/STEGO).