Skip to content

rainarit/seen2scene

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ†• [2026-01-16] MetamerGen released β€” we upgraded the model to generate images that are metameric to human scene understanding (paper accepted at ICLR 2026), more details are here.

[2025] Seen2Scene released β€” the first iteration, introduced at CCN 2025, more details are here.

Generating Scenes from Eye Movements πŸ‘οΈ πŸ–ΌοΈ

Ritik Raina1 Β· Abe Leite1 Β· Alexandros Graikos1 Β· Seoyoung Ahn2 Β· Dimitris Samaras1 Β· Gregory J. Zelinsky1

1Stony Brook University  2UC Berkeley

[MetamerGen Paper (ICLR 2026)] [Seen2Scene Paper (CCN 2025)] [BibTeX]

Overview

A family of models that reconstruct a person's understanding of a scene from their eye movements β€” turning sparse, foveated visual input into a complete generated image. Human vision blends low-resolution information from the periphery with sparse, high-resolution detail from where the eyes fixate.

Every model is a lightweight adapter over a frozen Stable Diffusion v1.5, conditioned on features from a frozen DINOv2 ViT-B/14 (reg4) encoder and injected through IP-Adapter cross-attention β€” only the small projection and adapter modules are trained.

Models

Seen2Scene (CCN 2025)

[Paper] [Code]

The first iteration: three variants that isolate how foveal detail and scene gist each contribute to scene understanding.

Model Conditioning Download
Fixation-only DINOv2 patch tokens at fixated locations adapter weights
Fixation + gist fixated patch tokens + global cls/register gist tokens coming soon
Gist-only global gist tokens only (cls + 4 register = 5 tokens) adapter weights

MetamerGen (ICLR 2026)

[Paper] [Code]

The upgrade: generates images that are metameric to human scene understanding from a dual-stream foveated representation.

Model Conditioning Download
MetamerGen foveal: sharp patch tokens at fixated locations Β· peripheral: patch tokens from a blurred image (no gist tokens) coming soon

Installation

The code expects a Linux environment with a CUDA GPU (reference setup: Python 3.12, PyTorch 2.4.1, CUDA 12.1).

Quick start (Recommended) β€” clone the repository, then create the conda environment and download the DINOv2 encoder weights in one step:

git clone https://github.com/rainarit/seen2scene
cd seen2scene
bash setup.sh
conda activate eye-movement-scene-gen

conda β€” create and activate the environment from the provided definition:

conda env create -f environment.yml
conda activate eye-movement-scene-gen

pip β€” install a torch build matching your CUDA first (see the file header), then:

pip install -r requirements.txt

Getting started

setup.sh fetches the frozen DINOv2 encoder into weights/. The trained adapter checkpoints are separate β€” download the ones you want from the Models table (GitHub Releases) into weights/:

curl -L -o weights/seen2scene_fixation_only.bin \
  https://github.com/rainarit/seen2scene/releases/download/seen2scene-v1.0/seen2scene_fixation_only.bin

Stable Diffusion v1.5 is fetched automatically from the Hugging Face Hub on first use (no manual download needed).

Use the pipeline

pipeline.py provides Seen2ScenePipeline, a diffusers-style interface to every model in the family: pick a model with a string, feed an image and the fixation (x, y) pixel locations of a scanpath, and get the generated scene back.

from pipeline import Seen2ScenePipeline

pipe = Seen2ScenePipeline.from_pretrained(
    model_type="fixation-only",   # "fixation-only" | "fixation-gist" | "gist-only" | "metamergen"
    adapter_path="weights/seen2scene_fixation_only.bin",
    image_encoder_path="weights/dinov2_vitb14_reg4_pretrain.pth",
    device="cuda",
)

scene = pipe(
    image="my_photo.jpg",                            # PIL image, file path, or URL
    fixations=[(310, 140), (95, 300), (420, 260)],   # scanpath, (x, y) pixels in the input image
    num_inference_steps=50,
    guidance_scale=7.5,
    seed=42,
)
scene.save("generated.png")

Fixations are given in the input image's own pixel coordinates; the pipeline maps them through the same aspect-preserving resize used at training time, so each fixation selects the DINOv2 patch that actually contains it. gist-only needs no fixations, and metamergen additionally accepts a peripheral_level controlling how much the peripheral stream is blurred. Run it from the repo root (or add the repo root and common/ to PYTHONPATH).

Explore the notebooks

Two notebooks are provided to explore the models on any online image:

  • Seen2Scene demo β€” sample random fixations, display the RGB PCA of the DINOv2 conditioning features (fixated patch tokens + gist tokens), and generate scenes with all three Seen2Scene models
  • MetamerGen demo β€” build the sharp (foveal) and blurred (peripheral) views, display the RGB PCA of both streams, and generate a scene with MetamerGen

Data preparation

Resource Where Used for
DINOv2 ViT-B/14 (reg4) downloaded by setup.sh to weights/, or direct link frozen image encoder
Stable Diffusion v1.5 auto-fetched from the HF Hub frozen base model
COCO train2017/ cocodataset.org training images
COCO-FreeView fixations official project page evaluation (real human fixations)

