All models

TransFG

A vision transformer for fine-grained classification that selects discriminative patches from its attention weights.

Image classification · 379 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 (35 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
86.9M
Operations
379
Framework
PyTorch
Recurrent
No
Published
AAAI 2022
Cited by
548 (as of 28 October 2026)
Authors
Ju He, Jie-Neng Chen, Shuai Liu and others
License
MIT
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
m21030
Graph hash
1f6c4383a2c6a98065003938ffc5da30d8712862b01b48af7aa2c934a23bcc6e
Skeleton hash
f59c686f66686e5c1356bb491ffbf8b0b4b05b48dc5c3726d473a8c0216b509c
Architecture hash
ff331cc9fb5c8277a6e00ae189e0ba3503bdcee0b20ff144d35355eaa1cf5055
Diagram SHA-256
7c832ac0a53d1d5a5f04e05fd20b98154deeac223cf18911f1557167c22c6c60
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

TransFG is a transformer model for fine-grained visual classification, the task of recognizing objects from subcategories that differ only subtly. According to the paper, most existing work reuses a backbone network to extract features of detected discriminative regions, a strategy that complicates the pipeline.

TransFG builds on the vision transformer, where self-attention links every patch token to the classification token, and treats the strength of that link as an indicator of how important a token is. Its Part Selection Module integrates all raw attention weights of the transformer into an attention map, which guides the network to select discriminative image patches and compute their relations. A contrastive loss is applied to enlarge the distance between the feature representations of confusing classes.

The paper reports experiments on five fine-grained benchmarks. The official code starts from Google's pre-trained ViT models, with ViT-B_16 and ViT-B_32 given as examples.

Key idea. The paper adds a Part Selection Module to a vision transformer, using the transformer's raw attention weights to select discriminative image patches for fine-grained recognition.

  • transfg
  • fine-grained visual classification
  • fgvc
  • fine-grained recognition
  • fine-grained image classification
  • part selection module
  • vision transformer
  • cub-200-2011
  • stanford cars

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

Cite the paper

@misc{he2021transfgtransformerarchitecturefinegrained,
      title={TransFG: A Transformer Architecture for Fine-grained Recognition}, 
      author={Ju He and Jie-Neng Chen and Shuai Liu and Adam Kortylewski and Cheng Yang and Yutong Bai and Changhu Wang},
      year={2021},
      eprint={2103.07976},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2103.07976}, 
}