Icon

01_​Classifiying_​Cats_​and_​Dogs_​Training - km

Classifying Images of Cats and Dogs - Training

This workflow reads images of cats and dogs, performs some simple preprocessing, and trains and evaluates a Convolutional Neural Network (CNN) that is able to distinguish cat images from dog images.

If you use this workflow, please cite:
F. Villaroel Ordenes & R. Silipo, “Machine learning for marketing on the KNIME Hub: The development of a live repository for marketing applications”, Journal of Business Research 137(1):393-410, DOI: 10.1016/j.jbusres.2021.08.036.

2. Read and preprocess images: This workflow part reads the images of cats and dogs, encodes the two classes (cats = 1 and dogs = 0), andperforms some image preprocessing -- e.g., normalization of the images to be represented with values between 0 and 1 (Image Calculator),resizing the images to a fixed size (Image Resizer node). 1. Define network architecture: The Keras Layer nodes define a CNN for a binary image classification task. You can add more convolutionallayers to improve the performance. 3. Train, execute, and evalutate network: The Keras Network Learner nodes train the Keras network. In theconfiguration window you can define the loss functions and the training parameters. The Learning Monitor view of thenode shows the performance improvement during training. The Conda Environment Propagation node ensures the existence of a Conda environment with all packages. Anotheroption is to setup your Python integration to use a Conda environment with all packages as described here: https://docs.knime.com/2019-06/deep_learning_installation_guide/index.html#dl_python_setup IMPORTANT!To execute the workflow you need todownload the training dataset fromKaggle and update the path in the ListFiles / Folders Node inside thismetanode. The path should point to theunzipped folder including the images.https://www.kaggle.com/c/dogs-vs-cats/data Classifying Images of Cats and Dogs - TrainingThis workflow reads images of cats and dogs, performs some image preprocessing, and trains and evaluates a Convolutional Neural Network (CNN) for image classification. shape: 150, 150, 3filters: 32kernel size: 3x3activation: ReLUpool size: 2x2units: 64kernel size: 3x3activation: ReLUpool size: 2x2units: 64activation: ReLUdropout: 0.5units: 1activation: sigmoidTrain the model for 10 epochs (Adam) withloss function binary crossentropyApply the modelon new dataoutput >= 0.5 Catoutput < 0.5 DogEvaluate the modelAccuracy (73%)Resize to 150x150Path to training imagesNormalize between 0..1Read imagesRemove superfluous columnsSave modelSet up condaenvironmentEncode classeswith 0 and 1Keras Input Layer Keras Convolution2D Layer Keras Max Pooling2D Layer Keras Convolution2D Layer Keras Max Pooling2D Layer Keras Flatten Layer Keras Dense Layer Keras Dropout Layer Keras Dense Layer Keras NetworkLearner Keras NetworkExecutor Rule Engine Scorer Image Resizer Paths to images Image Calculator Image Reader(Table) Column Filter Partitioning Keras NetworkWriter Conda EnvironmentPropagation Rule Engine 2. Read and preprocess images: This workflow part reads the images of cats and dogs, encodes the two classes (cats = 1 and dogs = 0), andperforms some image preprocessing -- e.g., normalization of the images to be represented with values between 0 and 1 (Image Calculator),resizing the images to a fixed size (Image Resizer node). 1. Define network architecture: The Keras Layer nodes define a CNN for a binary image classification task. You can add more convolutionallayers to improve the performance. 3. Train, execute, and evalutate network: The Keras Network Learner nodes train the Keras network. In theconfiguration window you can define the loss functions and the training parameters. The Learning Monitor view of thenode shows the performance improvement during training. The Conda Environment Propagation node ensures the existence of a Conda environment with all packages. Anotheroption is to setup your Python integration to use a Conda environment with all packages as described here: https://docs.knime.com/2019-06/deep_learning_installation_guide/index.html#dl_python_setup IMPORTANT!To execute the workflow you need todownload the training dataset fromKaggle and update the path in the ListFiles / Folders Node inside thismetanode. The path should point to theunzipped folder including the images.https://www.kaggle.com/c/dogs-vs-cats/data Classifying Images of Cats and Dogs - TrainingThis workflow reads images of cats and dogs, performs some image preprocessing, and trains and evaluates a Convolutional Neural Network (CNN) for image classification. shape: 150, 150, 3filters: 32kernel size: 3x3activation: ReLUpool size: 2x2units: 64kernel size: 3x3activation: ReLUpool size: 2x2units: 64activation: ReLUdropout: 0.5units: 1activation: sigmoidTrain the model for 10 epochs (Adam) withloss function binary crossentropyApply the modelon new dataoutput >= 0.5 Catoutput < 0.5 DogEvaluate the modelAccuracy (73%)Resize to 150x150Path to training imagesNormalize between 0..1Read imagesRemove superfluous columnsSave modelSet up condaenvironmentEncode classeswith 0 and 1Keras Input Layer Keras Convolution2D Layer Keras Max Pooling2D Layer Keras Convolution2D Layer Keras Max Pooling2D Layer Keras Flatten Layer Keras Dense Layer Keras Dropout Layer Keras Dense Layer Keras NetworkLearner Keras NetworkExecutor Rule Engine Scorer Image Resizer Paths to images Image Calculator Image Reader(Table) Column Filter Partitioning Keras NetworkWriter Conda EnvironmentPropagation Rule Engine

Nodes

Extensions

Links