This repository contains the code for the In-Context RCA project. It includes RCA classifier models, a UNet for segmentation, and utilities to support training and inference using PyTorch.
-
Install the required dependencies by running:
pip install -r requirements.txt
-
Install SAM 2 following the SAM 2 installation instructions.
-
Download the SAM 2 checkpoints and place the folder inside the
segment-anything-2
. -
Replace the contents of the
sam2
folder with the ones fromsegment-anything-2
. Once the replacement is complete, you may safely delete thesegment-anything-2
folder.
- unet_segmentations: Contains different quality segmentations generated with a UNet.
- src: Contains the supported models along with scripts for preprocessing, generating the datasets and evaluation
- scripts: Contains
run_inference.py
andcustom_inference.py
scripts for reproducing experiments and running the method on user's custom data.
The following datasets were used:
To reproduce experiments on the datasets used in the paper, execute the following command with the run_inference.py
script:
python run_inference.py --dataset <dataset_path> --classifier <classifier_name> --output_file <output_file_path>
To run inference on your own data, you can use the custom_inference.py
script:
python custom_inference.py --ref_dataset <reference_dataset_path> --eval_dataset <eval_data_path> --n_classes <num_of_classes> --classifier <classifier_name> --output_file <output_file_path>
If you are using our masks please cite our work:
@misc{cosarinsky2025incontextreverseclassificationaccuracy,
title={In-Context Reverse Classification Accuracy: Efficient Estimation of Segmentation Quality without Ground-Truth},
author={Matias Cosarinsky and Ramiro Billot and Lucas Mansilla and Gabriel Gimenez and Nicolas Gaggión and Guanghui Fu and Enzo Ferrante},
year={2025},
eprint={2503.04522},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2503.04522},
}