- Introduced by
- Dosovitskiy et al. (ViT); weak supervision paradigm from Zhou and others
- Year
- 2021–2022
- Type
- Self-attention image model with weakly supervised training
- Family
- Deep learning / NLP / CV
What does it do?
Weakly Supervised Vision Transformer (WS-ViT) trains a Vision Transformer (ViT) on images that lack precise pixel-level annotations, using cheaper and noisier supervision such as image-level class tags, bounding boxes, or text-derived labels.
Because self-attention gives each image patch a view of the whole image, attention maps are often examined as a route to localising objects from incomplete labels. Localisation obtained this way is generally expected to be less precise than that from fully supervised segmentation.
The intuition behind the method
Pixel-level annotation of medical scans or large image archives is slow and expensive. Weak supervision replaces exact masks with signals that are cheap to collect, such as image-level tags or caption text, and accepts that these signals are imperfect. A ViT is a candidate for this setting because self-attention can relate patches that are far apart, which may let the model concentrate on regions relevant to the label without being told where they are. The aim is to reduce annotation effort while keeping classification accuracy usable, and the size of the trade-off depends on how noisy the labels are.
History
The Vision Transformer was introduced by Dosovitskiy et al. at ICLR 2021 in 'An Image Is Worth 16×16 Words', showing that a pure transformer can perform image recognition when trained on sufficient data. Weak supervision as a field is surveyed in Zhou's review, which distinguishes incomplete, inexact and inaccurate supervision; that review summarises existing research on weak supervision rather than originating the paradigm.
When to use it
Use WS-ViT when you have a large image dataset but obtaining dense per-pixel or even per-instance annotations is prohibitively expensive — for example in medical imaging (pathology slides, radiology), remote sensing, or large-scale web-scraped datasets. It is well-suited to image classification, weakly supervised object localisation, and segmentation seeded from image-level tags. Prefer fully supervised approaches when precise spatial masks are available and the dataset is small, since self-attention models need more data to converge well. Avoid if your images are very low resolution or if model interpretability at the pixel level is a hard regulatory requirement, because attention-based localisation can still be imprecise.
Limitations and considerations
- Training from scratch is computationally heavy and needs large datasets, because ViTs have less built-in image-specific inductive bias than CNNs.
- Localisation resolution is bounded by the patch grid: an object or lesion smaller than a 16×16 patch cannot be delineated more finely than the patch size.
- Noisy weak labels can bias the model systematically unless the loss is adapted to the label type.
- Attention-based localisation can be diffuse for small or overlapping objects, and image-level supervision alone generally gives less precise localisation than fully supervised segmentation.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Image-level tags or bounding boxes replace pixel masks, which lowers the annotation cost for large image collections.
- Self-attention lets each patch's representation draw on the whole image, the property that motivates reading localisation from attention maps; whether this improves on CNN-based weak supervision for a given task has to be tested.
- A pre-trained ViT backbone can be fine-tuned on small weakly labelled sets, since the transfer step needs far fewer labelled examples than training from scratch.
- Attention rollout and CAM give per-patch heat maps that can be inspected qualitatively alongside the predictions.
Applications
- Weakly supervised semantic segmentation from image-level class tags in natural images.
- Pathology slide analysis from slide-level diagnostic labels, where multiple instance learning is one natural framing and a ViT can act as the patch encoder.
- Remote sensing scene classification and object detection with coarse bounding-box annotations.
- Classification of large, noisy web image collections whose labels come from surrounding text or user tags.
- Lesion localisation in medical images as a screening aid where pixel masks are unavailable.
How it works
How it works
The image is split into fixed-size, non-overlapping patches, commonly 16×16 pixels. Each patch is linearly projected to an embedding and combined with a learnable position encoding. A [CLS] token is prepended to the sequence, and its final state is used to summarise the image for classification.
Training uses supervision weaker than dense masks: image-level class tags, bounding-box coordinates, point annotations, pseudo-labels from a teacher model, or noisy labels taken from the web. The label source determines which loss and regularisation are appropriate, so this choice is made before the training objective is set.
The patch sequence passes through several transformer encoder blocks, each applying multi-head self-attention across all patches followed by a feed-forward sub-layer. Because every patch can attend to every other patch, the model can represent long-range spatial dependencies that a convolution with a local kernel does not capture directly.
Standard cross-entropy assumes correct labels, so it can be insufficient when labels are noisy or incomplete. Options commonly used for this purpose include label smoothing, noise-transition modelling, partial-label losses, and consistency regularisation between differently augmented views of the same image. The loss is chosen to match the label type, and each option aims to stop the network from memorising incorrect labels.
Localisation is read from the trained model without pixel-level ground truth. Common options are Class Activation Maps (CAM), which weight the patch features by the classifier weights for the predicted class, and attention rollout, which aggregates self-attention across layers. Both produce coarse heat maps over patches rather than segmentation masks, so their quality must be checked against reference annotations.
A backbone pre-trained with self-supervised or large-scale supervised objectives is fine-tuned on the weakly labelled target data. Transfer from such a backbone reduces how much weak supervision is needed, which is why the approach can remain practical when annotated examples are scarce.
Common pitfalls
- Using standard cross-entropy on crowd-sourced or web-scraped labels without a noise-robust modification.
- Fine-tuning on a small weakly labelled set without a pre-trained ViT backbone, which tends to generalise poorly.
- Treating attention or CAM maps as ground-truth masks without comparing them to a reference annotation.
- Reporting only classification accuracy; localisation should also be scored against a held-out set of reference annotations using an explicit localisation metric.
Frequently asked questions
Does a ViT offer an advantage over CNNs for weakly supervised learning?
Self-attention lets every patch interact directly with every other patch, giving a global receptive field. This is the property that motivates using attention maps for localisation without pixel labels. No established advantage over CNN-based weak supervision is shown on this page; whether attention maps are sharper or more semantically meaningful than CNN-based CAM depends on the dataset and backbone and has to be tested on the task at hand.
What kinds of weak labels can be used?
Common forms include image-level class tags (the cheapest), bounding boxes, point annotations, scribbles, and pseudo-labels from a teacher network or a stronger model. The loss should match the label type: incomplete annotations call for partial-label losses, and noisy pseudo-labels call for consistency regularisation or noise-transition modelling. Image-level tags are often combined with class activation mapping for localisation.
How much data is needed?
Starting from a large pre-trained ViT backbone, useful performance can often be reached with far fewer weakly labelled images than training from scratch requires. Training from scratch needs much larger datasets because transformers have more parameters and less built-in inductive bias than CNNs. The exact amount depends on the task and should be checked on a validation set.
Is the localisation output reliable enough for clinical use?
Not without additional validation. Attention-based localisation maps should be compared against expert annotations on a held-out set before any clinical conclusion is drawn. In regulatory or safety-critical settings, weakly supervised localisation is typically used as a screening or prioritisation aid rather than as a definitive spatial diagnosis.
How does multiple instance learning (MIL) relate to WS-ViT?
MIL is a weak supervision framework in which a bag of instances (here, patches) carries a single bag-level label. One interpretation is that a WS-ViT acts as a MIL model whose transformer aggregates patch information through learned self-attention pooling rather than a hand-designed aggregation function. Whether this outperforms classical MIL pooling depends on the task and should be tested against those baselines.
Related methods
Sources
Dosovitskiy, A., Beyer, L., Kolesnikov, A., Weissenborn, D., Zhai, X., Unterthiner, T., Dehghani, M., Minderer, M., Heigold, G., Gelly, S., Uszkoreit, J., & Houlsby, N. (2021). An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations (ICLR).
Open publication referenceZhou, Z.-H. (2022). A brief introduction to weakly supervised learning. National Science Review, 5(1), 44–53.
Open DOI reference