ITK pipeline using provided tensorflow .pd model.
Heavily based on Neargye/hello_tf_c_api
Feel free to contact me if you need new itkTensorFlow features, for example multiple inputs/outputs.
System | Badge |
---|---|
OSX/Linux build - Travis | |
Windows build - AppVeyor | |
Downloads |
You can download the library and the executable from here. Options available for the executable execution:
>> itkTensorFlowExe -h
Use: itkTensorFlowExe
-r inputRgbFilePath
-g inputGrayFilePaths, can be used multiple times
-m inputGraphPath tensor flow model/graph (in .pb format)
-o outputDirPath
-s scale (multiply output values by this value)
-h help
If you want to use one rgb image (Windows command line):
itkTensorFlowExe.exe -r "image2.jpg" -m "path/to/model.pb" -o "output"
OSX/Linux command line:
./itkTensorFlowExe -r "image2.jpg" -m "path/to/model.pb" -o "output"
If you want to use one or more grayscale images (Windows command line):
itkTensorFlowExe.exe ^
-g "image0.dcm" ^
-g "image1.dcm" ^
-g "image2.dcm" ^
-m "path/to/model.pb" ^
-o "output"
OSX/Linux command line:
./itkTensorFlowExe \
-g "image0.dcm" \
-g "image1.dcm" \
-g "image2.dcm" \
-m "path/to/model.pb" \
-o "output"
You can find examples of using executable here: https://github.com/MRKonrad/itkTensorFlow/tree/master/scripts
OSX/Linux
git clone https://github.com/MRKonrad/itkTensorFlow.git
cd itkTensorflow
git submodule update --init --recursive
cmake . -Bbin -DITK_DIR_HINTS="../ITK_install"
cmake --build bin
Windows
git clone https://github.com/MRKonrad/itkTensorFlow.git
cd itkTensorflow
git submodule update --init --recursive
cmake . -Bbin -G"Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=install -DITK_DIR_HINTS="../ITK_install"
cmake --build bin --config RELSEASE --target INSTALL
The sample model used in tests can be found in a nice jupyter notebook:
https://colab.research.google.com/github/tensorflow/models/blob/master/research/deeplab/deeplab_demo.ipynb
In this notebook, to get the image indexing right, I was playing with rotated image:
http://mrkonrad.github.io/MRKonrad/files/cnnRotatedImage/image2_90.jpg
http://mrkonrad.github.io/MRKonrad/files/cnnRotatedImage/image2_180.jpg
http://mrkonrad.github.io/MRKonrad/files/cnnRotatedImage/image2_270.jpg
- missing
msvcp140.dll
Download https://www.microsoft.com/en-us/download/details.aspx?id=48145 as suggested in https://stackoverflow.com/questions/32998902/msvcp140-dll-missing - how to generate
.pb
(tensorflow) file from.h5
(keras)
https://stackoverflow.com/questions/45466020/how-to-export-keras-h5-to-tensorflow-pb
https://github.com/amir-abdi/keras_to_tensorflow
python keras_to_tensorflow.py
--input_model="path/to/keras/model.h5"
--output_model="path/to/save/model.pb"
- How to see model in a
tensorboard
python ~/Code/tensorflow/tensorflow/python/tools/import_pb_to_tensorboard.py --model_dir tests/testData/model.pb --log_dir tests/testData/log
tensorboard --logdir tests/testData/log
- remove dependency to hello_tf_c_api
- make it work with 32bit windows. I have unsuccessfully tried to:
- compile tensorflow myself: https://github.com/MRKonrad/tensorflowBuild
- use playertwo compiled tensorflow 1.6: https://github.com/MRKonrad/build-tensorflow
- possibly I could start with playertwo solution from scratch and see where it goes
These are the ways to provide n 2d input images:
- itkImage with third dimension as the n-th image
Pro: can be defined in the runtime
Con: breaches the logic behind itk image - itkImage with n-dim vector type
Pro: makes sense with itk logic
Con: have to be defined at the compile time
PixelType = itk::Vector< float, n >; // n has to be static, cannot be defined in the runtime
ImageType = itk::Image< PixelType, 2 >;
- n inputs to a itkImageFilter class
Pro: makes sense with itk logic
Con: number of itkImageFilter have to be defined in a constructor. itkImageFilter constructor does not accept arguments. Hence the n has to be defined in the compile time
Partial solution: allow big number of inputs
In this project I went with the first option.
I am trying to follow the convetional commits guide: