Code for running R2-V2, the winning method of the Generalized Analysis of Vessels in Eye (GAVE) Challenge at MICCAI 2025, focused on artery/vein segmentation in retinal fundus images.
R2-V2 is based on our earlier RRWNet method.
There are two models available, av and bv. Both of them perform vessel segmentation and artery/vein classification. However, they have different characteristics:
av: This model is mostly focused on the correct classification of arteries and veins, with a very high vessel sensitivity.bv: This model is more balanced, and performs particularly well for vessel segmentation.
The weights and the configuration files of the models are available at the Releases section.
The implementation is based on Python 3.12.8, PyTorch 2.8, and CUDA 12.8. It also uses other libraries, such as scikit-image and NumPy, for image processing and transformations.
Thus, for running the code, it is first necessary to set up the environment.
Installing Python 3.12.8 using pyenv
📌 IMPORTANT: The following steps are only necessary if you want to install Python 3.12.8 using
pyenv.
Install pyenv.
curl https://pyenv.run | bashInstall clang. E.g.:
sudo dnf install clangInstall Python version 3.12.8.
CC=clang pyenv install -v 3.12.8Create and activate Python environment.
~/.pyenv/versions/3.12.8/bin/python3 -m venv venv/
source venv/bin/activate # bash
. venv/bin/activate.fish # fishUpdate pip if necessary.
pip install --upgrade pipCreate and activate Python environment.
python -m venv venv/
source venv/bin/activate # bash
. venv/bin/activate.fish # fishInstall requirements using requirements.txt.
pip3 install -r requirements.txtTo run the code, use the infer.py script. Please check the available options using the -h or --help flag.
The models need preprocessed images in order to work well. If no directory with preprocessed images is indicated, the inference code will preprocess the image on the fly. However, it is also possible to preprocess all the images before running inference using preprocessing.py. Again, please check the available options using the -h or --help flag.