Icon

Train-VGG16-nClasses

DL-VGG16-MultiClassification
This workflow trains a multi-class image-classifier for single-channel grayscale images, provided a classification table as generated by the multi-class (button) plugin in Fiji from the"Qualitative Annotations" update site, with one column per category and 1 for belong to category and 0 for not in the category.Each image should be assigned to a single category (1-hot encoding).The images should be single channel grayscale images, of any bit type and size, but the workflow can be adapted to RGB images (remove the RGB conversion node).To run the workflow, first edit the nodes in green:- set the columns containing the directory and filename (get image path node)- select the columns (select feature columns node)- downsizing dimensions (optional, Image pre-processing node)- after executing the first nodes, you can also edit the training parameters in the keras network learner node, in the option panelThe workflow will open the images and perform pre-processing :- downscaling (size to define by right clicking the preprocessing node)- intensity normlisation to range 0-1- conversion to pseudo-RGB by duplicating the Gray channelThen the workflow will download a pretrained model base (VGG16) and add fresh dense layers (ie fully connected) for classification with custom classes.The VGG16 base is frozen, only the new classification layers are trained.It will then go on with the training. Settings for the training can be accessed in the Keras Network learner node.The plot of accuracy and loss can be observed over the execution of the training (and after execution too).Once the training completed, the network can be saved, tested on a test set or further trained by also training the core convolutional layers in a second training node. (not done)# Example datasetThis workflow can be tested with the example dataset uploaded on Zenodo (Annotations-multiClass.csv)http://doi.org/10.5281/zenodo.3997728Requirements:# KNIMEOn the KNIME side, the extensions are installed automatically, with the exception of- Knime Image Processing - Deep Learning Extension Install via File > Install KNIME Extension or directly via https://hub.knime.com/BioML-Konstanz/extensions/org.knime.knip.dl.feature/latest# PythonThe best is to let KNIME install a pre-configured environement, since updating an existing environment with tensorflow usually fails.To do so, go to File > Preferences > Knime > Python Deep Learning and select create a new environment.The environment creation takes a while, so be patient.- Python 3.6.10 or 3.6.9- Keras 2.2.4- TensorFlow 1.12.0 (not more otherwise the Keras trainer fails)- pandas 0.23.5 max (for KNIME) TESTING TRAINING Duplicate grayscaleto RGB channels Train new last layersRight click to set nEpochs, Batch size...DONT CHANGE INPUT OR TARGETAfter/During execution view accuracy/lossGet VGG16 base (frozen)+ add new dense layers for classifView CNN input TRAINING/VALIDATION SETRight click to set pathInteractive view to see count of images for each classExecute on test setoutput column named PredictionOpen imagesSave trained model as h5save class names as txtTop: TrainingMiddle : ValidationBottom: TestingRight-click > Interactive viewto see partitioningView imagesand predictionsGet predicted classand probability Resize (right click to set size)default 224x224Normalize intensity to [0,1] Ground truth columns as collectionView confiusion matrixandmetrics Right-clic to select columns Right clickand select integercolumns to use as features Gray to RGB Keras NetworkLearner Model Image Viewer Read classificationtable Keras NetworkExecutor Image Reader(Table) Export model Split dataset Image Viewer Format output ImagePre-Processing Create CollectionColumn Scorer (JavaScript) Get image path Select featurecolumns This workflow trains a multi-class image-classifier for single-channel grayscale images, provided a classification table as generated by the multi-class (button) plugin in Fiji from the"Qualitative Annotations" update site, with one column per category and 1 for belong to category and 0 for not in the category.Each image should be assigned to a single category (1-hot encoding).The images should be single channel grayscale images, of any bit type and size, but the workflow can be adapted to RGB images (remove the RGB conversion node).To run the workflow, first edit the nodes in green:- set the columns containing the directory and filename (get image path node)- select the columns (select feature columns node)- downsizing dimensions (optional, Image pre-processing node)- after executing the first nodes, you can also edit the training parameters in the keras network learner node, in the option panelThe workflow will open the images and perform pre-processing :- downscaling (size to define by right clicking the preprocessing node)- intensity normlisation to range 0-1- conversion to pseudo-RGB by duplicating the Gray channelThen the workflow will download a pretrained model base (VGG16) and add fresh dense layers (ie fully connected) for classification with custom classes.The VGG16 base is frozen, only the new classification layers are trained.It will then go on with the training. Settings for the training can be accessed in the Keras Network learner node.The plot of accuracy and loss can be observed over the execution of the training (and after execution too).Once the training completed, the network can be saved, tested on a test set or further trained by also training the core convolutional layers in a second training node. (not done)# Example datasetThis workflow can be tested with the example dataset uploaded on Zenodo (Annotations-multiClass.csv)http://doi.org/10.5281/zenodo.3997728Requirements:# KNIMEOn the KNIME side, the extensions are installed automatically, with the exception of- Knime Image Processing - Deep Learning Extension Install via File > Install KNIME Extension or directly via https://hub.knime.com/BioML-Konstanz/extensions/org.knime.knip.dl.feature/latest# PythonThe best is to let KNIME install a pre-configured environement, since updating an existing environment with tensorflow usually fails.To do so, go to File > Preferences > Knime > Python Deep Learning and select create a new environment.The environment creation takes a while, so be patient.- Python 3.6.10 or 3.6.9- Keras 2.2.4- TensorFlow 1.12.0 (not more otherwise the Keras trainer fails)- pandas 0.23.5 max (for KNIME) TESTING TRAINING Duplicate grayscaleto RGB channels Train new last layersRight click to set nEpochs, Batch size...DONT CHANGE INPUT OR TARGETAfter/During execution view accuracy/lossGet VGG16 base (frozen)+ add new dense layers for classifView CNN input TRAINING/VALIDATION SETRight click to set pathInteractive view to see count of images for each classExecute on test setoutput column named PredictionOpen imagesSave trained model as h5save class names as txtTop: TrainingMiddle : ValidationBottom: TestingRight-click > Interactive viewto see partitioningView imagesand predictionsGet predicted classand probability Resize (right click to set size)default 224x224Normalize intensity to [0,1] Ground truth columns as collectionView confiusion matrixandmetrics Right-clic to select columns Right clickand select integercolumns to use as features Gray to RGB Keras NetworkLearner Model Image Viewer Read classificationtable Keras NetworkExecutor Image Reader(Table) Export model Split dataset Image Viewer Format output ImagePre-Processing Create CollectionColumn Scorer (JavaScript) Get image path Select featurecolumns

Nodes

Extensions

Links