The objective of this project is to develop a model that can recognize diseases in chickens by analyzing images of their fecal matter. This task is vital for early disease detection and monitoring in poultry farms. In this report, we will discuss the data preprocessing, neural network architecture, and model evaluation.
The dataset is loaded from a CSV file, 'train_data.csv,' which contains information about images of chicken fecal matter and their associated disease labels. The dataset is initially explored to understand its structure.
Class imbalance is a common issue in classification tasks, and it was addressed in this project. To balance the dataset, the following steps were taken:
- Calculating class weights: Class weights were calculated based on the class frequencies to handle the imbalance.
- Creating a balanced dataset: A balanced dataset was generated by randomly selecting a fixed number of samples (in this case, 560) for each disease class. This balanced dataset ensures that the model is not biased towards any specific class.
To improve the model's generalization, data augmentation techniques were applied using the ImageDataGenerator
from Keras. This included rotations, shifts, shearing, zooming, and horizontal flips.
The dataset was split into training, validation, and test sets. The training dataset is further augmented, while the validation and test sets remain untouched.
A transfer learning approach was employed using the MobileNetV3Small pre-trained model, which was trained on the ImageNet dataset. MobileNetV3Small is known for its efficiency and effectiveness in computer vision tasks.
The neural network architecture consists of the following components:
- Base model: MobileNetV3Small with pre-trained weights. The model is used as a feature extractor.
- Batch Normalization: Applied to the output of the base model.
- Fully Connected Layers: Two dense layers with dropout regularization.
- Output Layer: A dense layer with softmax activation for multi-class classification.
The model was compiled using the Adamax optimizer with a learning rate of 0.001 and categorical cross-entropy loss. The chosen optimizer and loss function are suitable for this multi-class classification problem.
The model was trained for five epochs using the training dataset, and performance was evaluated on the validation dataset. The training process included early stopping, model checkpointing, and tensorboard callbacks for monitoring and saving the best model.
The model's performance was evaluated on the test dataset. Key evaluation metrics include test loss and test accuracy. Additionally, confusion matrices and a classification report were generated to assess the model's classification performance for each disease class.
The model achieved competitive test accuracy, indicating its ability to effectively classify diseases in chicken fecal matter images. Detailed evaluation metrics, such as precision, recall, and F1-score for each class, are available in the classification report.
In conclusion, this project demonstrates the feasibility of using deep learning to recognize diseases in chickens from images of their fecal matter. The balanced dataset, data augmentation, and transfer learning with MobileNetV3Small have contributed to the model's success. The results indicate that the model is a valuable tool for early disease detection and monitoring in poultry farming.