Zhangyuan Yu*1, Chenlin Du*2, Hongrui Liang1, Xiuqi Zheng1, Zeyao Ma3, Mingjun Wu4, Mingwu Ao4, Qicheng Lao1,📧
1 School of Artificial Intelligence, Beijing University of Posts and Telecommunications (BUPT), Beijing, China
2 Department of Geriatric Dentistry, Peking University School and Hospital of Stomatology & National Center of Stomatology & National Clinical Research Center for Oral Diseases & Research Center of Engineering and Technology for Computerized Dentistry Ministry of Health & NMPA Key Laboratory for Dental Materials, Beijing, China
3 Department of Orthodontics, School of Stomatology, Capital Medical University, Beijing, China
4 Ningbo Fregty Optoelectronics Technology Co., Ltd, Ningbo, China
(* equal contribution, 📧 corresponding author)
Endoscopic imaging plays a crucial role in modern diagnostics and minimally invasive procedures. However, Artifacts caused by specular and diffuse reflections present significant challenges to downstream tasks such as segmentation.
Inspired by the simplified Phong model for endoscopy, we propose a two-stage artifact inpainting framework. The first stage suppresses specular artifacts, while the second stage focuses on inpainting diffuse artifacts. Additionally, we introduce a weight map to control the handling of diffuse artifacts, ensuring a more precise enhancement.
The two-stage artifact inpainting framework is composed of:
- Suppresses Specular Artifact via a DUCKNet(Trained from scratch) + LaMa pipeline.
- Refines Diffuse Artifact using StableDelight with an adaptive weight-map guided fusion.
Extensive experiments on colonoscopy and dental endoscopy datasets show that our method significantly improves segmentation accuracy (mDice ↑ from 51.5% to 96.1% for zero-shot when SAM segmentation using point prompt).

Figure 1: Overview of our two-stage endoscopic artifact inpainting framework.
This repository is developed with Python 3.10.16. Create a virtual environment and install dependencies:
# clone repository
git clone git@github.com:Raven-July/Endoscopic-Artifact-Inpainting.git
cd Endoscopic-Artifact-Inpainting
# create conda environment
conda create -n Artifact python==3.10
conda activate Artifact
# install dependencies
pip install uv
uv pip install -r requirements.txt-
DUCKNet Model
- Download from GoogleDrive
- Place
Duck16mod_Spec_99_new.ptinto./weightsfolder.
-
Pretrained Big-LaMa Model
- Download from GoogleDrive
- Unzip and place the
big-lamafolder into./weightsfolder.
-
Pretrained StableDelight Model
- Download from HuggingFace
- Place the
yoso-delight-v0-4-basefolder into./weightsfolder.
Simply execute:
sh process.shThis will run the full two-stage artifact inpainting pipeline. Results will appear in ./outputs folder.
| Parameter | Description | Default |
|---|---|---|
lama_dilate_size |
Controls the dilation kernel size applied to the DUCKNet specular mask before passing to Big-LaMa. Larger values remove more highlights but risk over-inpainting. | 15 |
mix_thresh |
Threshold for fusing DUCKNet+LaMa result with StableDelight output. Pixels above this brightness are considered diffuse highlights and blended with StableDelight output. | 150 |
You can modify these parameters in process.sh before running the pipeline.
Links to public datasets:
Coming soon...
Coming soon...
Our method achieves better artifact inpainting quality and robustly improve the segmentation performance of endoscopic images.

Figure 2: Quantitative comparison for segmentation performance enhancement.

Figure 3: Visual comparison of artifact inpainting results.

Figure 4: Segmentation result comparisons between our method and baselines.
If you find this repository useful, please cite our paper:
@InProceedings{YuZha_Endoscopic_MICCAI2025,
author = { Yu, Zhangyuan AND Du, Chenlin AND Liang, Hongrui AND Zheng, Xiuqi AND Ma, Zeyao AND Wu, Mingjun AND Ao, Mingwu AND Lao, Qicheng},
title = { { Endoscopic Artifact Inpainting for Improved Endoscopic Image Segmentation } },
booktitle = {proceedings of Medical Image Computing and Computer Assisted Intervention -- MICCAI 2025},
year = {2025},
publisher = {Springer Nature Switzerland},
volume = {LNCS 15969},
month = {September},
page = {191 -- 201}
}This repository is released under Apache-2.0 license. See LICENSE for details.
Our work builds upon valuable open-source contributions from DUCKNet, LaMa, StableDelight, and FCBFormer, whose efforts made this research possible.
This work makes use of data from the Restored CVC-ClinicSpecific dataset(Unofficial Version).
This work was supported by Ningbo Fregty Optoelectronics Technology