Icon

DL-PredictClassBinary-h5Model

DL-PredictClassBinary-h5Model
This workflow allows predicting image-categories for new images using a pretrained deep-learning model.You will need : - a pretrained model saved as a h5 file (to set in the Keras Network reader node highlighted in green)- a text file with the categories names (txt, to set in the File reader node, highlighted in green)Both files have been created by the training workflow.If you did not keep the text file, no panic, you can recreate it manually.It only contains the name of the categories, with one category per line.The lines in the text files are ordered by alphabetical order of the categories. # Input imagesThe workflow above is demonstrated for grayscale images but it can adapted for RGB images (remove the Gray to RGB node).The workflow takes care of the pre-processing (downscalling and intensity normalisation).USE THE SAME SETTINGS THAN WITH THE TRAINING IMAGES, especially for downscalling, by default images are downscaled to 224 x 224 pixels# WorkflowThe model will predict an float value correspondign to the probability for the category of index 1 (see training workflow).The workflow then formats the output of the model to return the predicted category and associated probability.The predicted category and original image path can finally be saved to disk as a csv.# REQUIREMENTS- 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.The training will run on gpu automatically if the gpu version of keras and tensorflow are installed.- Python 3.6.10- Keras 2.2.4- TensorFlow 1.12.0 (not more otherwise the Keras trainer fails)- pandas 0.23.5 max (for KNIME) Read images to classify(Grayscale)Duplicate grayscaleto RGB channels Open Keras finetunednetwork (h5)Do the prediciton Read *model*_classes.txtView images and predictionsSave image path andclass predictionCategory namesandprobabilitiesResize (right click to set size)default 224x224Normalize intensity to [0,1] remove images Image Reader Gray to RGB Keras NetworkReader Keras NetworkExecutor File Reader Image Viewer CSV Writer Format output ImagePre-Processing Format beforesaving This workflow allows predicting image-categories for new images using a pretrained deep-learning model.You will need : - a pretrained model saved as a h5 file (to set in the Keras Network reader node highlighted in green)- a text file with the categories names (txt, to set in the File reader node, highlighted in green)Both files have been created by the training workflow.If you did not keep the text file, no panic, you can recreate it manually.It only contains the name of the categories, with one category per line.The lines in the text files are ordered by alphabetical order of the categories. # Input imagesThe workflow above is demonstrated for grayscale images but it can adapted for RGB images (remove the Gray to RGB node).The workflow takes care of the pre-processing (downscalling and intensity normalisation).USE THE SAME SETTINGS THAN WITH THE TRAINING IMAGES, especially for downscalling, by default images are downscaled to 224 x 224 pixels# WorkflowThe model will predict an float value correspondign to the probability for the category of index 1 (see training workflow).The workflow then formats the output of the model to return the predicted category and associated probability.The predicted category and original image path can finally be saved to disk as a csv.# REQUIREMENTS- 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.The training will run on gpu automatically if the gpu version of keras and tensorflow are installed.- Python 3.6.10- Keras 2.2.4- TensorFlow 1.12.0 (not more otherwise the Keras trainer fails)- pandas 0.23.5 max (for KNIME) Read images to classify(Grayscale)Duplicate grayscaleto RGB channels Open Keras finetunednetwork (h5)Do the prediciton Read *model*_classes.txtView images and predictionsSave image path andclass predictionCategory namesandprobabilitiesResize (right click to set size)default 224x224Normalize intensity to [0,1] remove imagesImage Reader Gray to RGB Keras NetworkReader Keras NetworkExecutor File Reader Image Viewer CSV Writer Format output ImagePre-Processing Format beforesaving

Nodes

Extensions

Links