gvtulder / elasticdeform

Differentiable elastic deformations for N-dimensional images (Python, SciPy, NumPy, TensorFlow, PyTorch).
Other
186 stars 25 forks source link

Tensorflow wrapper and GPU #6

Closed Chop1 closed 4 years ago

Chop1 commented 4 years ago

Does using the tensorflow wrapper allow the elasticdeform to be performed on GPU (while using tensorflow-gpu) ? I'm actually using your library in my data generator but its time consuming.

gvtulder commented 4 years ago

No, the elastic deformation is not performed on the GPU. It's based on the SciPy ndimage implementation, which doesn't have a GPU-optimized version.

There's also the question how useful it would be: in my own experiments, for example, I often saturate the GPU for the network training and can do the deformation on the CPU (in parallel) while the network is training. If data augmentation is not the bottleneck, moving it to the GPU would actually slow things down.

But I agree, the interpolation it's expensive. You might be able to make it slightly faster by choosing a lower interpolation order, but that probably won't make a huge difference.

There may be other libraries that do use the GPU. This one might work, but I haven't tried it myself: https://github.com/qsyao/cuda_spatial_deform

(Sorry for the late reply.)