How digitalpathologybern/hover_next_inference works
Project type and purpose
• This is a Python‐based, command‐line inference pipeline (not a web app) for nuclei segmentation and classification in whole‐slide and image files (JPEG/PNG/NPY/ZARR).
• It’s organized as an open‐source tool, with a single “main.py” entry point driving a modular, multi‐stage processing pipeline.
File structure
Top‐level:
• main.py – CLI launcher that parses arguments (input path, model checkpoint, TTA, workers, tiling, etc.)
• environment.yml, requirements.txt, setup.py – Conda/Pip environment definitions, packaging info
• sample_analysis.ipynb – downstream‐analysis example using pipeline outputs
• .github/workflows/build.yml – CI for building/testing
• LICENSE, README.md
src/ (core pipeline modules):
• data_utils.py – implements data loaders for WSI (OpenSlide), image, NPY, custom datatypes
• spatial_augmenter.py, augmentations.py – test‐time augmentation (TTA) and other transforms
• multi_head_unet.py – defines the segmentation/classification model architecture (U-Net variant)
• inference.py – orchestrates batched/TTA inference on patches, manages GPU workers
• post_process.py, post_process_utils.py – merges tile predictions, instance‐map generation, class lookup table, export TSVs
• viz_utils.py – visualization helpers for debugging or output previews
• constants.py – shared config values (tile sizes, class labels, etc.)
Key README insights
• Supports auto‐download of pretrained weights from Zenodo
• CLI flags split pre-processing (tiling), inference (GPU), post-processing (CPU/multi-machine)
• Slurm support via “--only_inference” for GPU utilization
• Docker/Singularity container instructions