This repository provides the codebase for evaluating image inpainting methods—
The results reported in this repository are described in a paper submitted to the Computers in Biology and Medicine. Additionally, the supplementary material can be viewed here.
Example of inpainted images produced by the evaluated methods, across the three missingness mechanisms (MAR, MNAR, MCAR):
Beyond pixel-level reconstruction quality, we measure how each inpainting method affects a downstream VGG16 classification task (Accuracy, F1, AUC) compared to a clean, non-corrupted baseline:
To test whether the evaluated methods generalize beyond mammography, we repeat the inpainting evaluation on the BreaKHis histopathology dataset, additionally benchmarking MAT and HARP:
We recommend creating a virtual environment before running the experiments:
python -m venv env
source env/bin/activate # On Linux/macOS
.\env\Scripts\activate # On WindowsTo install the required dependencies, run:
pip install -r requirements.txt
pip install flaskTo reproduce the results reported in the paper, run the following scripts according to each missingness mechanism:
python codes/experimental_design_dead_pixels.py # MCAR
python codes/experimental_design_random_square.py # MAR
python codes/experimental_design_stripes.py # MNARTo reproduce the histopathology generalization study (BreaKHis):
python codes/experimental_design_breakhist.pyTo reproduce the downstream classification impact analysis:
python codes/classification_vgg16.pyAfter running all experiments, aggregate the results with:
python codes/aux_codes.pyTo promote reproducibility and support further research in mechanism-aware image inpainting, we introduce MedInpainter, an open-source, browser-based framework designed for mammographic imaging.
The framework provides:
- Mapping to missingness mechanisms (MCAR, MAR, MNAR)
- Standardized and reproducible evaluation protocols
- Benchmarking support for inpainting methods
- Human-in-the-loop feedback collection for qualitative assessment
Launch the application with:
python app.pyIt starts a local Flask server at http://127.0.0.1:5000/ — open that address in your browser. Note that app.py runs Flask's development server (debug=True); it is intended for local/research use, not production deployment.
- Choose a dataset from the sidebar: INBreast, MIAS, CBIS-DDSM, or VinDr-Mammo. (If a dataset isn't available locally, MedInpainter falls back to a synthetic mammogram-like image in "Demo Mode".)
- Choose a missingness mechanism and tune its parameters with the sliders:
- MCAR — Dead Pixels (single-pixel and cluster dropout probabilities, cluster size)
- MAR — Random Squares (square size)
- MNAR — Column Stripes (fraction of corrupted columns, stripe width)
- MNAR — Saturation Dropout (alpha, threshold)
- Choose an inpainting algorithm: kNN, Matrix Completion, VAE-WL, CMask-ViT (MAE-ViT), DIP, or Diffusion.
- Select an image using the index field or the previous/next arrows, then click Generate.
- Inspect the result grid — Original, Corrupted, Binary Mask, and Imputed image — along with PSNR, SSIM, MAE, and missing-pixel percentage. Each image card can be downloaded individually.
- Rate the result (1–5 stars, with optional notes) and click Save Feedback. Saved entries appear in the Feedback History panel and can be exported as a CSV file for later analysis.
Contributions are welcome! If you find this project useful, consider giving it a ⭐ on GitHub.
% Citation will be provided as soon as possible.This project is licensed under the MIT License — see the LICENSE file for details.
This study was financed, in part, by the São Paulo Research Foundation (FAPESP), Brasil. Process Numbers 2021/06870-3 and 2024/23791-8. This work was also financed through national funds by FCT - Fundação para a Ciência e a Tecnologia, I.P., in the framework of the Project UIDB/00326/2025 and UIDP/00326/2025. Additionally, it was supported by the Portuguese Recovery and Resilience Plan (PRR) through project C645008882-00000055-Center for Responsable AI.