⚠️ The original runwayml/stable-diffusion-v1-5 repo was removed from the Hugging Face Hub; use the mirror stable-diffusion-v1-5/stable-diffusion-v1-5.

Set DATASET_PATH / DATASET_JSON_PATH inside the launcher scripts to your local paths.

Training

Edit the paths at the top of a launcher, then run it from the repo root. Only the adapter is trained; the base models stay frozen.

# Seen2Scene
bash seen2scene/scripts/train_fixation_only.sh
bash seen2scene/scripts/train_fixation_gist.sh
bash seen2scene/scripts/train_gist_only.sh

# MetamerGen
bash metamergen/scripts/train_metamergen.sh

Checkpoints are saved to runs/<model>_<timestamp>/. Metrics log to Weights & Biases (wandb login, or set WANDB_MODE=offline).

Evaluation

The COCO-FreeView freeview evaluation (CLIP + DreamSim) belongs to Seen2Scene: it generates scenes for held-out human viewings and scores fidelity against the originals.

bash seen2scene/scripts/eval_gist_only.sh   # gist-only
bash seen2scene/scripts/eval_freeview.sh    # fixation-only / fixation+gist

Accelerate saves sharded checkpoints; convert one to a single ip_adapter.bin first (the gist eval does this automatically via seen2scene/convert_gist_checkpoint.py; see also seen2scene/convert_checkpoint.py).

ℹ️ MetamerGen is assessed with the behavioral same/different metamer experiment described in its paper, not the freeview automated eval.

Repository layout

.
β”œβ”€β”€ seen2scene/          # CCN 2025: 3 models + freeview eval
β”‚   β”œβ”€β”€ train_fixation_only.py
β”‚   β”œβ”€β”€ train_fixation_gist.py
β”‚   β”œβ”€β”€ train_gist_only.py
β”‚   β”œβ”€β”€ eval_gist_only.py            # DreamSim/CLIP eval (gist-only)
β”‚   β”œβ”€β”€ eval_freeview.py             # DreamSim/CLIP eval (fixation / fixation+gist)
β”‚   β”œβ”€β”€ eval_freeview_fov_per.py     # DreamSim/CLIP eval (foveal+peripheral)
β”‚   β”œβ”€β”€ convert_checkpoint.py, convert_gist_checkpoint.py
β”‚   └── scripts/                     # ready-to-edit train/eval launchers
β”œβ”€β”€ metamergen/          # ICLR 2026: images metameric to human scene understanding
β”‚   β”œβ”€β”€ train_metamergen.py
β”‚   └── scripts/
β”œβ”€β”€ pipeline.py          # Seen2ScenePipeline: image + fixation scanpath -> generated scene
β”œβ”€β”€ notebooks/           # interactive demos (PCA of features + generations)
β”œβ”€β”€ common/              # shared datasets + eval metrics
β”‚   β”œβ”€β”€ COCO_dataset.py              # training data (foveation simulated on COCO)
β”‚   β”œβ”€β”€ COCOFreeView_dataset.py      # eval data (real human fixations)
β”‚   └── eval_utils.py                # DreamSim / CLIP metrics
β”œβ”€β”€ dinov2/              # vendored DINOv2 encoder (code only)
β”œβ”€β”€ ip_adapter/          # vendored IP-Adapter (Resampler, attn processors)
β”œβ”€β”€ environment.yml      # conda environment (recommended)
β”œβ”€β”€ requirements.txt     # pip alternative
└── setup.sh             # create env + download DINOv2 weights

Acknowledgement

We are grateful to the open-source projects this work builds on: DINOv2 (image encoder), IP-Adapter (conditioning), πŸ€— diffusers / Stable Diffusion v1.5, and DreamSim (perceptual metric). The vendored dinov2/ and ip_adapter/ directories retain their upstream licenses.

License

This project's code is released under the Apache License 2.0. The vendored dinov2/ and ip_adapter/ directories are also Apache-2.0 and keep their upstream copyrights (see NOTICE and their LICENSE files).

Stable Diffusion v1.5, which the models build on, is downloaded separately and is governed by the CreativeML OpenRAIL-M license β€” please comply with its use-based restrictions.

Citation

If you find this repository useful, please consider giving a star ⭐ and citing the paper(s) for the model(s) you use:

@inproceedings{raina2025seen2scene,
  title={Seen2Scene: a generative model of fixation-by-fixation scene understanding},
  author={Raina, Ritik and Leite, Abe and Graikos, Alexandros and Ahn, Seoyoung and Zelinsky, Gregory J.},
  booktitle={Conference on Cognitive Computational Neuroscience (CCN)},
  year={2025}
}

@article{raina2026metamergen,
  title={Generating metamers of human scene understanding},
  author={Raina, Ritik and Leite, Abe and Graikos, Alexandros and Ahn, Seoyoung and Samaras, Dimitris and Zelinsky, Gregory J.},
  journal={arXiv:2601.11675},
  year={2026}
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages