Windows 10 Installation Guide, by God Bennett.
Firstly, thanks to the author for the hard work on DeepBrainSeg!
Albeit, the DeepBrainSeg Library does not facilitate straight-forward Windows 10 installation. The example images in the original repository are Mac based screens/frames, and the code in the original repository also has Mac based programming comments, like "/usr/bin/env python", which seems to indicate that Mac was used for development of this product.
That said, here is a Windows 10 Guide, by myself. If anyone faces any issues, let me know. (For those curious why God Bennett is commenting from Jordan's profile, I legally changed my name from Jordan to God).
Figure_0: DeepBrainSeg starting up on Windows 10.
Figure_1: DeepBrainSeg used to get brain segmentation on Windows 10. (Note: Ensemble segmentation/inference takes ~2 hours via torch_cpu, on my i7 6700 intel cpu. Torch cuda/gpu on the other hand, is much faster, with ensemble segmentation/inference taking only ~10 minutes, on my gtx 1060 3gb)
-
Don't run DeepBrainSeg setup.py , until step 10. It matters not if you had already ran it, still proceed if you had already done so.
-
Install Python 3.5.4 64 bit. You will notice below that everything going forward is 64 bit based!
- Failure to do the above will result in python 3.5 base version related torch error, and python 3.6 will yield DeepBrainSeg related deepSeg import error! Not to mention, anaconda cloud has no distribution of pydensecrf for python3.7, and I will mention why anaconda cloud is relevant below. Stay with python 3.5 as advised by author.
- Install pydensecrf (by simply manually copying "Lib/site packages" folder to "Lib/site packages" in Python35 installation directory), particularly "win-64/pydensecrf-1.0rc2" (crucially, from the anaconda cloud location).
- Failure to do the above will result in pydensecrf related build errors, in conjunction with c++ dependencies, if pip is used instead of the manual process above.
- Install pyradiomics (by simply manually copying "Lib/site packages" and "Scripts" folders to "Lib/site packages" and "Scripts" in Python35 installation directory) "win-64/pyradiomics-2.1.0-py35_0.tar" (crucially from the anaconda cloud location, because build errors come from attempt using pip)
- Failure to do the above will result in pydensecrf related build errors, in conjunction with c++ dependencies, if pip is used instead of the manual process above.
-
Install visual studio build tools.
-
Install in particular, torch 1.2.0 from the location below, using the command below given python35 path is set:
Cpu enabled option:
python -m pip install https://download.pytorch.org/whl/cpu/torch-1.2.0%2Bcpu-cp35-cp35m-win_amd64.whl
- Install (by simply manually copying "Lib/site packages" folder to "Lib/site packages" in Python35 installation directory), in particular, torchvision 0.4.0 , "win-64/torchvision-0.4.0-py35_cpu" (crucially, from page 4 of the anaconda cloud location).
- Failure to do the above will result in pydensecrf related build errors, in conjunction with c++ dependencies, if pip is used instead of the manual process above.
- It is crucial that the items in (6) and (7) are installed above, no other version, unless you verify that any other versions of torch and torchvision you install match.
- Failure to do the above will result in import issues, including "Optional" error seen below:
- Gpu accelerated alternatives to (6) and (7) (Note: Cuda 9.2 (1.5gb) install is required for below):
pip install torch==1.2.0+cu92 torchvision==0.4.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html
With the gpu option above, segmentation takes ~10 minutes, instead of ~2 hours required when using cpu options in (6) and (7).
- Test your torch, torchvision, and pydensecrf installations below:
import torch
import torchvision
import pydensecrf
import pydensecrf.densecrf #The above "import pydensecrf.densecrf " test may fail even if the one above succeeds! As advised in (8) torch and torchvision must match. If a "variable_length" issue error pops up, this means that numpy requires updating to the latest version. Typical pip works.
- Finally run DeepBrainSeg setup.py. Install any other missing thing if applicable, using typical python pip.
You should see DeepBrainSeg installation being resolved below:
- If no errors happen in the test, then it's time to launch the DeepBrainSeg user interface on Windows 10:
python DeepBrainSegUI.py #as advised on the main repository or simply run the python file from IDLE35.
The result should be similar to what you see in the first and second images of this readme.
- The trained models are automatically downloaded to "~/.DeepBrainSeg" (or home on mac), but automatically downloaded to "C:\Users<YourUserName>.DeepBrainSeg" on Windows!
- Ants mask generator, which needs to be used to generate a mask file for inference/real time test, is located in "DeepBrainSeg-master/DeepBrainSeg/brainmask/antsmask.py"
- Crucially, follow these guidelines to install ANTS on Windows. Change the "/opt/ANTS/bin" directory in "DeepBrainSeg-master/DeepBrainSeg/brainmask/antsmask.py" to point to wherever you installed ANTS.
- Sample non-graphical ui based segmentation sample located in "DeepBrainSeg-master/examples/tumorsegmentation.py", which reads a sample from "DeepBrainSeg-master_/sample_volume/brats".