--- license: cc-by-4.0 library_name: pytorch pipeline_tag: image-segmentation tags: - retinal-vessel-segmentation - artery-vein-classification - medical-imaging - fundus-photography --- # R2-V2 (bv) Weights for the `bv` variant of **R2-V2**, the winning method of the **Generalized Analysis of Vessels in Eye (GAVE) Challenge at MICCAI 2025**, for blood vessel segmentation and artery/vein classification in retinal fundus images. R2-V2 is based on the [RRWNet](https://github.com/j-morano/rrwnet) architecture. The `bv` model is more balanced than the `av` variant, and performs particularly well for vessel segmentation. This repo is meant for **easy inference**: it bundles the `bv` weights together with the (unmodified except for `.safetensors` loading support) code needed to run them, so it works standalone without cloning anything else. For the full training/reproducibility code, see the [R2-V2 GitHub repo](https://github.com/j-morano/R2-V2). ## Files - `bv.safetensors`: model weights (RRWNet state dict). - `bv_config.json`: configuration used to produce these weights. - `model.py`, `infer.py`, `preprocessing.py`, `transformations.py`: inference pipeline code (image preprocessing, artery/vein post-processing, CLI). - `requirements.txt`: pinned dependencies (Python 3.12.8, PyTorch 2.8, CUDA 12.8). ## Usage ```sh python -m venv venv/ && source venv/bin/activate pip install -r requirements.txt python infer.py -i -t bv -w . -s ``` `-w .` tells `infer.py` to look for `bv.safetensors` and `bv_config.json` in the current directory. Run `python infer.py -h` for all options (test-time augmentation, masks, GAVE output format, etc.). To load the weights manually instead: ```python import json from safetensors.torch import load_model from model import RRWNet config = json.load(open("bv_config.json")) model = RRWNet( input_ch=config["in_channels"], output_ch=config["out_channels"], base_ch=config["base_channels"], num_iterations=config["num_iterations"], ) load_model(model, "bv.safetensors") model.eval() ```