All models

ConVIRT

A ResNet50 and ClinicalBERT pair trained contrastively on medical images and their reports.

Medical imaging · 490 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 (24 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
138M
Operations
490
Framework
PyTorch
Recurrent
No
Published
MLHC 2022
Cited by
406 (as of 16 October 2026)
Authors
Yuhao Zhang, Hang Jiang, Yasuhide Miura 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
m391
Graph hash
ced6f7b52196069ee9a6b96772ec2472f6bd6560c344f71e47652ffbba093ac0
Skeleton hash
a813e7469e5479a3da1e2c1daa5f49eb088deec5923952583b765a10c6ff76b2
Architecture hash
cd3ad0bbddd09112459ae84acdfffc78e0a15e819d0c8a2ca9864cc77d503fd1
Diagram SHA-256
d551ea925e7b4ce08c08a328a38689e6f660e4f0bb22ff244062e0cf2480a6ec
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

ConVIRT is a way to pretrain a medical image encoder from the free text that already accompanies the images, the radiology report, instead of from expert labels. The paper's case is that medical imaging had been stuck between ImageNet transfer, a poor fit for very different image characteristics, and rule-based label extraction from reports, which is inaccurate and hard to generalize. Contrastive learning on natural images had looked promising, but the authors found it helped little on medical images because of their high inter-class similarity.

The method encodes an augmented image and a sampled span of its report, projects both into one shared space, and maximizes agreement between true pairs with a bidirectional contrastive loss. The loss has the same form as InfoNCE: a cosine similarity with a temperature, read as the log loss of an N-way classifier picking the true pair out of a minibatch. The image encoder is a ResNet50 and the text encoder a BERT model initialized from ClinicalBERT weights pretrained on MIMIC clinical notes, with max-pooling over its output vectors. The embeddings and first 6 transformer layers of that BERT encoder stay frozen while the last 6 are fine-tuned. Text augmentation is deliberately mild, a uniformly sampled sentence from the report, because sampling at the sentence level preserves the meaning of the span. The image transformations are cropping, horizontal flipping, affine transformation, color jittering and Gaussian blur, with jittering limited to brightness and contrast because the images are monochrome.

Transferred to 4 medical image classification tasks and 2 zero-shot retrieval tasks, the pretrained weights outperform strong baselines in most settings. The data-efficiency claim is the headline: in all 4 classification tasks the method needs only 10% as much labeled data as an ImageNet-initialized model to match or beat it. The authors' own repository holds only the CheXpert 8x200 image-image and text-image retrieval evaluation sets, not model code. The captured member is therefore a non-official PyTorch implementation by Eduardo Reis, forked and modified from an open SimCLR codebase, whose forward pass returns the two 512-dimensional projections. The paper's own pretraining used an output dimension of 512, a temperature of 0.1 and a loss weight of 0.75.

Key idea. Pretraining medical image encoders with a bidirectional image-text contrastive objective over naturally paired reports, needing no expert input and far less labeled data downstream.

  • convirt
  • contrastive learning of medical visual representations from paired images and text
  • medical image-text contrastive
  • chest x-ray pretraining
  • radiology report
  • clinicalbert
  • resnet50
  • infonce
  • mimic-cxr
  • chexpert
  • zhang langlotz
  • convirt-pytorch

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

Cite the paper

@misc{zhang2022contrastivelearningmedicalvisual,
      title={Contrastive Learning of Medical Visual Representations from Paired Images and Text}, 
      author={Yuhao Zhang and Hang Jiang and Yasuhide Miura and Christopher D. Manning and Curtis P. Langlotz},
      year={2022},
      eprint={2010.00747},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2010.00747}, 
}