Multimodal AI
Vision Transformers and Self-Supervised Vision: ViT, Contrastive Learning, MAE, and Segmentation and Detection
Advanced 45 min For: Developers / Researchers
Key takeaways
- ▸ViT cuts an image into fixed-size patches, projects them linearly, and prepends a learnable classification token with positional encodings before a standard Transformer encoder. With the paper’s formula N = HW/P², a 224×224 image and patch size 16 yield a 14×14 grid of 196 patches, or a sequence length of 197 once the classification token is added. This lesson’s script checks several common resolutions.
- ▸Compared with CNNs, ViT builds in little translation equivariance or locality. The paper states that, on mid-sized datasets such as ImageNet and without strong regularisation, accuracy lags ResNets of comparable size by a few percentage points; pre-training on 14M–300M images lets scale outweigh that missing inductive bias. The best model pre-trained on ImageNet-21k or JFT-300M reaches 88.55% on ImageNet.
- ▸SimCLR uses NT-Xent (normalised temperature-scaled cross-entropy) to pull together two augmented views of the same image and push away the other samples in the batch; the projection head is discarded after training and only the encoder output is kept. MAE feeds only visible patches to the encoder and reconstructs pixels with a lightweight decoder; because images are spatially redundant, a 75% masking ratio is commonly used so the task cannot be solved by local interpolation. DINOv2 performs self-distillation on the curated LVD-142M collection to obtain general-purpose features that can be frozen; I-JEPA predicts target-block representations rather than pixels.
- ▸For detection, Faster R-CNN uses a Region Proposal Network that shares features with the detection head; with VGG-16 on a K40 GPU the full system runs at 5 fps and uses 300 proposals per image. YOLO casts detection as a single regression: on PASCAL VOC it uses a 7×7 grid, 2 boxes per cell and 20 classes, hence a 7×7×30 tensor; the original paper reports 45 fps for the base model on a Titan X with no batching, and 155 fps for Fast YOLO. DETR uses a set of learned object queries and bipartite matching (the Hungarian algorithm) to predict a set directly, without non-maximum suppression; a model with a parameter count comparable to Faster R-CNN reaches 42 AP on COCO val.
- ▸For segmentation, U-Net uses a symmetric contracting path and expansive path, concatenating cropped high-resolution maps back into the decoder, with 23 convolutional layers in total. SAM treats segmentation as a promptable task; prompts may be points, boxes or masks, among others, and the accompanying SA-1B dataset has more than one billion masks on 11M images. In practice one can load pre-trained backbones with timm for a linear probe or fine-tuning, use SAM for prompted or automatic annotation, and train a detector on one’s own photos with Ultralytics YOLO.
Summary. Once an image is cut into patches, a standard Transformer can be used for recognition: that is the basic idea of the Vision Transformer (ViT). To serve as a general-purpose backbone for dense tasks such as detection and segmentation, hierarchical features and local attention (Swin) are also needed. Detection and segmentation themselves have moved from region proposals and single-stage regression to set prediction and promptable segmentation. In parallel, contrastive learning, masked reconstruction, self-distillation and prediction in representation space let visual models learn transferable features from unlabelled images. This lesson follows the path “ViT tokenisation and scale → Swin’s hierarchical window attention → representative detectors and segmenters → four lines of self-supervision → linear probes, fine-tuning and readily available tools”. Figures taken from papers were checked against the source; figures produced by this lesson’s script are reported at the end with the environment and seed: Python 3.13.5, NumPy 2.5.4, random seed 0.
This lesson belongs to the unit Vision Transformers and Self-Supervised Vision. It assumes Transformers and Attention and From CNNs and RNNs to Transformers. Related algorithm cards: ViT, SimCLR, MAE, JEPA, SAM, Contrastive Learning and InfoNCE, U-Net, Faster R-CNN, YOLO, DETR, Swin, DINOv2.
From convolutional networks to the Vision Transformer
Before ViT, convolutional networks were the default visual models: local receptive fields, weight sharing and translation equivariance are built into the architecture. Dosovitskiy, Beyer, Kolesnikov et al. (2020; ICLR 2021) showed that a convolutional backbone around the Transformer is not required: cutting the image into fixed-size patches, projecting them linearly and feeding the sequence to a standard Transformer encoder is already enough for image recognition.
Let the image have resolution (H, W) and C channels, and let each patch have side P. After the image is reshaped into a sequence of patches, the length is
N = H W / P²
which is the encoder’s effective input length. For the common setting 224×224 and P=16, 224/16=14, so there are 14×14=196 patches. Each patch is projected to the model width D by a shared linear layer, and a learnable classification token (x_class) is prepended. Positional information is added as learnable one-dimensional position embeddings; the authors report no significant gain from more two-dimension-aware encodings. For classification one takes the encoder output that corresponds to x_class and attaches a classification head (an MLP with one hidden layer at pre-training time).
The script in this lesson checks several common sizes against that formula.
| Image H×W | Patch side P | Grid | Patches N | Sequence length with class token | Note |
|---|---|---|---|---|---|
| 224×224 | 16 | 14×14 | 196 | 197 | Usual input for ViT-B/16 and ViT-L/16 |
| 224×224 | 32 | 7×7 | 49 | 50 | ViT-B/32 and ViT-L/32 |
| 224×224 | 14 | 16×16 | 256 | 257 | Patch size used with ViT-H/14 |
| 384×384 | 16 | 24×24 | 576 | 577 | A common higher-resolution fine-tuning size |
When fine-tuning at a resolution different from pre-training, the paper interpolates the pre-trained position embeddings on a 2D grid rather than reinitialising them at random.
ViT encodes almost no image-specific inductive bias: locality, two-dimensional neighbourhood structure and translation equivariance appear only in the initial patching step and in the interpolation of position embeddings at fine-tuning time. All other spatial relations have to be learned from data. The authors therefore write that, on mid-sized datasets such as ImageNet and without strong regularisation, these models yield accuracies a few percentage points below ResNets of comparable size, and that they “do not generalize well when trained on insufficient amounts of data”. When pre-training data reach 14M–300M images, “large scale training trumps inductive bias”. Pre-training may be done on the public ImageNet-21k set or on the in-house JFT-300M set. The best model reported in the paper reaches 88.55% on ImageNet, 90.72% on ImageNet-ReaL, 94.55% on CIFAR-100, and 77.63% on the 19-task VTAB suite. Those figures are from the paper, not a reproduction in this lesson.
Hierarchical vision transformers: Swin
A standard ViT applies global self-attention among all patches and keeps a single-resolution feature map, so the cost grows quadratically with the number of patches and the model is an awkward general-purpose backbone for detection and segmentation. The Swin Transformer of Liu, Lin, Cao et al. (2021) makes two changes.
First, it builds hierarchical features: it starts from smaller patches (4×4 by default in the paper) and then uses patch merging to reduce resolution and increase the channel width, producing multi-scale maps at successive stages. Second, self-attention is restricted to non-overlapping local windows, which makes the cost approximately linear in image size; to allow information to cross window boundaries, the window partition is shifted between consecutive blocks (shifted windows), corresponding to W-MSA and SW-MSA in the paper. The default window side is M=7.
For a 224×224 input, patch size 4 and M=7, the four stages have token grids 56×56, 28×28, 14×14 and 7×7. The attention-score counts below assume that each token forms a dot product with M² positions inside its window, or with every token under global attention. They illustrate how the two complexity scalings diverge as the feature map grows; they are not measured runtimes.
| Stage | Token grid | Tokens | Windows (M=7) | Window attention scores | Global attention scores | Global / window |
|---|---|---|---|---|---|---|
| 1 | 56×56 | 3136 | 64 | 153664 | 9834496 | 64 |
| 2 | 28×28 | 784 | 16 | 38416 | 614656 | 16 |
| 3 | 14×14 | 196 | 4 | 9604 | 38416 | 4 |
| 4 | 7×7 | 49 | 1 | 2401 | 2401 | 1 |
At stage 1 the windowed score count is 1/64 of the global count, matching the number of windows; at stage 4 the whole feature map is a single window and the two counts coincide. The paper reports a best ImageNet-1K top-1 accuracy of 87.3 for Swin as a backbone, and 58.7 box AP and 51.1 mask AP on COCO test-dev. Those figures are again from the paper and were not reproduced here.
A short history of object detection
This unit already lists Faster R-CNN, YOLO and DETR. The remarks below only state the problem each method addresses; they are not a second course on detection.
Two stages: Faster R-CNN. After R-CNN and Fast R-CNN, region proposal itself became the speed bottleneck. Ren, He, Girshick and Sun (2015) introduced a Region Proposal Network (RPN): a fully convolutional network that shares full-image convolutional features with the detection head and predicts object bounds and objectness at each position. The authors describe the proposals as nearly cost-free, with a marginal cost of about 10 ms per image. With VGG-16, the detection system runs at 5 fps on a GPU including all steps and uses 300 proposals per image; Table 5 of the paper reports 198 ms in total for RPN + Fast R-CNN on a K40 GPU (10 ms of that for proposals). The RPN covers multiple scales and aspect ratios with a set of anchors.
Single stage: YOLO. Redmon, Divvala, Girshick and Farhadi (2015) cast detection as a regression problem: a single network predicts bounding boxes and class probabilities from the full image in one evaluation, so the whole pipeline can be optimised end-to-end. The image is divided into an S×S grid; the cell that contains an object’s centre is responsible for it. Each cell predicts B boxes and their confidences, plus C class probabilities, and the output is an S×S×(B×5+C) tensor. On PASCAL VOC, S=7, B=2 and C=20, so the final prediction is a 7×7×30 tensor. The input is resized to 448×448. The paper reports that the base YOLO model runs at 45 fps on a Titan X with no batch processing; the faster Fast YOLO model is given as 155 fps in the abstract and as more than 150 fps in the body. The paper also reports 63.4% mAP under the setting used there. The Ultralytics YOLO family used today is a later line of models; follow the official documentation for the interface and training recipe, and do not treat the 2015 figure of 45 fps as the speed of a current model on current hardware.
Set prediction: DETR. Carion, Massa, Synnaeve et al. (2020) treat detection as direct set prediction. A CNN backbone produces a 2D feature map, which is flattened, supplemented with a positional encoding and passed to a Transformer encoder. The decoder takes N learned object queries (N=100 in the paper’s experiments) together with the encoder output; a shared feed-forward network then predicts a class and box, or a “no object” label. Training uses the Hungarian algorithm to compute a bipartite matching between predictions and ground truth, so the loss is permutation-invariant and duplicate detections are discouraged, removing the need for non-maximum suppression and hand-designed anchors. The paper reports that a model with a parameter count comparable to Faster R-CNN reaches 42 AP on COCO val, with a gain on large objects (AP_L +7.8) and a remaining deficit on small objects (AP_S −5.5).
| Method | Year | Core structure | Post-processing | Speed or accuracy in the paper (original setting) |
|---|---|---|---|---|
| Faster R-CNN | 2015 | Feature-sharing RPN + detection head | Classify and regress after proposals | VGG-16, K40 GPU, 5 fps including all steps; 300 proposals |
| YOLO (v1) | 2015 | Single-network regression, S×S grid | Thresholding and de-duplication | 45 fps for the base model on Titan X; 7×7×30 on VOC |
| DETR | 2020 | Encoder–decoder + object queries | Bipartite matching, no NMS | 42 AP on COCO val (parameter count close to Faster R-CNN) |
Segmentation: U-Net and Segment Anything
U-Net. Ronneberger, Fischer and Brox (2015) designed a U-shaped encoder–decoder for biomedical images. The contracting path repeats two 3×3 convolutions, ReLU and 2×2 max-pooling; the expansive path upsamples, applies a 2×2 up-convolution that halves the number of channels, concatenates the correspondingly cropped map from the contracting path, and applies two 3×3 convolutions. These skip connections give the decoder both context and high-resolution localisation. The network has no fully connected layers and 23 convolutional layers in total. Because valid convolutions are used, the segmentation map covers only those pixels whose full context lies inside the input, and large images can be processed with an overlap-tile strategy. The authors stress elastic-deformation augmentation so that the network can be trained end-to-end from very few annotated images.
SAM. Kirillov, Mintun, Ravi et al. (2023) define a promptable segmentation task: given any prompt, return at least one valid mask; when the prompt is ambiguous (a point on a shirt may also refer to the person), the output should be a reasonable mask for one of those readings. A prompt can include spatial or text information; points, boxes and masks are the usual interface in the public implementation. The model comprises an image encoder, a prompt encoder and a mask decoder, and is trained to transfer zero-shot given a prompt. The accompanying SA-1B dataset contains 11M licensed, privacy-respecting images and more than one billion masks; the project page is segment-anything.com. The dataset and model-scale figures are from the paper; this lesson does not download SA-1B or the official weights.
Self-supervised vision
Labelled images are typically far scarcer than unlabelled ones. Self-supervised learning builds a task from the image itself, first obtaining a transferable representation and then attaching a linear probe or a fine-tuned head. The four lines below cover the algorithms already listed for this unit.
Contrastive learning and InfoNCE
van den Oord, Li and Vinyals (2018) introduced InfoNCE in Contrastive Predictive Coding. Given a set X={x_1,…,x_N} that contains one positive sample from the conditional p(x_{t+k}|c_t) and N−1 negatives from a proposal distribution p(x_{t+k}), one optimises
L_N = − E[ log f_k(x_{t+k}, c_t) / Σ_{x_j ∈ X} f_k(x_j, c_t) ]
Minimising L_N maximises a lower bound on the mutual information: I(x_{t+k}, c_t) ≥ log(N) − L_N, which tightens as N grows. The intuition is that the model must recognise the sample compatible with the current context among a batch of distractors.
SimCLR
Chen, Kornblith, Norouzi and Hinton (2020) turned that idea into a deliberately simple visual framework. Two augmentations are sampled independently for each example, yielding two correlated views; an encoder f(·) and a projection head g(·) are trained to maximise agreement. The main augmentations are random cropping with resize back to the original size, colour distortion and Gaussian blur. The contrastive loss is NT-Xent (normalised temperature-scaled cross-entropy). For 2N views from a batch of N images, the loss of a positive pair (i, j) is
ℓ_{i,j} = − log exp(sim(z_i, z_j)/τ) / Σ_{k=1, k≠i}^{2N} exp(sim(z_i, z_k)/τ)
where sim is cosine similarity after ℓ₂ normalisation and τ is a temperature. A batch of size 8192 supplies 16382 negatives per positive pair (the number given in the paper). The authors sweep batch sizes from 256 to 8192; the default ablation uses batch size 4096 for 100 epochs, LARS and global batch normalisation. They emphasise three findings: the composition of augmentations matters; a learnable nonlinear projection between the representation and the loss is important; and contrastive learning benefits from larger batches and more steps than supervised training. In the abstract, a linear classifier on SimCLR representations reaches 76.5% top-1 on ImageNet. As already noted, the representation actually used is the hidden vector h before the projection head.
MAE
The masked autoencoder of He, Chen, Xie et al. (2021) takes a different path: random patches of the input are masked and the missing pixels are reconstructed. Two design choices are central. The first is an asymmetric architecture: the encoder sees only visible patches and no mask tokens; mask tokens are introduced after the encoder, and a lightweight decoder processes the full set and reconstructs in pixel space. After pre-training the decoder is discarded, and for recognition the encoder is applied to the uncorrupted image. The second is a high masking ratio, for example 75%: images are spatially redundant, so a low ratio is often too easy; a high ratio both creates a harder task and lets the encoder process only about 25% of the patches, which the paper says can accelerate pre-training by 3× or more. For 196 patches and 75% masking, 49 patches remain visible and 147 are masked; Figure 2 of the paper uses 80% masking and leaves 39 of 196 patches, which matches 196×0.20=39.2 rounded to 39. The authors also report that a vanilla ViT-Huge trained only on ImageNet-1K reaches 87.8%, the best accuracy among methods using only that dataset at the time. That figure is from the paper; this lesson does not train an MAE.
DINOv2 and self-distillation
DINO, by Caron, Touvron, Misra et al. (2021), casts self-supervision as student–teacher self-distillation. The two networks share an architecture but not parameters; they process two random transformations of the same image. The teacher output is centred over the batch, both sides are passed through a temperature softmax, and agreement is measured with a cross-entropy; gradients flow only through the student, and the teacher is an exponential moving average of the student. No class labels are used.
DINOv2, by Oquab, Darcet, Moutakanni et al. (2023), scales that line of work in data and model size. An automatic pipeline builds a curated collection, LVD-142M (142 million images), from about 1.2 billion source images, rather than training on uncurated data directly. A ViT with about 1 billion parameters is trained and then distilled into a family of smaller models; the ViT-g backbone in the paper has 1.1 billion parameters (embedding dimension 1536 and 24 attention heads). The aim is general-purpose features that work across image distributions and tasks without fine-tuning. The official introductory post (17 April 2023) likewise stresses that the features can feed a linear classifier directly, and that linear evaluation lies within about 2 percentage points of fine-tuning on ImageNet-1k. Concrete accuracies should be read from the paper’s tables; this lesson does not reproduce them.
I-JEPA
Assran, Duval, Misra et al. (2023) proposed an image-based joint-embedding predictive architecture, I-JEPA: from a single context block, predict the representations of several target blocks in the same image. The method is non-generative and does not reconstruct pixels; the authors also state that it does not rely on hand-crafted data augmentations to form multiple views. To encourage semantic representations, the target blocks should be large enough in scale and the context block should be spatially informative. The encoder is a ViT that processes only the visible context patches; the predictor is a narrower ViT conditioned on positional tokens of the target; the target-encoder weights are an exponential moving average of the context encoder. The paper reports training a ViT-H/14 on ImageNet with 16 A100 GPUs in under 72 hours, with strong downstream results including linear classification. Meta AI’s introduction of 13 June 2023 describes the same structure: what is compared is an abstract representation of the image, not the pixels themselves.
| Method | Year | Learning signal | What is compared or predicted | What is usually kept after training |
|---|---|---|---|---|
| SimCLR | 2020 | Agreement of two augmented views of one image | Cosine similarity in the projection space (NT-Xent) | The encoder f(·); the projection head is dropped |
| MAE | 2021 | Random masking at a high ratio | Pixels of the masked patches | The encoder; the decoder is dropped |
| DINO / DINOv2 | 2021 / 2023 | Student–teacher self-distillation | Agreement of output distributions | The teacher or a distilled backbone, which may be frozen |
| I-JEPA | 2023 | Context block predicts target blocks | Target embeddings in representation space | The context / target encoders; no pixel reconstruction |
Practice: linear probes, fine-tuning and readily available tools
Pre-training only yields a representation. Two common ways to attach it to a task are as follows.
- Linear probe. The backbone is frozen and only a linear classification head is trained. This measures whether the representation is linearly separable, is relatively cheap, and is a standard comparison among pre-training methods. The SimCLR, MAE, I-JEPA and DINOv2 papers all report linear evaluation as a headline figure.
- Fine-tuning. The backbone and the task head are updated together. Task accuracy is usually higher, but the representation moves towards that task and is no longer equally general. The official DINOv2 introduction emphasises that its linear evaluation is already close to fine-tuning (within about 2 percentage points on ImageNet-1k), which suits using one frozen feature for several tasks.
Do not treat ImageNet numbers from a paper as the accuracy on your own data. When transferring, fix the random seed, record the backbone name and whether it was frozen, and compare a linear probe with fine-tuning on the same split.
In practice, timm provides a uniform interface for loading pre-trained ViT, Swin, DINOv2 and other backbones, for classification or as a feature extractor on a small dataset. The official SAM repository accepts point and box prompts and can also generate automatic masks on a batch of images, which is useful for preparing detection or segmentation labels. Ultralytics YOLO documents how to train a detector on custom images. This lesson does not download multi-gigabyte weights and does not report accuracies that were not run.
Worked examples in this lesson
The script _work/daily/2026-11-23/vision_demo.py uses only NumPy and downloads no weights. The environment is /workspace/.venv-learn, Python 3.13.5, NumPy 2.5.4, seed=0. Output is in vision_demo_results.json in the same directory.
- Patch arithmetic matches the table above: for 224×224 and P=16, N=196 and the sequence length with a class token is 197; at a 75% MAE mask, 49 patches are visible and 147 are masked; at 80%, 196×0.20=39.2, which rounds to 39, matching “39 out of 196 patches” in Figure 2 of the MAE paper.
- NT-Xent on synthetic vectors. Eight 16-dimensional unit latent vectors are drawn, and two views of each are formed by adding Gaussian noise of standard deviation 0.15 (16 vectors in total). The mean cosine similarity is 0.735972 for positive pairs and 0.000257 for negative pairs. The batch-mean loss is 0.014323 at τ=0.05, 0.127325 at τ=0.1, 1.542188 at τ=0.5 and 2.071892 at τ=1.0. After the pairing is shuffled, the loss at τ=0.1 rises to 7.402600. If every vector is identical, the loss is 2.708050, which matches the closed form log(2N−1)=log(15)=2.708050. A smaller temperature sharpens the gap between positives and negatives and therefore lowers the loss on already separable samples; this only illustrates the formula, and is not a tuning recommendation on real images.
- Swin window counts are those in the earlier table, used to check the counting relation “window attention is approximately linear in image size, global attention is quadratic”.
Exercises
- Unit project. On a small image-classification dataset, compare a linear probe and fine-tuning of a pre-trained ViT, recording accuracy and training settings on the same split; then use SAM with point or box prompts (or automatic mask generation) to annotate a batch of pictures, and inspect whether the masks match the prompted objects.
- Complete the hands-on units of the Hugging Face Computer Vision Course, and compare them with the patching and encoder usage in this lesson.
- Load ViT, Swin, DINOv2 or similar backbones with timm and transfer them on a small dataset, comparing a frozen backbone with full fine-tuning.
- Following the Ultralytics training documentation, train a YOLO detector on your own photos, and record the model version, image size and number of epochs.
Suggested reading order
Start by reviewing self-attention and positional encodings in Transformers and Attention, and compute the 224×224 sequence length with the patch formula in this lesson. For ViT, read Section 3 of Dosovitskiy et al.; when a hierarchical backbone is needed, read the window and shifted-window sections of the Swin paper, or the official repository. For detection, follow Faster R-CNN → YOLO v1 → DETR to see how the problem is restated; for modern YOLO usage, follow the Ultralytics documentation. For segmentation, start with U-Net skip connections and then SAM’s promptable task and official repository. For self-supervision, compare InfoNCE / SimCLR → MAE → DINO / DINOv2 → I-JEPA along the four lines “compare views, reconstruct pixels, self-distil, predict representations”, and try a linear probe on frozen features in timm. The same stage’s lesson on vision-language models then attaches the image encoders from this lesson to a language model.
FAQ
How does ViT turn an image into a sequence, and how many tokens does a 224×224 image with patch size 16 produce?
Following Dosovitskiy et al., a resolution-(H, W) image is cut into non-overlapping patches of side P and each patch is projected linearly. The number of patches is N = HW/P². For 224×224 and P=16 that is a 14×14 grid, or 196 patches. For classification a learnable classification token is prepended and positional encodings are added, so the encoder sees a sequence of length 197. This lesson’s script also checks P=32 (49 patches) and 384×384 with P=16 (576 patches).
Why does the MAE paper mask as much as 75% of the image, rather than a small fraction as in BERT?
The paper notes that images are natural signals with heavy spatial redundancy: a missing patch can often be recovered from its neighbours with little high-level understanding. Masking a very high proportion of random patches (for example 75%) yields a nontrivial self-supervisory task and forces a more holistic representation. The same design works with the asymmetric architecture: the encoder sees only the visible quarter of the patches, and mask tokens appear only in the lightweight decoder. Figure 2 of the paper also illustrates 80% masking, leaving 39 of 196 patches.
Why does SimCLR discard the projection head after training?
SimCLR places a learnable nonlinear projection head g(·) (an MLP with one hidden layer and ReLU) after the encoder f(·), and applies the contrastive loss to z=g(h). Ablations show that a nonlinear projection outperforms a linear one by about 3 points and outperforms no projection by more than 10 points; even with a nonlinear projection, the hidden representation h before the head remains a better downstream feature than z (again by more than 10 points). After training, g(·) is discarded and h is used as the image representation.
MAE and I-JEPA both hide parts of the image. What is the difference in what they predict?
MAE is generative: the decoder reconstructs masked patches in pixel space. I-JEPA is a non-generative joint-embedding predictive architecture: from a single context block it predicts the representations of several target blocks in the same image, not the pixels. The authors argue that this avoids treating unpredictable pixel detail as a learning target and reduces reliance on hand-crafted data augmentations. Meta AI’s introductory post (13 June 2023; curl returned 400 on the day of writing, confirmed by a separate fetch) agrees with the paper: prediction is in an abstract representation space rather than a comparison or reconstruction of pixels.
What can a SAM prompt be, and how does that differ from what U-Net is for?
SAM defines a promptable segmentation task: given any prompt, return a valid mask. The paper states that a prompt can include spatial or text information identifying an object; the public implementation and usual interface emphasise points, boxes and masks. The model is trained to transfer zero-shot given a prompt. U-Net is an encoder–decoder designed for biomedical images, with skip connections that concatenate cropped maps from the contracting path onto the upsampled path, and is typically trained end-to-end on a labelled dataset rather than used as a general prompted segmenter.