← Latest papers
🤖 machine learning

VariViT: A Vision Transformer for Variable Image Sizes

The paper proposes VariViT, a Vision Transformer architecture that handles variable image sizes through a novel positional embedding resizing scheme and an efficient batching strategy, achieving superior performance in brain tumor classification and genotype prediction while reducing computational costs by up to 30%.

Original authors: Aswathi Varma, Suprosanna Shit, Chinmay Prabhakar, Daniel Scholz, Hongwei Bran Li, Bjoern Menze, Daniel Rueckert, Benedikt Wiestler

Published 2026-02-17
📖 4 min read☕ Coffee break read

Original authors: Aswathi Varma, Suprosanna Shit, Chinmay Prabhakar, Daniel Scholz, Hongwei Bran Li, Bjoern Menze, Daniel Rueckert, Benedikt Wiestler

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are a detective trying to solve a mystery by looking at a series of photographs. In the world of Artificial Intelligence (AI), these "detectives" are called Vision Transformers (ViTs). They are incredibly smart at looking at pictures to find patterns, like spotting a tumor in a brain scan.

However, there's a big problem with how these detectives usually work: They only accept photos of one specific size.

The Problem: The "One-Size-Fits-All" Suit

Imagine you have a collection of photos of tumors. Some are tiny specks, and some are huge masses.

  • The Old Way (Vanilla ViT): To feed these photos into the AI, you have to force them all into a standard frame.
    • If the tumor is small, you have to stretch the photo out to fit the frame. This makes the tumor look blurry and introduces fake details (artifacts), like stretching a rubber band until it snaps.
    • If the tumor is huge, you have to chop off the edges or shrink the whole image down. This might cut off important clues or make the tumor look too small to see clearly.
    • The Result: The AI gets confused. It spends a lot of time looking at the empty background (the healthy brain) because the tumor got distorted or shrunken, wasting its energy.

The Solution: VariViT (The Flexible Detective)

The authors of this paper created a new AI model called VariViT. Think of VariViT as a detective who doesn't need a rigid frame. They can look at a photo exactly as it is, whether it's a tiny square or a giant rectangle.

Here is how VariViT works, using some simple analogies:

1. The "Center and Select" Trick (The Positional Map)

To understand a picture, an AI needs a map to know where things are (e.g., "the tumor is in the top-left corner").

  • The Old Way: If the photo size changes, the AI tries to stretch or squish its map to fit. This is like trying to stretch a rubber map; the streets get distorted, and the AI gets lost.
  • The VariViT Way: Imagine the AI has a giant, perfect map of the largest possible tumor. When it looks at a smaller tumor, instead of stretching the map, it simply zooms in on the center of that giant map.
    • Since tumors are usually centered in medical scans, the "center" of the big map and the "center" of the small tumor are the same.
    • VariViT just grabs the relevant chunk of the map from the middle. No stretching, no distortion, just a clean, sharp view of the tumor.

2. The "Smart Grouping" Strategy (Batching)

Training an AI is like teaching a class of students. Usually, you put students of the same height in the same row so they can all see the board.

  • The Old Way: If you have students of different heights (different image sizes), you either have to make the short ones stand on boxes (padding) or the tall ones sit on the floor (cropping). This is slow and messy.
  • The VariViT Way: The authors invented two clever ways to group the students:
    1. Group by Size: Put all the "small tumor" photos in one batch and all the "large tumor" photos in another. The AI learns them separately but efficiently.
    2. The "Accumulate" Method: If you must mix sizes, the AI takes a few small photos, learns from them, then takes a few large ones, learns from them, and then updates its brain. This saves a massive amount of computing power.

Why Does This Matter?

The researchers tested VariViT on brain scans to do two things:

  1. Identify the type of brain tumor (Primary vs. Metastatic).
  2. Predict genetic mutations (IDH status) which helps doctors choose the right treatment.

The Results:

  • Better Accuracy: VariViT was better at spotting the tumors and predicting their genetics than the old "stretch-and-shrink" models. It achieved higher scores (F1-scores around 75-76%) because it wasn't distracted by blurry backgrounds.
  • Faster Speed: Because it didn't waste time stretching images or processing empty background space, it trained 30% faster.

The Bottom Line

VariViT is like giving the AI detective a pair of smart glasses that automatically adjust to the size of the object they are looking at. Instead of forcing the world to fit the AI's rigid rules, VariViT adapts to the messy, irregular reality of human anatomy. This means doctors can get faster, more accurate diagnoses without the AI getting confused by distorted images.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →