VisionHOPE README

The project's README from github.com/PSRben/VisionHOPE. As one markdown file: README.md.

VisionHOPE

Visual Backbones as Self-Modifying Learning Systems

Siran Peng* · Tianshuo Zhang* · Tianyu Fu · Weisong Zhao · Haoyuan Zhang
Jiankuo Zhao · Minghui Wu · Ping Jiang · Xiangyu Zhu · Chenxu Zhao† · Zhen Lei†

* Equal contribution.   †Corresponding authors.

arXiv: 2609.33325 PyTorch 2.1 Hugging Face Models License: MIT

📄 Paper · 🤗 Hugging Face Paper · Updates · Overview · Results & checkpoints · Citation

Installation · Models · SRNL & operator · Fast inference · Datasets · Training · Evaluation · Efficiency

PyTorch implementation of VisionHOPE, a visual backbone based on self-referential nested learning (SRNL). This repository provides ImageNet classification, COCO detection and instance segmentation, and ADE20K semantic segmentation, along with standalone SRNL and VisionHOPE operator modules.

Pretrained weights: GitHub Releases · Hugging Face · Baidu Netdisk (visionhope_weights, access code: 8866).

Progression from CNNs, ViTs, SSMs, and TTT to nested learning: VisionHOPE adapts both its memory and the rule that updates it within an image.

From adaptive visual computation to self-modifying learning within an image.

Updates

Overview

VisionHOPE builds on the self-referential construction in Nested Learning: The Illusion of Deep Learning Architectures. It lets what the model remembers and how it learns evolve together while processing an image. The VisionHOPE operator combines:

  1. Coupled memories. Five memories store content, generate key and value representations, and govern learning rate and retention. They co-evolve as visual context accumulates.
  2. Stable updates. A soft injection cap and a spectral clamp provide non-expansion guarantees for both token-wise and chunk-wise memory recurrences.
  3. Spatially aligned scans. Four directional scans use row- and column-aligned chunks, followed by spatial restoration and learned channel-wise fusion.

VisionHOPE operator and residual block: four directional SRNL scans with five coupled memories, stability-matched step-size control, and channel-wise output fusion.

The VisionHOPE operator (left) and residual block (right). Click the figure to inspect the full resolution.

The hierarchical Tiny / Small / Base backbones support classification and dense prediction. For use in other architectures, see the standalone SRNL, operator, and block interfaces.

Installation

Use Linux with an NVIDIA GPU and the CUDA toolkit, including nvcc and a C++ compiler. Python 3.10 is recommended for all tasks; classification also supports Python 3.11. Run the following from the repository root, with CUDA 12.1 installed:

python -m pip install torch==2.1.0 torchvision==0.16.0 \
    --index-url https://download.pytorch.org/whl/cu121
python -m pip install -r requirements/classification.txt
python -m pip install --no-deps -e .

CUDA extensions compile on first use. Keep model parameters in FP32 and use torch.autocast for mixed precision.

Additional dependencies for COCO and ADE20K

Use a separate Python 3.10 environment for each task, with the PyTorch and CUDA versions above. Install MMCV, then the task dependencies:

python -m pip install --only-binary=mmcv mmcv==2.1.0 \
    -f https://download.openmmlab.com/mmcv/dist/cu121/torch2.1/index.html

For COCO:

python -m pip install -r requirements/detection.txt
python -m pip install --no-deps -e .

For ADE20K:

python -m pip install -r requirements/segmentation.txt
python -m pip install --no-deps -e .

Models

Use these model names and checkpoint filenames for ImageNet-1K classification at 224 × 224. Accuracy and complexity are listed in Main results.

Model Name Checkpoint filename
VisionHOPE-T visionhope_tiny visionhope_tiny.pth
VisionHOPE-S visionhope_small visionhope_small.pth
VisionHOPE-B visionhope_base visionhope_base.pth

The train/test scripts look for checkpoints in weights/; set WEIGHTS_ROOT to use another directory. COCO checkpoints are named visionhope_<size>_coco_<schedule>.pth (e.g. visionhope_small_coco_3x.pth); ADE20K checkpoints are named visionhope_<size>_ade20k.pth.

Download a checkpoint from Hugging Face into weights/ with the Hugging Face CLI. Run these commands from the repository root:

python -m pip install --upgrade huggingface_hub
hf download PSRben/VisionHOPE visionhope_small.pth --local-dir weights

Replace visionhope_small.pth with the checkpoint filename for your model and task. To download all classification, COCO, and ADE20K checkpoints:

hf download PSRben/VisionHOPE --include "visionhope_*.pth" --local-dir weights

Load an ImageNet-1K checkpoint with Python:

import torch
from visionhope.models import create_model

model = create_model(
    "visionhope_small", checkpoint_path="weights/visionhope_small.pth"
).cuda().eval()

with torch.inference_mode():
    logits = model(torch.randn(1, 3, 224, 224, device="cuda"))  # [1, 1000]

Omit checkpoint_path to create a model for training.

SRNL and VisionHOPE operator

SRNL accepts sequences of shape [batch, tokens, dim] and returns the same shape:

import torch
from visionhope.models import SRNL

srnl = SRNL(dim=64, head_dim=16, chunk_size=64).cuda()
x = torch.randn(2, 257, 64, device="cuda", requires_grad=True)
y = srnl(x)
y.square().mean().backward()

Pass srnl(x, queries=q) to supply queries of the same shape as x; otherwise, x is also used as the query. Each forward call starts a new sequence. dim must be divisible by head_dim, which supports 4, 8, 16, 32, and 64.

VisionHOPEOperator and VisionHOPEBlock accept image features in [batch, channels, height, width] format and preserve their shape:

import torch
from visionhope.models import VisionHOPEOperator, VisionHOPEBlock

x = torch.randn(2, 64, 14, 20, device="cuda")
operator = VisionHOPEOperator(dim=64, head_dim=16).cuda()
block = VisionHOPEBlock(dim=64, mixer_dim=32, head_dim=16).cuda()

y = operator(x)
z = block(x)

mixer_dim sets the block's internal width. All three components require CUDA and support training with autograd.

chunk_size=None uses 64-token chunks for standalone SRNL and row/column chunks for image operators and blocks. You can also specify a positive chunk length; rectangular feature maps and sequences with an incomplete final chunk are supported.

Fast inference

For standalone SRNL and operators, set fast_inference=True, call .eval(), and disable gradients:

import torch
from visionhope.models import SRNL, VisionHOPEOperator

srnl = SRNL(dim=64, fast_inference=True).cuda().eval()
operator = VisionHOPEOperator(dim=64, fast_inference=True).cuda().eval()

with torch.inference_mode():
    y = srnl(torch.randn(2, 257, 64, device="cuda"))
    z = operator(torch.randn(2, 64, 14, 20, device="cuda"))

The same flag can be changed after construction, for example srnl.fast_inference = True. It leaves weights unchanged and does not affect training. If you supply separate SRNL queries, their dtype must match the input for fast inference.

For blocks and complete models, use prepare_for_inference after loading weights:

import torch
from visionhope.models import create_model
from visionhope.inference.prepare import prepare_for_inference

model = create_model(
    "visionhope_small", checkpoint_path="weights/visionhope_small.pth"
).cuda().eval()
prepare_for_inference(model)

with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16):
    logits = model(torch.randn(1, 3, 224, 224, device="cuda"))

prepare_for_inference fuses model parameters in place for fast inference. Keep an unprepared copy if you also need to continue training. The test scripts below enable fast inference by default; pass --mode ordinary to disable it.

Datasets

Download ImageNet-1K (ILSVRC 2012), COCO 2017, and ADE20K from their official websites.

Arrange the datasets as follows, or point the scripts to equivalent locations with --data-root:

