This is a Convolutional Neural Network (CNN) model developed for educational purposes using TensorFlow and Keras to create, train, and evaluate deep neural networks. The model is designed to classify images of cats and dogs, leveraging a dataset provided by TensorFlow.
The dataset consists of 2000 images of cats and dogs for training and 1000 images for validation, organized into separate directories for each purpose. Before training, the images are resized to 160x160 pixels. Color values in the images are normalized to a range between 0 and 1.
You can see more about the dataset by clicking here.
Or just download it here.
The CNN model consists of several layers:
- Rescaling Layer: Rescales the input images to the desired size.
- Convolutional Layers: Convolutional layers with ReLU activation functions to introduce non-linearity.
- MaxPooling Layers: Downsamples the feature maps generated by the convolutional layers.
- Flatten Layer: Flattens the output of the convolutional layers into a 1-dimensional array.
- Dense Layers: Fully connected layers with ReLU activation functions.
- Output Layer: A single node with a sigmoid activation function for binary classification (0 for cat, 1 for dog).
The model is trained using the Adam optimizer with binary cross-entropy loss. Training occurs over 20 epochs with a batch size of 32.
To use the model, you can either download the model and load it in your code using the following command:
model = tf.keras.models.load_model('path/to/model')Alternatively, you can create a copy of the ImageClassification.ipynb notebook and run/manipulate the entire code (including training).
After training, the model's performance can be evaluated by visualizing predictions on a test dataset. The plot_dataset_predictions function generates a visualization of 9 predictions as images, comparing them with their ground truth labels.
This model is still under development. The next steps involve evaluating the quality of the generated model by applying metrics to our validation dataset. After analyzing the performance and accuracy of the model training, I will need to address any related issues found. For example, to find a way to prevent overfitting.
Additionally, I plan to apply transfer learning to this model, leveraging pre-trained models in TensorFlow for similar training tasks.
- TensorFlow
- Matplotlib