This project involves training a Convolutional Neural Network (CNN) to classify images of different car models. The main steps in this process include data preprocessing, model creation, training, and evaluation.
- Data Augmentation: To increase the diversity of the training data and prevent overfitting, the project uses
ImageDataGenerator
to apply random transformations such as rescaling, rotation, and horizontal flipping. - Data Loading: The car image dataset is loaded into TensorFlow's dataset objects using
flow_from_directory
, which automatically labels the images based on their directory structure. The dataset is split into training and testing sets, with images resized to 128x128 pixels.
- CNN Architecture: A Sequential model is created with several layers:
- Convolutional Layers: These layers apply convolution operations to extract features from the images.
- Max Pooling Layers: These layers reduce the spatial dimensions of the feature maps.
- Flatten Layer: This layer flattens the 3D feature maps into 1D feature vectors.
- Dense Layers: These fully connected layers perform classification based on the extracted features.
- Dropout Layer: This layer helps prevent overfitting by randomly setting a fraction of input units to 0 during training.
- The model is compiled using the Adam optimizer and the Sparse Categorical Crossentropy loss function. Accuracy is used as the evaluation metric.
- The model is trained for 50 epochs using the training data, with validation performed on the testing data at the end of each epoch.
- After training, the model's performance is evaluated using the test dataset to determine its accuracy and loss.
- The trained model can then be used to predict the classes of new, unseen car images.
This project demonstrates the practical application of deep learning techniques for image classification tasks, specifically focusing on distinguishing between various car models. The use of data augmentation and a well-designed CNN architecture are key to achieving good performance.