data/
├── imagenet/
│   ├── train/<class_name>/*.JPEG
│   └── val/<class_name>/*.JPEG
├── coco/
│   ├── train2017/
│   ├── val2017/
│   └── annotations/instances_{train,val}2017.json
└── ade20k/
    ├── images/{training,validation}/
    └── annotations/{training,validation}/

You can also set IMAGENET_ROOT, COCO_ROOT, and ADE20K_ROOT to your dataset directories. For ADE20K, use the extracted ADEChallengeData2016 directory as the root.

Training

The scripts in scripts/train contain the training recipes. Matching evaluation scripts are in scripts/test.

Task Sizes Script name
ImageNet-1K tiny, small, base visionhope_<size>.sh
COCO, Mask R-CNN 1× tiny, small, base visionhope_<size>_coco_1x.sh
COCO, Mask R-CNN 3× tiny, small visionhope_<size>_coco_3x.sh
ADE20K, UPerNet tiny, small, base visionhope_<size>_ade20k.sh

For example, to train VisionHOPE-S on eight GPUs:

# ImageNet-1K
NPROC_PER_NODE=8 bash scripts/train/visionhope_small.sh \
    --data-root data/imagenet --output outputs/visionhope_small

# COCO
NPROC_PER_NODE=8 bash scripts/train/visionhope_small_coco_1x.sh \
    --data-root data/coco --pretrained weights/visionhope_small.pth

# ADE20K
NPROC_PER_NODE=8 bash scripts/train/visionhope_small_ade20k.sh \
    --data-root data/ade20k --pretrained weights/visionhope_small.pth

Training defaults to eight GPUs. Set NPROC_PER_NODE=1 for a single GPU. --batch-size is per GPU; the learning rate scales with the effective global batch unless --lr is given. Arguments appended to a script override its defaults. COCO and ADE20K training use ImageNet-pretrained backbones.

Outputs go to outputs/train/<script-name>/ unless --output is supplied. Use best.pth for evaluation and training_state.pth to resume training:

bash scripts/train/visionhope_small.sh \
    --resume outputs/visionhope_small/training_state.pth \
    --output outputs/visionhope_small

For argument descriptions, defaults, and choices:

python -m visionhope.tasks.cli train classification --help

Replace classification with detection or segmentation for the other tasks.

Evaluation

Run the matching test script with a checkpoint and dataset:

CUDA_VISIBLE_DEVICES=0 bash scripts/test/visionhope_small.sh \
    --data-root data/imagenet --checkpoint weights/visionhope_small.pth

CUDA_VISIBLE_DEVICES=0 bash scripts/test/visionhope_small_coco_1x.sh \
    --data-root data/coco --checkpoint weights/visionhope_small_coco_1x.pth

CUDA_VISIBLE_DEVICES=0 bash scripts/test/visionhope_small_ade20k.sh \
    --data-root data/ade20k --checkpoint weights/visionhope_small_ade20k.pth

The scripts set the evaluation precision and preprocessing for each task. ImageNet evaluation uses FP32, 224 × 224 inputs, and crop ratio 1.0. Pass --precision fp16 or --precision bf16 to a test script for mixed-precision evaluation. Classification accepts --num-classes to match the checkpoint's output classes and --no-cudnn-benchmark to disable cuDNN algorithm benchmarking. For COCO and ADE20K, use --test-scale W H to change the resize scale while keeping the aspect ratio; defaults are 1333 800 and 2048 512, respectively. ADE20K evaluation defaults to batch size 1; larger batches require images of the same size after preprocessing. Results are saved under outputs/test/<script-name>/; pass --output with a different directory for another evaluation of the same model. Use python -m visionhope.tasks.cli inference classification --help for evaluation options; the other task names work here too.

Main results

The tables below summarize ImageNet-1K, COCO, and ADE20K results for the hierarchical VisionHOPE-T / S / B models. See the paper for experimental details. Pretrained checkpoints are available from GitHub Releases, Hugging Face, and Baidu Netdisk (access code: 8866).

ImageNet-1K classification

Trained on ImageNet-1K; single-crop evaluation at 224 × 224. FLOPs include the classification head.

Model Params (M) FLOPs (G) Top-1 (%) ↑ Recipe CKPT
VisionHOPE-T 26.6 4.9 84.1 Train / Eval GitHub / Hugging Face
VisionHOPE-S 52.9 9.8 85.2 Train / Eval GitHub / Hugging Face
VisionHOPE-B 91.2 17.3 85.6 Train / Eval GitHub / Hugging Face

COCO detection and instance segmentation

Mask R-CNN, initialized with ImageNet-1K-pretrained backbones and evaluated on val2017. FLOPs are for the full detector at 1280 × 800. Box AP and mask AP are reported in percent.

1× schedule

Backbone FLOPs (G) Box AP ↑ Mask AP ↑ Recipe CKPT
VisionHOPE-T 266 47.9 43.1 Train / Eval GitHub / Hugging Face
VisionHOPE-S 365 49.5 44.2 Train / Eval GitHub / Hugging Face
VisionHOPE-B 516 50.5 45.0 Train / Eval GitHub / Hugging Face

3× schedule

Backbone FLOPs (G) Box AP ↑ Mask AP ↑ Recipe CKPT
VisionHOPE-T 266 49.4 44.1 Train / Eval GitHub / Hugging Face
VisionHOPE-S 365 50.5 45.0 Train / Eval GitHub / Hugging Face

ADE20K semantic segmentation

UPerNet, initialized with ImageNet-1K-pretrained backbones; single-scale validation. Parameters are for the complete model; inference FLOPs are measured at 512 × 2048.

Backbone Params (M) FLOPs (G) mIoU (%) ↑ Recipe CKPT
VisionHOPE-T 55.4 942 49.4 Train / Eval GitHub / Hugging Face
VisionHOPE-S 81.8 1043 50.3 Train / Eval GitHub / Hugging Face
VisionHOPE-B 121.2 1200 51.8 Train / Eval GitHub / Hugging Face

See Evaluation for precision and preprocessing, and Efficiency for FLOP-counting and timing conventions.

Efficiency

Measure parameters, inference FLOPs, throughput, and GPU memory without a dataset:

bash run_inference.sh complexity --model visionhope_small
bash run_inference.sh efficiency --model visionhope_small

bash run_inference.sh complexity --task detection --model visionhope_small \
    --checkpoint weights/visionhope_small_coco_1x.pth --shape 1280 800
bash run_inference.sh efficiency --task segmentation --model visionhope_small \
    --checkpoint weights/visionhope_small_ade20k.pth --shape 512 2048

--shape takes height and width. Use --help for batch size, precision, and timing options, and --output result.json to save a report. Throughput and memory measurements use fast inference. They measure the model forward pass on synthetic inputs, excluding data loading, preprocessing, and prediction postprocessing. FLOPs count one multiply-add as one operation. COCO counts depend on the proposals generated for the input; the report lists operations outside the FLOP count. memory.eager reports peak CUDA memory, including model weights and inputs; CUDA Graph memory is reported separately.

Citation

If VisionHOPE is useful for your research, please cite the arXiv preprint:

@article{peng2026visionhope,
  title   = {VisionHOPE: Visual Backbones as Self-Modifying Learning Systems},
  author  = {Peng, Siran and Zhang, Tianshuo and Fu, Tianyu and Zhao, Weisong
             and Zhang, Haoyuan and Zhao, Jiankuo and Wu, Minghui and Jiang, Ping
             and Zhu, Xiangyu and Zhao, Chenxu and Lei, Zhen},
  journal = {arXiv preprint arXiv:2609.33325},
  year    = {2026},
  doi     = {10.48550/arXiv.2609.33325},
  url     = {https://arxiv.org/abs/2609.33325}
}

License

VisionHOPE is released under the MIT License. See Third-party notices for third-party attribution and licenses.

VisionHOPE (PSRben/VisionHOPE)

Searching Database…

这是什么?VisionHOPE 是基于自引用嵌套学习(SRNL)构建的视觉骨干网络的官方 PyTorch 实现,支持 ImageNet-1K 分类、COCO 检测/实例分割和 ADE20K 语义分割。
这是可训练的模型库,还是完整的应用?它是一个研究代码库和 PyTorch 库:提供三种规模的骨干网络(Tiny/Small/Base),以及可插入其他架构的独立 SRNL、算子和 block 模块,还附带 ImageNet、COCO 和 ADE20K 的训练与评估脚本。
怎么让它跑起来?克隆仓库,在配有 CUDA 12.1 的 Linux 上配置 Python 3.10(做分类用 3.11 也可以),然后从仓库根目录运行安装命令;CUDA 扩展会在首次使用时自动编译。COCO 和 ADE20K 各自需要独立的 Python 3.10 环境,外加 MMCV 和对应任务的依赖。
需要 NVIDIA GPU 和 CUDA 工具包吗?需要,它要求 Linux、NVIDIA GPU、CUDA 工具包(nvcc 加 C++ 编译器)和 PyTorch;COCO 和 ADE20K 还需要在各自的 Python 环境中安装 MMCV。
环境搭建有什么需要留意的坑吗?CUDA 扩展必须在首次运行时编译,而且 COCO/ADE20K 各自需要带有匹配 PyTorch/CUDA 版本和 MMCV 的隔离 Python 3.10 环境,这让检测/分割的环境搭建比单纯分类更麻烦。
没有独立 GPU 能运行吗?不能,SRNL、算子和 block 模块都要求 CUDA 和 NVIDIA GPU;没有提到任何纯 CPU 的运行路径。
VisionHOPE 有哪几种模型规模?三个分层骨干网络——VisionHOPE-T、-S 和 -B——参数量分别为 26.6M、52.9M 和 91.2M,ImageNet-1K top-1 准确率分别达到 84.1%、85.2% 和 85.6%。
SRNL 是什么?自引用嵌套学习,是 VisionHOPE 的核心机制:五个相互耦合的记忆体共同存储内容,并共同掌控键、值、学习率和保留机制,让模型“记住什么”和“如何学习”在处理图像的过程中共同演化。
可以在 VisionHOPE 骨干网络之外使用 SRNL 或算子模块吗?可以,独立的 SRNL、VisionHOPEOperator 和 VisionHOPEBlock 模块都可以导入其他架构;它们需要 CUDA,并支持基于 autograd 的训练。
如何加速推理?在 SRNL/算子上设置 fast_inference=True,或对完整模型调用 prepare_for_inference,即可融合权重以加快前向计算,同时不影响训练行为。
Creator
PSRben
Size
0.7 MB
Stars
1.3K
Age
21d
Commits · 90 Days