The complete source code for AFN-DeSeg (Auto-Fluorescence Nuclei Denoising and Segmentation) is publicly available to ensure full reproducibility of the results presented in this study.
GitHub Repository: https://github.com/z-pan/AFN-DeSeg
The repository includes:
-
Model Implementation
- AFN-DeSeg dual-encoder architecture (U-Net + DINOv3 ViT)
- LoRA adaptation modules for efficient fine-tuning
- Attention U-Net for Key Diagnostic Area (KDA) prediction
-
Training Scripts
- Stage 1: DINO domain adaptation for TPAF microscopy
- Stage 2: Joint denoising and segmentation training
- KDA model training
-
Data Processing
- Mixed Poisson-Gaussian (MPG) noise synthesis
- Data augmentation pipelines
- Dataset loaders for TPAF images
-
Evaluation
- Comprehensive metrics (PSNR, SSIM, Dice, IoU, mAP, HD95)
- KDA-specific metrics (KAF, nuclear density correlation)
- Bland-Altman analysis for clinical validation
-
Inference
- Prediction scripts for new TPAF images
- Batch processing utilities
- Python >= 3.8
- PyTorch >= 2.0.0
- CUDA >= 11.7 (for GPU acceleration)
- GPU: NVIDIA GPU with >= 8GB VRAM (recommended: RTX 3090 or A100)
- RAM: >= 32GB system memory
- Storage: >= 10GB for code, models, and sample data
- Fresh installation: ~10-15 minutes
- With pre-downloaded model weights: ~5 minutes
Pretrained model weights are available at:
- DINOv3 backbone:
facebook/dinov3-vitb16-pretrain-lvd1689m(HuggingFace) - AFN-DeSeg checkpoint: Available in the
checkpoint/directory
All experiments use fixed random seeds for reproducibility:
- PyTorch seed: 42
- NumPy seed: 42
- CUDA deterministic mode: enabled
- Training (Stage 2, 150 epochs): ~12-24 hours on single A100 GPU
- Inference (per 512×512 image): ~50-100ms on GPU
This code is released under the MIT License, allowing free use, modification, and distribution for both academic and commercial purposes with proper attribution.
If you use this code in your research, please cite:
Pan, Z., Song, N., Cheng, S., et al. A Joint Denoising and Segmentation Framework
for Ovarian Cancer Diagnosis based on Two-Photon Autofluorescence Microscopy.
Nature Communications (2024).
For questions regarding the code implementation:
- Corresponding Author: [Author Name]
- Email: [Contact Email]
- Issues: https://github.com/z-pan/AFN-DeSeg/issues