An image-processing and computer-vision pipeline that automatically transforms plant-leaf photos to support disease-classification workflows.
We built the system using Python, TensorFlow, Keras, PlantCV, and OpenCV, learning which image transformations and CNN model metrics produce effective visual-classification performance, achieving approx 94% prediction accuracy.
This program will analyze a plant directory, counts all images in its subfolders, and generates bar and pie charts showing the distribution of classes.
python3 ./src/Distribution.py "./Apple"
- Transform a single image Displays the original and transformed versions on screen:
python3 ./src/Augmentation.py "images/leaves/Apple/Apple_healthy/image (1).JPG"The program will: Generate and display transformed images such as:
- Process a directory If the path points to a directory, the tool detects subdirectories (if any) and performs data augmentation for each:
python3 ./src/Augmentation.py "images/leaves/"The program will:
- Copy original images into augmented_directory/
- Generate additional images if a subdirectory has fewer images than the largest one
- Preserve subdirectory structure
The program takes source path, applies 6 transformations to the image or direcotry tree and and saves it in destination directory (in case of photo input not necessary to provide destination).
The advanced transformations may take a while so it is not recommended to use them on a big directories.
There are various possible execution ways.
Available transformations:
- gaussian_blur
- mask
- negative_image
- edges_image
- posterize
- sharpen
- roi_object (advanced)
- analyze_image (advanced)
image input:
python3 ./src/Transformation.py -src "./images/Apple/Apple_Black_rot/image (1).JPG" -dst new
python3 ./src/Transformation.py -src "./images/Apple/Apple_Black_rot/image (1).JPG" -f negative
python3 ./src/Transformation.py -src "./images/Apple/Apple_Black_rot/image (1).JPG" -f analyze --advanceddirectory input:
python3 ./src/Transformation.py -src "./images/Apple" -dst transformed_apple
python3 ./src/Transformation.py -src "./images/Apple" -dst transformed_apple -f mask
python3 ./src/Transformation.py -src "./images/Apple" -dst transformed_apple -f roi --advanced
This program allows you to split an image dataset into training/validation sets, train a CNN using TensorFlow, and export the trained model along with the class names inside a .zip file.
python3 ./src/train.py Grape/The Convolutional Neural Network (CNN) is composed of:
- Rescaling layer
- Conv2D layers
- MaxPooling2D layer
- Flatten layer
- Dense layer
Training configuration:
- Optimizer: Adam
- Loss: sparse_categorical_crossentropy
- Metric: accuracy
Once the training is complete, the program saves the model as a .h5 file, save the class names in a .csv file and creates a compressed ZIP file containing both files.
This program allows you to load a previously trained model (exported as a ZIP file), extract its contents, and classify a single image using the saved CNN.
python3 ./src/predict.py "Apple/apple_healthy/image (1).JPG" --model apple_model.zipThe program will: Validate the image path. Extract the model .h5 file and the class names .csv file from the provided ZIP archive. Load the trained model using TensorFlow/Keras. Run inference and compute prediction probabilities.
Example output:
Predicted class: apple_healthy. Confidence 0.97



