Cotton Leaf Disease Detection Using Machine Learning and Raspberry Pi
Author
Deepak R Khadse, Shubham S Pawar
Abstract
Biotic stresses induced by foliar pathogens and phytophagous insects severely constrain the lint yield and fiber quality of upland cotton (Gossypium hirsutum L.) across global agricultural belts. Conventional field diagnosis relies on manual visual scouting by extension agronomists, a procedure that is time-intensive, prone to inter-observer subjectivity, and largely unavailable to smallholder cultivators in remote regions. While deep learning classifiers have demonstrated high diagnostic accuracy in laboratory settings, existing cloud-dependent architectures require high-bandwidth internet connectivity and graphics processing unit (GPU) servers that are impractical for offline field deployment. This paper presents the design, mathematical formulation, and hardware implementation of a standalone edge-computing diagnostic system for automated cotton leaf disease and pest classification using a custom five-block Convolutional Neural Network (CNN) deployed on a Raspberry Pi 4 Model B (4 GB RAM) interfaced with a 3.5-inch resistive touch display. A balanced dataset of 3,600 RGB foliar images spanning six categories—Target Spot, Powdery Mildew, Healthy foliage, Bacterial Blight, Armyworm damage, and Aphid infestation—was curated and partitioned into 2,880 training, 360 validation, and 360 testing samples. Input frames were standardized to 224 × 224 × 3 resolution via OpenCV and NumPy pipelines incorporating bilateral filtering, floating-point normalization, and stochastic affine augmentation. Trained over 30 epochs (batch size 32, learning rate 0.001, Adam optimizer, categorical cross-entropy loss), the network achieved 96.8% training accuracy, 94.6% validation accuracy, and 93.9% independent testing accuracy, with macro-averaged precision, recall, and F1-scores of 94.2%, 94.0%, and 94.2%, respectively. Serialized into an 18.6 MB footprint (4.85 million parameters), the model required 2.84 seconds for one-time boot initialization on the Raspberry Pi 4 and executed image preprocessing in 38 milliseconds and forward-pass inference in 412 milliseconds, delivering a total per-leaf prediction time of 0.45 seconds entirely offline.
Keywords
Cotton Leaf Disease Detection, Convolutional Neural Network (CNN), Deep Learning, Edge AI, Raspberry Pi 4, Computer Vision, OpenCV, Precision Agriculture.
Full Text:
Download Paper PDF
References
[1] P. Johri, S. Kim, K. Dixit, P. Sharma, B. Kakkar, Y. Kumar, J. Shafi, and M. F. Ijaz, “Advanced deep transfer learning techniques for efficient detection of cotton plant diseases,” Frontiers in Plant Science, vol. 15, Art. no. 1441117, Dec. 2024. https://www.frontiersin.org/journals/plant-science/articles/10.3389/fpls.2024.1441117/full
[2] A. Rehman, N. Akhtar, and O. H. Alhazmi, “Monitoring and predicting cotton leaf diseases using deep learning approaches and mathematical models,” Scientific Reports, vol. 15, no. 1, Art. no. 22570, Jul. 2025. https://pmc.ncbi.nlm.nih.gov/articles/PMC12219678/
[3] L. K. Dhruw, V. K. Tewari, P. Soni, A. Chouriya, P. Patidar, and N. Singh, “Development of a unified deep learning approach integrating CNN-based local and ViT-based global feature extraction for enhanced cotton disease and pest classification,” Scientific Reports, vol. 15, Nov. 2025. https://pmc.ncbi.nlm.nih.gov/articles/PMC12584364/
[4] S. Hussen et al., “Explainable AI for cotton leaf disease classification: A metaheuristic-optimized deep learning approach,” Food Science & Nutrition, vol. 13, no. 7, Art. no. e70658, Jul. 2025, doi: 10.1002/fsn3.70658. https://pmc.ncbi.nlm.nih.gov/articles/PMC12283425/
[5] L. Xu, H. Song, X. Yang, P. Xu, and Z. Cai, “ViTKAB: An efficient deep learning network for cotton leaf disease identification,” Frontiers in Plant Science, vol. 16, Art. no. 1719877, Dec. 2025, doi: 10.3389/fpls.2025.1719877. https://www.frontiersin.org/journals/plant-science/articles/10.3389/fpls.2025.1719877/full
[6] M. Zekiwos and A. Bruck, “Deep learning-based image processing for cotton leaf disease and pest diagnosis,” Journal of Electrical and Computer Engineering, vol. 2021, Art. no. 9981437, Jun. 2021. https://www.researchgate.net/publication/352484184_Deep_Learning-Based_Image_Processing_for_Cotton_Leaf_Disease_and_Pest_Diagnosis
[7] S. Kinger and R. Tagalpallewar, “Deep learning based cotton leaf disease detection,” in Proc. IEEE Int. Conf., Oct. 2022. https://ieeexplore.ieee.org/document/10041630/
[8] C. K. Rai and R. Pahuja, “Classification of diseased cotton leaves and plants using improved deep convolutional neural network,” Multimedia Tools and Applications, vol. 82, no. 16, pp. 25307–25325, Jul. 2023, doi: 10.1007/s11042-023-14933-w.
[9] M. Latif et al., “Cotton leaf diseases recognition using deep learning and genetic algorithm,” Computers, Materials & Continua, vol. 69, no. 3, pp. 2917–2932, 2021, doi: 10.32604/cmc.2021.017364.
[10] V. R. Vangar et al., “AI-driven agriculture: Improving cotton farming through transfer learning-based disease detection and classification,” Cureus Journals, vol. 2, no. 1, Art. no. es44389-024-02217-9, Sep. 2025, doi: 10.7759/s44389-024-02217-9.
[11] S. Otiya et al., “Cotton leaf disease classification using deep convolution neural network with explainable AI,” in Proc. Int. Conf., Nov. 2023. https://www.researchgate.net/publication/377073800_Cotton_Leaf_Disease_Classification_using_Deep_Convolution_Neural_Network_with_Explainable_AI
[12] S. Vidivelli, R. Manikandan, S. Magesh, J. Cho, and S. V. Easwaramoorthy, “Exploring precision agriculture: Employing Grad-CAM for a deep neural network in cotton image detection and segmentation with XAI,” in AIP Conference Proceedings, vol. 3335, no. 1, Art. no. 030009, Oct. 2025.
[13] S. Anwar, S. R. Soomro, S. K. Baloch, A. A. Patoli, and A. R. Kolachi, “Performance analysis of deep transfer learning models for the automated detection of cotton plant diseases,” Engineering, Technology & Applied Science Research (ETASR), 2024. https://etasr.com/index.php/ETASR/article/view/6187
[14] G. V. K. Reddy and M. B. P. Kumar, “EfficientNet–Fuzzy ShCNN for multi-level cotton leaf disease classification under complex environments,” Engineering, Technology & Applied Science Research (ETASR), vol. 16, no. 3, pp. 35756–35761, Jun. 2026. https://etasr.com/index.php/ETASR/article/view/18077
[15] S. Nazim, A. Samad, N. Tanwani, J. Bhayo, and M. A. Rahu, “An explainable AI-based cotton leaf disease classification using EfficientNet, Grad-CAM, LIME, and SHAP,” International Journal of Agricultural Innovations and Cutting-Edge Research, vol. 4, no. 2, Feb. 2026. https://jai.bwo-researches.com/index.php/jwr/article/view/249
[16] R. Dodda et al., “Automated plant disease detection and prevention using Raspberry Pi and CNN algorithm,” in Proc. 2024 IEEE 3rd World Conf. Applied Intelligence and Computing (AIC), Jul. 2024. https://www.researchgate.net/publication/385359129_Automated_Plant_Disease_Detection_and_Prevention_Using_Raspberry_Pi_and_CNN_Algorithm
[17] M. Saad and A. Aidi, “Optimized deep learning models for edge computing: A comparative study on Raspberry Pi 4 for real-time plant disease detection,” Semantic Scholar / ResearchGate, 2024. https://www.researchgate.net/publication/387033774_Optimized_Deep_Learning_Models_For_Edge_Computing_A_Comparative_Study_on_Raspberry_PI4_For_Real-Time_Plant_Disease_Detection
[18] R. S. Tanksale and S. B. Mane, “Efficient plant disease detection on RISC devices: A comparison of Basic CNN, AlexNet, ResNet-50, and MobileNet models using MiniTensorFlow,” International Journal of Intelligent Systems and Applications in Engineering (IJISAE), vol. 12, Feb. 2024. https://www.ijisae.org/index.php/IJISAE/article/view/4849
[19] L. Hammam, H. A. Bastawrous, H. Ghali, and G. A. Ebrahim, “An embedded convolutional neural network model for potato plant disease classification,” Computers, vol. 14, no. 11, Art. no. 498, Nov. 2025. https://www.mdpi.com/2073-431X/14/11/498
[20] P. Bari, O. Kulkarni, P. Kudale, S. Hadole, and S. Mali, “AI-based crop disease detection using deep learning and Raspberry Pi,” International Journal of Innovative Science and Research Technology (IJISRT), vol. 10, no. 10, Oct. 2025, doi: 10.38124/ijisrt/25oct1526. https://www.ijisrt.com/aibased-crop-disease-detection-using-deep-learning-and-raspberry-pi
Share your valuable work from Social Media Buttons