Installation¶
FairMedFM supports Python 3.10 to 3.13 and is published on PyPI.
Fairness metrics only¶
pip install fairmedfm
This installs the metrics, the fairmedfm score command and the Python API, with NumPy, pandas and
scikit-learn as the only dependencies. To read Parquet, Feather or Excel tables and PNG, TIFF or NIfTI masks, add
the io extra:
pip install "fairmedfm[io]"
The base install is all you need to evaluate your own model, on any operating system and without a GPU.
Benchmark runner¶
To run the benchmark with the built-in foundation models, install the benchmark runner, fairmedfm-bench, from
GitHub. Install PyTorch for your CUDA version first (see pytorch.org);
otherwise pip installs the default PyTorch build. A separate environment is recommended.
pip install "fairmedfm-bench @ git+https://github.com/FairMedFM/FairMedFM#subdirectory=benchmark"
Linear probing, CLIP zero-shot and CLIP adaptation with the classification models.
pip install "fairmedfm-bench[seg] @ git+https://github.com/FairMedFM/FairMedFM#subdirectory=benchmark"
Promptable segmentation with SAM-family models, in addition to classification.
Always use the full GitHub URL: fairmedfm-bench is not published on PyPI. The runner installs fairmedfm as a
dependency and keeps transformers below 5, albumentations below 2, torchmetrics below 1.7 and setuptools below 81,
because the benchmark code uses APIs that later versions removed. Until version 0.4.0, the runner was part of the pip
package as fairmedfm[cls] and fairmedfm[seg].
Models with separate installs¶
These models need packages that are not on PyPI or that conflict with the runner's dependencies. FairMedFM reports which package is missing when you select one of them.
| Model | Install |
|---|---|
| BLIP, BLIP2 | pip install salesforce-lavis in a separate environment (it pins older dependencies) |
| CONCH | pip install git+https://github.com/Mahmoodlab/CONCH.git |
| Merlin | pip install merlin-vlm |
| SAM2, MedSAM2 | Install SAM2 |
| SAM3, MedicalSAM3 | pip install git+https://github.com/facebookresearch/sam3.git (Python 3.12+, PyTorch 2.7+) |
Some models are gated on Hugging Face: request access on the model page, then run huggingface-cli login
or set HF_TOKEN. See Models.
Check the installation¶
fairmedfm --version
fairmedfm run --help # needs the benchmark runner
Paper environment¶
The paper's experiments used Python 3.8 and the conda environment in the repository. To use it, clone the
repository and run python main.py, which accepts the same arguments as fairmedfm run:
git clone https://github.com/FairMedFM/FairMedFM.git
cd FairMedFM
conda env create -f environment.yml
conda activate fairmedfm
python main.py --help
See Reproduce the paper.