Optimizing BrainSec
Source code on GitHub.
Figure 1: End-to-End Whole-Slide-Image (WSI) Segmentation Pipeline using SegFormer
bash
conda env create -f configs/server_env.yml -n brainsec2
conda activate brainsec2
`Step 2 — Download Models
Model weights are large and hosted externally on Google Drive at: https://drive.google.com/drive/folders/1NbLP4E-m5RhgTmHj4mcee1ZR6OcevJIm?usp=sharingMore public WSI data available at:
https://zenodo.org/records/1470797 (.svs)
https://datadryad.org/dataset/doi:10.5061/dryad.7h44j107j (.czi) `bash
mkdir -p models
unzip ~/Downloads/model.zip -d models/
`Step 3 — Run Inference
GPU Inference (≈ 3 min on NVIDIA GPU)
`bash
python src/inference/inference_main.py
--model-type pretrained
--model-dir models/segformer_pretrained
--wsi-path data/sample.svs
--output output.png
--batch-size 8
`CPU Inference with ONNX (≈ 15 min on M-series)
`bash
python src/onnxformatting/inference_onnx.py
--onnx-model models/segformer_lora.onnx
--wsi-path data/sample.svs
--output output_onnx.png
--executor-provider CPUExecutionProvider
`Fine Tuning
Finetune the base segformer model using a strategy
`bash
python src/inference/inference_main.py
--model-type lora
--model-dir models/ft_models/finetuned_lora
--base-model-dir models/segformer_pretrained
--wsi-path data/sample.svs
``...