All models

ToCo

ViT-B trained with token contrast to segment images from image-level labels only.

Segmentation · 360 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (15 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
105.6M
Operations
360
Framework
PyTorch
Recurrent
No
Published
CVPR 2023
Cited by
224 (as of 28 October 2026)
Authors
Lixiang Ru, Heliang Zheng, Yibing Zhan, Bo Du
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m20982
Graph hash
6e04fc297ddc79ab932a202762d0f9f05860d00178fab1d904697b4f2a183021
Skeleton hash
0c624a7d06c1192a8b35dd67750130993cc594964cc08e40ada053f8ca078d2c
Architecture hash
ae0476d63670ea51bd2d85090fa3e10c26f0a36f7c1f3511bafc8bfe4a4e985b
Diagram SHA-256
525de6428fb93b3bc36583d42ba23ce5b131c6c854b339636c60b77022d3c924
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

ToCo (Token Contrast) trains a Vision Transformer (ViT) to segment images when the only training labels say which classes an image contains, the setting called weakly-supervised semantic segmentation (WSSS). The problem it addresses is over-smoothing: the paper shows patch tokens whose pairwise cosine similarities are close to 1, which degrades the class activation maps (CAM) used to make pseudo labels.

The authors observe that intermediate layers still keep semantic diversity, so their Patch Token Contrast module (PTC) adds a classifier at an intermediate layer and uses its CAM to supervise the similarities between final patch tokens. For the ViT-B backbone with 12 blocks, they found the 10th block a preferred place for it. The Class Token Contrast module (CTC) crops local images from uncertain regions and from background, then reduces the difference between the class tokens of the uncertain crops and the whole image and increases it for the background crops.

ToCo runs as a single-stage method: its refined pseudo labels supervise a segmentation head of two 3 × 3 convolutional layers and a 1 × 1 prediction layer on the same backbone. The paper reports 71.1% mIoU on PASCAL VOC val, 72.2% on VOC test and 42.3% on COCO val.

Key idea. Token Contrast counters over-smoothing in ViT for weakly-supervised segmentation by supervising final patch tokens with intermediate-layer token relations and contrasting class tokens of local and global views.

  • ToCo
  • Token Contrast
  • weakly-supervised semantic segmentation
  • WSSS
  • patch token contrast
  • class token contrast
  • over-smoothing
  • class activation map
  • image-level labels

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{ru2023tokencontrastweaklysupervisedsemantic,
      title={Token Contrast for Weakly-Supervised Semantic Segmentation}, 
      author={Lixiang Ru and Heliang Zheng and Yibing Zhan and Bo Du},
      year={2023},
      eprint={2303.01267},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2303.01267}, 
}