This repository contains a simple example for detecting diseased apple leaves (We can use the same structure for any anomaly detection). The code was originally developed as a Google Colab notebook and demonstrates image preprocessing, a small convolutional neural network, and basic evaluation.
leaf_disease_detection.py- Main script (Colab-oriented) with preprocessing, model definition, training, and evaluation.
- Python 3.8+
- TensorFlow
- OpenCV (cv2)
- imutils
- scikit-learn
- matplotlib
- numpy
You can install the main packages with:
pip install tensorflow opencv-python imutils scikit-learn matplotlib numpyThe script uses Google Colab-specific helpers (google.colab.drive and google.colab.patches.cv2_imshow). To run locally, remove or adapt the Colab mount lines and update dataset paths to point to a local folder structure.
- Update the dataset paths inside
leaf_disease_detection.pyto point to your local dataset directories. - Remove or comment out the
drive.mount(...)line and Colab-specificcv2_imshowusages, replacing them withcv2.imshowor matplotlib display calls where appropriate. - Run:
python leaf_disease_detection.pyPersonal project/learning/studies!