Summary: Image classification by disease recognition on leaves.
Requirements | Skills |
---|---|
- python3.10 - torch - torchvision - opencv - plantcv - numpy - matplotlib |
- Rigor - Group & interpersonal - Algorithms & AI |
There are 4 distinct parts in this project, 01. Distribution
, 02. Augmentation
, 03. Transformation
, and 04. Classification
.
Download image dataset and generate distribution chart image
usage: 01.Distribution.py [-h] directories [directories ...]
A program to analyze plant images and generate charts.
positional arguments:
directories The directories to store extracted images and save the charts (ex: 01.Distribution apple)
options:
-h, --help show this help message and exit
python3 01.Distribution.py apple grape
Augment unbalanced image dataset
usage: 02.Augmentation.py [-h] [file_path]
A program to augment images samples by applying 6 types of transformation.
positional arguments:
file_path Image file path to transform to 6 different types.
options:
-h, --help show this help message and exit
python3 02.Augmentation.py
Save transformed image plots
usage: 03.Transformation.py [-h] -src [SRC_PATH] [-dst [DST_PATH]] [-gaussian] [-mask] [-roi] [-analyze] [-pseudo] [-hist]
A program to display image transformation.
options:
-h, --help show this help message and exit
-src [SRC_PATH], --src_path [SRC_PATH]
Image file path.
-dst [DST_PATH], --dst_path [DST_PATH]
Destination directory path.
-gaussian, --gaussian_blur
Gaussian Transform
-mask Mask Transform
-roi, --roi_objects Roi Transform
-analyze, --analyze_object
Analyze Transform
-pseudo, --pseudolandmarks
Psudolandmark Transform
-hist, --color_histogram
Color histogram Transform
python3 03.Transformation.py -src [SRC_PATH] -dst [DST_PATH]
Print the accuracy on validation dataset
usage: 04.Classification.py [-h] [folder_path]
A program to classify a type of leaf from validation set.
positional arguments:
folder_path Image folder path.
options:
-h, --help show this help message and exit
python3 04.Classification
The model is designed to classify leaf diseases based on images of leaves. The model is implemented using Pytorch and consists of 4 convolutional layers followed by max pooling, along with 2 fully connected layers. The final output is produced using a softmax function for multi-class classification.
-
Input layer
- Input: Leaf images with a shape of (256, 256, 3) corresponding to 256 x 256 RGB images.
-
Convolutional layers
- Conv Layer 1
- Input channels: 3 (RGB)
- Output channels: 32
- Kernel size: 3 x 3
- Activation function: ReLU
- Max Pooling: 2 x 2
- Conv Layer 2
- Input channels: 32
- Output channels: 64
- Kernel size: 3 x 3
- Activation function: ReLU
- Max Pooling: 2 x 2
- Conv Layer 3
- Input channels: 64
- Output channels: 128
- Kernel size: 3 x 3
- Activation function: ReLU
- Max Pooling: 2 x 2
- Conv Layer 4
- Input channels: 128
- Output channels: 256
- Kernel size: 3 x 3
- Activation function: ReLU
- Max Pooling: 2 x 2
- Conv Layer 1
-
Fully connected layers
- FC Layer 1
- Input: Flattened tensor from the previous convolutional layers (256 * 14 * 14 = 50176 units)
- Output: 512 units
- Activation function: ReLU
- Dropout: 0.5
- FC Layer 2
- Input: 512 units
- Output:
NUM_CLASSES
units (representing the number of disease classes) - Activation function: Softmax
- FC Layer 1
There are 2 distinct leaf types; apple
and grape
, each of which consists of 4 labels.
Apple Image Distribution | Grape Image Distribution |
---|---|
The following 6 image augmentation techniques are applied to one single-leaf image labeled apple black rot
.
Brightness | Contrast | Flip | Perspective | Rotate | Saturation |
---|---|---|---|---|---|
The following 6 image transformation techniques are applied to one single-leaf image labeled apple black rot
.
Mask | Gaussian Blur | Roi objects | Analyze object | Pseudolandmarks |
---|---|---|---|---|
Color Histogram |
---|
To visualize the learning curves using tensorboard, execute the following command.
tensorboard --logdir runs
We have 10 test images and the model has 100% accuracy