How can I convert a 3D CNN model trained for Nifti images to 2d so that I can inference on 2D nifti slices?
You could either:
- create a “depth” dimension in your inputs and
repeat
the dataD
times to match the expected input to the original 3D model - try to reduce the parameters from the 3D model to 2D ones
For the 2nd approach: I don’t know which approach would work at all, but e.g. you could reuse the kernels from the nn.Conv3d
layers, apply a mean
(or sum
or slice) in the depth dimension of the kernel and load it into a newly created nn.Conv2d
layer.
Depending on the actual model architecture this model “surgery” might not be trivial so the 1st approach might be easier.