-
Notifications
You must be signed in to change notification settings - Fork 12
PyTorch models
DeepImageJ can load Pytorch models making use of a third-party library called Deep Java Library (DJL), developed by the Amazon Web Services Team. Find detailed documentation of Pytorch DJL.
For the compatibility with Windows OS, DJL requires the installation of Visual Studio 2019 redistributable.
Internally, DJL is slightly different than the Tensorflow Java library, even though they both call the C++ code of either Pytorch or Tensorflow through a Java jni .jar executable.
Tensorflow Java works with tensors and DJL works with NDArrays, which try to mimic the Python Numpy arrays and overcome the difficulty of handling Java arrays.
As DJL makes use of the Python C++ API, the models have to be saved in TorchScript format. The latter does not add complexity to coding in Python as it only implies adding 2 extra lines of code.
The plugin is installed using version 1.7 of DJL which supports Pytorch 1.7. This Pytorch version should be backward compatible with the previous versions. However, the Pytorch version can be changed manually replacing the corresponding executable .jar files in the jars
folder. This process is similar to changing the Tensorflow Java library version manually.
Introduction:
User Guide:
Model Developers Guide: