RicardoPoleo commited on
Commit
b11f663
1 Parent(s): ae8662a

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +125 -0
README.md ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Custom CNN Model for Fruit and Vegetable Disease Detection
3
+
4
+ ## Model Description
5
+
6
+ This model is a custom Convolutional Neural Network (CNN) designed to classify images of fruits and vegetables as either healthy or rotten. The model was built using Keras and trained on the Fruit and Vegetable Diseases Dataset, which contains high-quality images for machine learning in agriculture and food quality control.
7
+
8
+ ## Model Architecture
9
+
10
+ The model consists of the following layers:
11
+
12
+ - **Conv2D**: 9 filters, kernel size (5, 5), padding 'same', input shape (128, 128, 3)
13
+ - **Activation**: ReLU
14
+ - **MaxPooling2D**: pool size (3, 3)
15
+ - **Conv2D**: 64 filters, kernel size (5, 5), padding 'same'
16
+ - **Activation**: ReLU
17
+ - **MaxPooling2D**: pool size (2, 2)
18
+ - **Conv2D**: 128 filters, kernel size (4, 4), padding 'same'
19
+ - **Activation**: ReLU
20
+ - **MaxPooling2D**: pool size (2, 2)
21
+ - **Conv2D**: 128 filters, kernel size (3, 3), padding 'same'
22
+ - **Activation**: ReLU
23
+ - **MaxPooling2D**: pool size (2, 2)
24
+ - **Flatten**
25
+ - **Dense**: 512 units, activation ReLU
26
+ - **Dropout**: rate 0.5
27
+ - **Dense**: 64 units, activation ReLU
28
+ - **Dense**: 28 units, activation Softmax (corresponding to the 28 classes of fruits and vegetables, healthy and rotten)
29
+
30
+ ## Training
31
+
32
+ The model was compiled and trained using the following settings:
33
+
34
+ - **Optimizer**: Adam
35
+ - **Loss Function**: Categorical Crossentropy
36
+ - **Metrics**: Accuracy
37
+ - **Epochs**: 10
38
+ - **Batch Size**: 128
39
+
40
+ ### Training History
41
+
42
+ The training history includes metrics such as loss and accuracy for both training and validation datasets over 10 epochs. The training history is available as a JSON file and shows significant improvement in accuracy and reduction in loss over the epochs.
43
+
44
+ ### Example Training History
45
+
46
+ ```json
47
+ {
48
+ "loss": [2.343, 1.384, 1.015, 0.761, 0.626, 0.517, 0.436, 0.374, 0.326, 0.285],
49
+ "accuracy": [0.286, 0.582, 0.692, 0.764, 0.804, 0.839, 0.858, 0.878, 0.895, 0.907],
50
+ "val_loss": [1.735, 1.201, 0.853, 0.639, 0.568, 0.504, 0.609, 0.451, 0.380, 0.387],
51
+ "val_accuracy": [0.471, 0.637, 0.737, 0.805, 0.822, 0.843, 0.811, 0.869, 0.884, 0.885]
52
+ }
53
+ ```
54
+
55
+ ## Dataset
56
+
57
+ The model was trained on the Fruit and Vegetable Diseases Dataset, which contains images categorized to assist in the development of machine learning models for detecting diseases in various fruits and vegetables.
58
+
59
+ ### Dataset Information
60
+
61
+ - **Number of Classes**: 28 (Healthy and Rotten categories for 14 different fruits and vegetables)
62
+ - **Image Format**: JPEG/PNG
63
+ - **Image Size**: Varies (resized to 128x128 for this model)
64
+
65
+ ### Data Collection
66
+
67
+ This dataset has been compiled from various reputable sources, including Kaggle and GitHub repositories. Each image has been manually inspected and categorized to ensure high quality and relevance for the task of disease detection in fruits and vegetables.
68
+
69
+ ### Usage
70
+
71
+ The dataset is highly versatile and can be used for a variety of machine learning tasks, including:
72
+
73
+ - Image Classification
74
+ - Transfer Learning
75
+ - Deep Learning
76
+
77
+ It is particularly useful for training models that can identify and distinguish between healthy and rotten produce, making it ideal for applications in agricultural technology and food quality control.
78
+
79
+ ### Preprocessing
80
+
81
+ Images were resized to a uniform size of 128x128 pixels to ensure consistent training. The dataset was split into training and validation sets to tune and evaluate the models effectively.
82
+
83
+ ## Model Performance
84
+
85
+ The model achieved the following performance metrics on the validation set after 10 epochs:
86
+
87
+ - **Validation Accuracy**: 88.6%
88
+ - **Validation Loss**: 0.388
89
+
90
+ ## Usage
91
+
92
+ To use this model, you can load it with Keras and use it to classify images of fruits and vegetables as either healthy or rotten.
93
+
94
+ ```python
95
+ from keras.models import load_model
96
+ import numpy as np
97
+ import cv2
98
+
99
+ # Load the model
100
+ model = load_model('custom_cnn_model.h5')
101
+
102
+ # Preprocess the image
103
+ image = cv2.imread('path_to_image')
104
+ image = cv2.resize(image, (128, 128))
105
+ image = np.expand_dims(image, axis=0)
106
+
107
+ # Predict the class
108
+ predictions = model.predict(image)
109
+ predicted_class = np.argmax(predictions, axis=1)
110
+ print(predicted_class)
111
+ ```
112
+
113
+ ## Acknowledgements
114
+
115
+ This model and dataset were developed using resources from Kaggle and GitHub. Special thanks to Muhammad Subhan for compiling the Fruit and Vegetable Diseases Dataset.
116
+
117
+ ## License
118
+
119
+ This model and the associated dataset are available under the CC0: Public Domain license.
120
+
121
+ For more information, please refer to the [dataset information PDF](link_to_pdf).
122
+
123
+ ### References
124
+
125
+ - [Fruit and Vegetable Diseases Dataset on Kaggle](https://www.kaggle.com/datasets/muhammad0subhan/fruit-and-vegetable-disease-healthy-vs-rotten/data)