MLV-Bench: Human vs. Machine Mid-Level Vision
This repository contains the code for the paper "Vision Transformers Learn Gestalt-Like Figure-Ground Cues from Natural Images" and provides reusable components for testing mid-level representations in Vision Transformers.
Prerequisites
Clone this repository and install the Python dependencies:
git clone https://github.com/mtangemann/mlvbench
cd mlvbench
uv sync
Probing figure-ground organization in Vision Transformers
All experiment code is provided in experiments/figure_ground_shape_cues.
cd experiments/figure_ground_shape_cues
# Train probes for an individual model and condition. Recommend for debugging and
# testing the setup.
python experiment.py --condition natural --model timm/vit_small_patch16_dinov3.lvd1689m
# Use the `launch.py` script to train probes for all networks and conditions. This
# supports submitting parallel jobs on a Slurm cluster, but you might have to adapt the
# Slurm settings for your cluster.
python launch.py path/to/output
MLV-Bench
Several of the components provided by MLV-Bench are are generic and can be reused for
different experiments, including the feature extraction and probe fitting. This
components are contained in the core mlvbench library.
from mlvbench.models import build_model
from mlvbench.trainer import ProbeTrainer
model = build_model("timm/vit_base_patch16_224.orig_in21k")
# --- Feature Extraction ---
images = ... # torch uint8 Tensor with shape (B, 3, H, W)
features = model.forward_features(images)
features.patch("block.11") # Patch features with shape (B, N, C)
features.patch("block.11", format="BHWC") # or reshaped to a spatial feature map
features.cls("block.11") # CLS token
# --- Probe Fitting ---
data_module = MyDataModule(...)
trainer = ProbeTrainer(
task: "binary_segmentation",
probe: "linear",
data_module: data_module,
batch_size: 256,
max_steps: 1000,
)
trainer.fit(model)
# Access the fitted probes via `model.probes`
print(f"Fitted {len(model.probes)} probes to the following layers:")
for probe in model.probes:
print(probe.layer)
# Evaluate probes
test_loader = data_module.test_loader(batch_size=256)
trainer.evaluate(model, test_loader, "output/example/evaluation")
Have a look at the API documentation for more information.
Citation
Please cite our paper if you use MLV-Bench for your experiments.
@misc{tangemann2026figureground,
title={Vision Transformers Learn Gestalt-Like Figure-Ground Cues from Natural Images},
author={Matthias Tangemann and Benjamin Lo and Zygmunt Pizlo and Kaleem Siddiqi and Dirk B. Walther and Sven Dickinson},
year={2026},
eprint={2607.08932},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2607.08932},
}
Please also make sure to cite the original authors for all models that you use. Each
model provides a link to more information as model.url.
Metadata
Release files for mlvbench 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mlvbench-1.0.0.tar.gz | 377.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mlvbench-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 450.4 kB
Release files / mlvbench-1.0.0.tar.gz
| Download URL | mlvbench-1.0.0.tar.gz |
|---|---|
| Size | 377.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2dd722608d1b3da841451578b9bc5ee5158d78ea0a9d04900d2a38462c42efc6
|
|
BLAKE2b-256 checksum How to use checksums |
6aa6bd1835ddae9f6cfbf1e9970ed468ade2f2ef80a6dd6070f45adad6c5789e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Release files / mlvbench-1.0.0-py3-none-any.whl
| Download URL | mlvbench-1.0.0-py3-none-any.whl |
|---|---|
| Size | 72.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
af9c1ac06ddf438f36193860cd55a49ddca96366424404c668de9aa9abefc26d
|
|
BLAKE2b-256 checksum How to use checksums |
1638f5a2bf018842f60f89389f8c0a850b7a0448c64ac1e57aa8ecfed30a7bdb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|