- Python 57.9%
- Jupyter Notebook 42.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| checkpoints_v4_interactive | ||
| src | ||
| .gitattributes | ||
| .gitignore | ||
| README.md | ||
| train_and_inference.ipynb | ||
ConvNeXT-UNet Code
This repository contains the training and inference pipeline used for our segmentation paper. It features a UNet with a ConvNeXt backbone for multi-class image segmentation of tomography datasets.
Repository Structure
train_and_inference.ipynb: The main interactive Jupyter Notebook used for defining the configurations, loading models/data, and running training or inference tasks.src/: A module containing core scripts:models.py: Defines the UNet ConvNeXt architecture.dataset.py: Handles loading the image/mask datasets and applying necessary preprocessing and augmentations.loss.py: Implements custom loss functions (e.g., Median Frequency Balanced BCE).train.py/train_ddp.py: Main scripts for training loops (including Distributed Data Parallel).
checkpoints_v4_interactive/: Directory containing pre-trained model checkpoints (managed via Git LFS).
Installation and Requirements
-
Clone the Repository
git clone https://github.com/pradyumnae/convnext-unet-segmentation.git cd convnext-unet-segmentationNote: Since the model weights are stored via Git LFS, ensure you have Git LFS installed before cloning, or run
git lfs pullafterward. -
Python Environment Setup We recommend using Conda or a Python virtual environment.
conda create -n seg-env python=3.12 conda activate seg-env -
Install Dependencies The project primarily relies on PyTorch, NumPy, Pillow, tifffile, and Matplotlib.
pip install torch torchvision numpy Pillow tifffile matplotlib tqdm
Usage
Interactive Training and Inference
Open the train_and_inference.ipynb notebook in Jupyter:
jupyter notebook train_and_inference.ipynb
Follow the cells sequentially to configure the data path (DATA_DIR), load the unet_convnext model, and either run a training loop or perform inference using the provided checkpoint checkpoints_v4_interactive/unet_convnext_v4.pth.
Output Masks
When running the inference pipeline, the code exports multi-class masks as both .png and .tiff files to the output directory defined in the notebook.
Citation
If you use this code in your research, please cite our corresponding paper:
@misc{elavarthi2026reconstructioninterpretationzerosetupmultiphase,
title={From Reconstruction to Interpretation: Zero-Setup Multi-Phase Segmentation of X-ray Tomography Data},
author={Pradyumna Elavarthi and Arun J. Bhattacharjee and Harrison Lisabeth and Anca Ralescu and Petrus H. Zwart and Dilworth Parkinson and Elizabeth G. Clark},
year={2026},
eprint={2607.12175},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2607.12175},
}