Icon

Building CNN Predictor for cats and dogs images - Exercise

Classifying Images of Cats and Dogs - Training (Exercise)
Annotations and comments
  • Exercise - Classifying Images of Cats and Dogs - Training Improve the performance of the simple CNN for image classification. Play around with hyperparameter optimization and/or the network architecture.
  • 1. Define network architecture: The Keras Layer nodes define a CNN for a binary image classification task.
  • 3. Train, execute, and evalutate network: The Keras Network Learner nodes train the Keras network. In the configuration window you can define the loss functions and the training parameters. The Learning Monitor view of the node shows the performance improvement during training. The Conda Environment Propagation node ensures the existence of a Conda environment with all packages. Another option is to setup your Python integration to use a Conda environment with all packages as described here: https://docs.knime.com/2021-12/deep_learning_installation_guide/index.html#dl_python_setup
  • 2. Read and preprocess images: This workflow part reads the images of cats and dogs, encodes the two classes (cats = 1 and dogs = 0), and performs 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).
  • IMPORTANT! To execute the workflow you need to download the training dataset from Kaggle and update the path in the List Files / Folders Node inside this metanode. The path should point to the unzipped folder including the images. https://www.kaggle.com/c/dogs-vs-cats/data
  • Remove superfluous columns
  • Set up conda environment
  • Normalize between 0..1
  • Read images
  • Resize to 150x150
  • shape: 150, 150, 3
  • Apply the model on new data
  • Train the model for 10 epochs (Adam) with loss function binary cross entropy
  • Save model
  • Select folder with with images
  • We only work with 4000 randomly selected images. You can adjust the number as desired.
  • First 12500 rows are cats, remaining rows are dogs
  • Sort by path name.
  • output >= 0.5 Cat output < 0.5 Dog
  • Encode classes with 0 and 1
  • Evaluate the model

Nodes

Extensions

Links