Sovereign 8s.is mirror of standardgalactic/convnext-unet-segmentation
  • Python 57.9%
  • Jupyter Notebook 42.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Pradyumna Elavarthi 557339ec54
Rename project to ConvNeXT-UNet Code
Updated the project title and description to reflect the new focus on ConvNeXT-UNet.
2026-07-17 13:14:10 -07:00
checkpoints_v4_interactive Update checkpoint naming and add README 2026-07-16 23:37:32 -07:00
src Add .gitignore and remove cache files 2026-07-16 23:29:51 -07:00
.gitattributes Initial commit for segmentation paper code 2026-07-16 23:29:44 -07:00
.gitignore Add .gitignore and remove cache files 2026-07-16 23:29:51 -07:00
README.md Rename project to ConvNeXT-UNet Code 2026-07-17 13:14:10 -07:00
train_and_inference.ipynb Fix redundant plot cells and uncomment training loop 2026-07-16 23:42:58 -07:00

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

  1. Clone the Repository

    git clone https://github.com/pradyumnae/convnext-unet-segmentation.git
    cd convnext-unet-segmentation
    

    Note: Since the model weights are stored via Git LFS, ensure you have Git LFS installed before cloning, or run git lfs pull afterward.

  2. Python Environment Setup We recommend using Conda or a Python virtual environment.

    conda create -n seg-env python=3.12
    conda activate seg-env
    
  3. 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}, 
}