# SlicerNNUNet: run trained nnU-Net v2 segmentation models in 3D Slicer. Point it # at a model folder (or a published model), pick the input volume(s), and the # module runs nnUNetv2_predict in a separate process and loads the result as a # segmentation. # # PURE-SCRIPTED: nothing to compile. Upstream pip-installs nnunetv2 and PyTorch # (through the PyTorch extension); here they are RPMs (python3-nnunetv2, # python3-torch). Patch0 makes the module use them. %global commit b1ee4304c5db948d3be4db022d25e87a9572de80 %global shortcommit %(c=%{commit}; echo ${c:0:8}) %global snapdate 20261002 %global slicer_inst %{_prefix}/lib/slicer %global slicer_subdir Slicer-5.12 %global qtsm %{slicer_inst}/lib/%{slicer_subdir}/qt-scripted-modules Name: 3dslicer-nnunet Version: 0 Release: 0.1.%{snapdate}git%{shortcommit}%{?dist} Summary: nnU-Net v2 segmentation models in 3D Slicer (SlicerNNUNet) License: BSD-3-Clause URL: https://github.com/KitwareMedical/SlicerNNUnet Source0: %{url}/archive/%{commit}/SlicerNNUnet-%{shortcommit}.tar.gz # - SegmentationLogic._findUNetPredictPath(): also find nnUNetv2_predict on PATH. It # only looked in /../lib/Python/{Scripts,bin} (upstream's bundled # Python); the RPM's script is /usr/bin/nnUNetv2_predict, so every run failed with # "Failed to find nnUNet predict path." # - InstallLogic.setupPythonRequirements(): when the installed python3-nnunetv2 does # not satisfy the requested version, say so with a dnf hint; never pip-install # nnunetv2 or PyTorch (a user-site copy would sit behind the system packages). # - Process._report(): decode nnUNetv2_predict output with bytes.decode, not # qt.QTextCodec, which Qt6 removed: every output line and error was lost. Patch0: 3dslicer-nnunet-fedora-packages.patch BuildArch: noarch Requires: 3dslicer Requires: python3-nnunetv2 Requires: python3-torch Requires: python3-packaging # EXTENSION_DEPENDS PyTorch: InstallLogic imports PyTorchUtils. Requires: 3dslicer-pytorch %description SlicerNNUNet runs trained nnU-Net v2 segmentation models in 3D Slicer: select a model folder and the input volume(s), and the module runs nnUNetv2_predict in a separate process and loads the result as a segmentation. nnU-Net and PyTorch come from Fedora packages (python3-nnunetv2, python3-torch). Fedora's PyTorch has no CUDA support, so NVIDIA GPUs are not used; inference runs on the CPU, or on AMD GPUs through ROCm. %prep %autosetup -n SlicerNNUnet-%{commit} -p1 %build # Pure-scripted: nothing to compile. %install # Install what SlicerNNUnet/CMakeLists.txt lists, at the paths # slicerMacroBuildScriptedModule uses -- except Testing/*: the self tests need the # SlicerPythonTestRunner extension (not packaged), and a top-level "Testing" package # in the shared qt-scripted-modules directory would collide with other extensions. _dir=SlicerNNUnet; _mod=SlicerNNUNet; _n=0 for _f in $(sed -n '/^set(MODULE_PYTHON_\(SCRIPTS\|RESOURCES\)$/,/^ )$/p' $_dir/CMakeLists.txt \ | grep -vE '^set\(|^ \)$' | sed -e 's/^ *//' -e "s/\${MODULE_NAME}/$_mod/g" | grep -v '^Testing/'); do test -f "$_dir/$_f" || { echo "ERROR: $_mod lists $_f, which is missing" >&2; exit 1; } install -Dpm0644 "$_dir/$_f" "%{buildroot}%{qtsm}/$_f" _n=$((_n + 1)) done test "$_n" -eq 11 || { echo "ERROR: installed $_n $_mod files, expected 11" >&2; exit 1; } ( cd %{buildroot} && find . \( -type f -o -type l \) | sed 's|^\.||' ) > %{_builddir}/nnunet.files %files -f %{_builddir}/nnunet.files %license LICENSE %doc README.md %changelog * Sat Oct 10 2026 Morgan Hough - 0-0.1.20261002gitb1ee4304 - Initial package. SlicerNNUNet on python3-nnunetv2 / python3-torch (Patch0: find /usr/bin/nnUNetv2_predict; no pip install; nnU-Net output decoded without the Qt5-only QTextCodec).