SliceOmatic and Python

This means that you need to have Python (and some of the associated modules) installed.
This web page is designed to help you setup Python and the modules you will need to run the AI mode.
GPU acceleration

The cuDNN library need to be installed BEFORE you install the "Tensorflow" module in Python. If they are not present when installing Tensorflow, then Python will install a CPU version of the library instead of the GPU version.
Please note that you do not need GPU acceleration to use the AI modules. But it is the difference between waiting 2 days or 2 hours for the same training to complete... If you are just using the AI with the provided weights (and not doing your own training), then you can easily do without the CUDA card. With a CUDA card, segmenting a 512x512 CT image in the AI mode with pre-defined weights take about 20ms, without a CUDA card you need about 250ms.
CUDA is a programing language used to access the GPU of Nvidia graphic cards.
For the compatible graphic card look at this page: Windows, Cuda or VR problems. You will need a powerfull card with a lot of GPU memory. I would suggest something like the GeForce RTX3090.
Installing CUDA (card, toolkit and libraries)
After installing the card and its drivers, you also need to install both the "CUDA Toolkit for Windows" and the
"CUDA Deep Neural Network" (cuDNN) library.
All of these can be found on the Nvidia web site (you will need to fill in the "developer's" form first before you get the cuDNN library).
The step by step instruction for these installations can be found on the Nvidia web site. Follow this link: Windows install guide
All of these can be found on the Nvidia web site (you will need to fill in the "developer's" form first before you get the cuDNN library).
The step by step instruction for these installations can be found on the Nvidia web site. Follow this link: Windows install guide
Installing Python with Anaconda
![]() You can find the latest version 3.9 of Anaconda from this link: Anaconda archives/. It will be the file: "Anaconda3-2022.05-Windows-x86_64.exe". But, this is just the first part of our Python install. Now we need to add the Python libraries that sliceOmatic will need. You now need to start the "Anaconda Prompt". From the Windows "Start" menu, expand the Anacoda folder and select the "Anaconda Prompt". |
![]() |
At the prompt type in "pip install numpy==1.22.4" and press "Enter" to install the NumPy library. Note: The libraries linking NumPy to my program only seem to work if we use the same version, this is why you need 1.22.4. Note: If you do not have a CUDA card or the CUDA libraries on your system, the Python will install the CPU version of the NumPy libraries. So, if you have a CUDA compatible GPU, it is important to install CUDA before you install NumPy. |
![]() |
Again, at the prompt type in "pip install tensorflow==2.9.1" to install the tensorflow library. Note: Later versions may also work, but I wrote the program using 2.9.1, so why take any chances?. |
![]() |
And again, at the prompt type in "pip install keras==2.9.0" to install the keras library. Note: Later versions may also work, but I wrote the program using Keras 2.9.0. |
![]() |
The AI mode is designed to be modular and users can add new AI models as they want. If you use a user model you may also need an additional Python library. Running the "File/Python status" (in the "System" group) should warn you about any missing libraries. Use the same "pip install" instruction as before to add any missing libraries. Note: conda install /vs/ pip install. Some of you may prefer using "Conda" instead of "pip" to install packages in Python. However the tensorflow package is designed to be installed with pip. The offical TensorFlow web page ( www.tensorflow.org/install/pip) has this warning: Note: Do not install TensorFlow with conda. It may not have the latest stable version. pip is recommended since TensorFlow is only officially released to PyPI. |
Copying the python39.dll file
At this point we would think that Python has been installed and everything is fine... But, it is my experience that the Python paths do not seem to be installed correctly for us to run our Python modules in sliceO. If you start sliceO now and you get "Error: Failed to load dll!" for both the "Menu_Info_Python.dll" and "Mode_AI_Python.dll", this mean that the program could not reach the python39.dll. |
![]() |
It could probably be fixed working on the "PATH" system variable, but I'm lazy, so on my system I solved the problem by simply copying the DLL from the Python installation directory (with Anaconda: "C:\user\your_name\anaconda3 or C:\ProgramData\Anaconda3") to the sliceOmatic installation directory (by default: "C:\Program Files\TomoVision"). SliceOmatic use the version 3.9 of Python, the DLL you need is "python39.dll". |
Directory of the Python interpreter
When you start the AI module, it will need more than just the python39.dll file. It need to know where Python has been installed on your system. for example, if you are using Anaconda, this directory will be, depending on how you installed Anaconda, either: "C:\user/your_name/anaconda3" (installed just for you) or "C:\ProgramData\Anaconda3" (installed for all users). The location of the Python installation is specified in the "AI" tab of the "File/Config" interface. |
![]() |
If the wrong directory is specified, you will get this warning pop-up: |
![]() |
Please make sure that this path is set correctly. The specified directory should contain the original copy of the "pythonxx.dll" as well as the "DLLs" and "Lib" sub-directories of the Python installation. |