Add 6 files
Browse filesFiles changed (6)
- README.mdAdded+58
- checkpoints/clip_best.ptAdded+3
- checkpoints/vgg_best.ptAdded+3
- clip_bridge.safetensorsAdded+3
- config.jsonAdded+28
- vgg_bridge.safetensorsAdded+3
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758---license: mitlibrary_name: pytorchtags: [fmri, neuroscience, brain-decoding, natural-scenes-dataset]datasets: [teooi/cortexdecoder-nsd-flatmaps]---
# CortexDecoder
Bridge weights for [CortexDecoder](https://www.biorxiv.org/content/10.64898/2026.10.09.757766v1), trained on NSD Subject 1. Code is on [GitHub](https://github.com/teooi/CortexDecoder) and the flatmaps andreconstructions are in [teooi/cortexdecoder-nsd-flatmaps](https://huggingface.co/datasets/teooi/cortexdecoder-nsd-flatmaps).
A frozen CortexMAE encoder turns visual-cortex flatmap patches into 200 brain tokens of dimension 768. Two cross-attentionbridges map those tokens to image features.
| File | Bridge | Output | Parameters ||---|---|---|---|| `vgg_bridge.safetensors` | low-level | 7190 VGG16-BN tokens of dimension 512, inverted to an image with a Deep Image Prior | 43.7M || `clip_bridge.safetensors` | semantic | 256 OpenCLIP ViT-bigG/14 tokens of dimension 1664, used to condition SDXL-unCLIP | 39.3M |
`checkpoints/` has the original training checkpoints, which also contain the optimizer state. `config.json` lists thebridge settings.
## Loading
```pythonfrom huggingface_hub import hf_hub_downloadfrom safetensors.torch import load_filefrom cortexdecoder.core.config import Config # from the GitHub repo, code/v2from cortexdecoder.models.bridge import FlatmapSingleHeadBridge
bridge = FlatmapSingleHeadBridge(Config(), brain_dim=768, num_patches=200, target="clip")bridge.load_state_dict(load_file(hf_hub_download("teooi/cortexdecoder", "clip_bridge.safetensors")))clip_tokens = bridge(brain_tokens) # [B, 200, 768] -> [B, 256, 1664]```
The brain tokens come from `code/v2/scripts/generate_roi_tokens.py`, which runs CortexMAE with only the visual-cortexpatches visible.
## Results
NSD Subject 1, 998 test images, one diffusion sample per image.
| PixCorr | SSIM | Alex(2) | Alex(5) | Incep | CLIP | Eff | SwAV ||---|---|---|---|---|---|---|---|| 0.366 | 0.413 | 98.1% | 99.1% | 94.9% | 93.5% | 0.628 | 0.360 |
## Citation
```bibtex@article{imototar2026cortexdecoder, title = {CortexDecoder: fMRI-to-image Reconstruction from Cortical Flatmaps}, author = {Imoto-Tar, Teo and Fung, Maxwell and Gurha, Arnav}, journal = {bioRxiv}, year = {2026}, doi = {10.64898/2026.10.09.757766}}```123version https://git-lfs.github.com/spec/v1oid sha256:7968b43bf70d2c4009547b2024c0b3a79a8b469790f58c89ec39db6717e43a3fsize 471515019123version https://git-lfs.github.com/spec/v1oid sha256:1ed302c774be3deed12f738de4a898cdb726cc738ae2a90a8b719e8d330b2343size 524787601123version https://git-lfs.github.com/spec/v1oid sha256:2259b8f9773fe3a41435215f8df5691d20faac804048532cf82a51c2dce263b3size 15714801612345678910111213141516171819202122232425262728{ "vgg_bridge": { "d_model": 768, "n_layers": 4, "n_heads": 8, "ffn_dim": 3072, "dropout": 0.1, "brain_dim": 768, "num_brain_tokens": 200, "brain_tokens": "flatmap_tokens_roi-nsdgeneral_fp16", "best_epoch": 21, "parameters_millions": 43.7 }, "clip_bridge": { "d_model": 768, "n_layers": 4, "n_heads": 8, "ffn_dim": 3072, "dropout": 0.1, "brain_dim": 768, "num_brain_tokens": 200, "brain_tokens": "flatmap_tokens_roi-nsdgeneral_fp16", "best_epoch": 5, "parameters_millions": 39.3, "clip_loss": "mse", "decoder_loss_weight": 16.0 }}123version https://git-lfs.github.com/spec/v1oid sha256:184aa5606c83a8fb6f9c093aabc4d8a3f19604b710b3fea8a7a6b3fa338d6720size 174905712README.mdAdded+58
checkpoints/clip_best.ptAdded+3
checkpoints/vgg_best.ptAdded+3
clip_bridge.safetensorsAdded+3
config.jsonAdded+28
vgg_bridge.safetensorsAdded+3