Python problems

SliceOmatic and Python
Python The SliceOmatic AI mode use the Python language to work.

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.

Installing Python with Anaconda
Anaconda There are many ways to insatll Python on Windows. The easiest one is through the free tool Anaconda. So, install Anaconda from this link

But, this is just the first part of our Python install. Now we need to add the Python libraries that sliceOmatic will need.

Also, the current versin of sliceOmatic is compiled with version 3.9 of Python, so you need to install Python version 3.9.

You now need to start the "Anaconda Prompt". From the Windows "Start" menu, expand the Anacoda folder and select the "Anaconda Prompt".
Anaconda Prompt

At the prompt type in "pip install numpy==1.22.4" and press "Enter" to install the NumPy library.

Note: I am having some problems with the latest versions of Numpy, this is why I suggest 1.22.4.
Anaconda install Numpy

Again, at the prompt type in "pip install tensorflow" to install the tensorflow library.

Note: If you are having problems with versions, I tested the program with 2.9.1.
Anaconda install Tensorflow

And again, at the prompt type in "pip install keras" to install the keras library.

Note: If you are having problems with versions, I tested the program with Keras 2.9.0.
Anaconda install Keras

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 I had a lot of troubles using "Conda" with the Tensorflow package... This is why I suggest you use "pip" instead. But I am not a Python expert, so, if you know what you are doing, use the technique you prefer.

Copying the pythonxx.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 pythonxx.dll.
Fail to load DLLs

It could probably be fixed working on the "PATH" system variable, but I'm lazy, so I fixed it on my system by simply copying the DLL from the Python installation directory (with Anaconda: "user/your_name/anaconda3") to the sliceOmatic installation directory (by default: "C:\Program Files\TomoVision").

The current version of sliceO is compiled with Python 3.9, so 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 pythonxx.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 "user/your_name/anaconda3".

The location of the Python installation is specified in the "AI" tab of the "File/Config" interface.
Python path

If the wrong directory is specified, you will get this warning pop-up:
Install path error

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.

Installing CUDA (card, toolkit and libraries)
CUDA Ah, yes, before I forget, if you plan to train your own AI, you may want to have a powerfull Cuda graphic card along with the CUDA toolkit and the cuDNN library installed in your computer.

Please note that you do not need a CUDA card, 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 16ms, 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.

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

to Top