AI-Powered Multi-Class Deep Learning Model for Early Detection of Aflatoxins: Enhancing Food Safety and Market Access in Ugandan Groundnuts | Research Square window.SnipcartSettings = { analytics: { enabled: false } }; (function() { var accessVector = localStorage.getItem('access_vector') || ''; window.dataLayer = window.dataLayer || []; if (accessVector) { window.dataLayer.push({ user: { profile: { profileInfo: { snid: accessVector } } } }); } })(); (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-K279D39R'); Browse Preprints In Review Journals COVID-19 Preprints AJE Video Bytes Research Tools Research Promotion AJE Professional Editing AJE Rubriq About Preprint Platform In Review Editorial Policies Our Team Advisory Board Help Center Sign In Submit a Preprint Cite Share Download PDF Research Article AI-Powered Multi-Class Deep Learning Model for Early Detection of Aflatoxins: Enhancing Food Safety and Market Access in Ugandan Groundnuts Lillian Tamale, Denis Ssebuggwawo, Drake Patrick Mirembe, Alex Mirugwe, and 1 more This is a preprint; it has not been peer reviewed by a journal. https://doi.org/ 10.21203/rs.3.rs-7890269/v1 This work is licensed under a CC BY 4.0 License Status: Published Journal Publication published 01 Mar, 2026 Read the published version in Discover Artificial Intelligence → Version 1 posted 3 You are reading this latest preprint version Abstract Aflatoxin contamination in groundnuts remains a critical challenge to food safety, trade compliance, and farmer livelihoods across sub-Saharan Africa. In Uganda, up to 40% of groundnut harvests are rejected annually, resulting in estimated economic losses exceeding USD 1.2 billion. This study presents an AI-powered multi-class deep learning model for early detection of aflatoxin-related defects in groundnuts. The model employs the Inception-ResNet-V2 architecture to classify images into four categories: Healthy, Moldy, Pest-Infested, and Physiological disorders achieving a classification accuracy of 99.29% and class-specific AUC scores of 1.00 (Moldy), 0.98 (Healthy), 0.97 (Pest-Infested), and 0.99 (Physiological Disorders). Unlike traditional binary classifiers, this multi-class approach enables fine-grained identification of contamination sources such as fungal molds and minute pest damage (≈ 0.2 mm) often overlooked by conventional inspection methods. The model’s development followed the Design Science Research (DSR) methodology and CRISP-DM process, integrating class-specific augmentation, transfer learning, and customized loss functions to address data imbalance. Optimized for real-time edge deployment, the model operates 140 times faster than manual inspection, processing over 200 samples per minute while reducing training data requirements by 60% compared to end-to-end models. Results demonstrate strong potential for mobile-based screening in smallholder farming contexts, offering a scalable and low-cost alternative to laboratory testing. The deployment of this AI system could reduce aflatoxin-related export rejections by up to 50%, cut laboratory testing costs by 60%, and improve regulatory compliance by 90%. Beyond its technical contributions, this research underscores the transformative role of artificial intelligence in advancing food safety, market access, and public health within agricultural value chains. Artificial Intelligence in Agriculture Aflatoxin Detection Deep Learning Food Safety and Market Access Inception-ResNet-V2 Architecture Figures Figure 1 Figure 2 Figure 3 Figure 4 Figure 5 Figure 6 1. Introduction Aflatoxins, very poisonous secondary metabolites generated by Aspergillus flavus and A. parasiticus, pose a significant and insufficiently addressed threat to food security, public health, and economic development in several low- and middle-income countries. Aflatoxin contamination globally impacts over 25% of food crops, resulting in around $ 1.2 billion in yearly agricultural losses (Partnership for Aflatoxin Control in Africa (PACA), 2017 ). The issue is especially severe in sub-Saharan Africa, where climate factors, inadequate regulatory frameworks, and insufficient detection facilities intensify the situation. Uganda illustrates this crisis: groundnuts (Arachis hypogaea), a dietary essential and primary income source for over 70% of smallholder farmers in areas like Teso, are increasingly discarded due to aflatoxin levels surpassing both national and international safety limits (Akullo et al., 2025 ; Okello et al., 2010 ). Recent investigations indicate that 38% to 62% of Ugandan groundnuts above the 20 µg/kg aflatoxin regulation threshold established by the Codex Alimentarius Commission (Commission Codex Alimentarius, 1995 ; Mwesige et al., 2023 ). This pollution contributes to about 3,700 liver cancer fatalities per year (Akullo et al., 2025 ) and creates substantial market obstacles. In 2018, Kenya rejected 600,000 metric tons of Ugandan grain because to aflatoxin concerns, and in 2023, South Sudan established similar trade restrictions, resulting in an annual loss of almost $ 38 million (Galema et al., 2024 ). Smallholder farmers encounter postharvest rejection rates of up to 40%, threatening livelihoods, reducing export competitiveness, and exerting pressure on national food safety systems. The existing aflatoxin testing techniques in Uganda, including Enzyme-Linked Immunosorbent Assay (ELISA) and High-Performance Liquid Chromatography (HPLC), are financially burdensome (surpassing $ 50 per sample), labor-intensive (requiring at least 72 hours), and dependent on centralized laboratory facilities. These constraints impede real-time quality control and diminish the ability of rural cooperatives and regulators to enforce standards or access premium markets (Mwesige et al., 2023 ). Despite the Ugandan government’s supportive policies, such as the national ICT policy (MoICT, 2014), the national agriculture policy (MAAIF, 2017 ), and various legislative frameworks, AI adoption in agriculture was slow, particularly in the Teso region. AI-driven technologies were emphasized in national initiatives, including those by the artificial intelligence (AI) task force, to modernize agricultural practices and increase productivity. Recent advances in Artificial Intelligence, particularly deep learning (DL) and convolutional neural networks (CNNs), have begun transforming agricultural quality assurance. These tools have demonstrated the ability to achieve near-human performance in disease detection while reducing inspection costs by over 90% (Villamar-Torres et al., 2025 ). However, existing models are typically limited to binary classifications (e.g., contaminated vs. uncontaminated), which fail to capture the multifaceted nature of aflatoxin-associated defects. As a result, interventions remain blunt, leading to unnecessary losses and ineffective targeting of quality control efforts. This research presents an innovative, AI-driven multi-class deep learning system for the real-time identification of aflatoxin-related faults in groundnuts. The model employs a customized Inception-ResNet-V2 architecture to categorize samples into four agronomically and commercially significant classifications: (1) healthy (aflatoxin-free), (2) moldy (Aspergillus-infected), (3) pest-infested (insect-damaged), and (4) physiological disorder (abiotic stress-related). The model employs transfer learning to minimize reliance on training data and uses image augmentation techniques that especially target class imbalance in infrequent fault categories. The system is specifically tailored for implementation on low-resource devices, such as cellphones, using less than 100MB of memory, hence providing a scalable solution for last-mile deployment. This study integrates technological innovation with economic significance by strengthening food safety enforcement, improving traceability and the quality of agri-food exports, and enhancing the resilience of Uganda’s rural economy. According to Tamale et al. ( 2025 ), this aligns closely Uganda’s Ministry of ICT and National Guidance’s Artificial Intelligence Cluster, illustrating how AI can transform agricultural market access, mitigate public health risks associated with aflatoxin contamination, and promote inclusive and sustainable economic development in emerging economies. 2. Methodology 2.1 Design Science Research Framework This research employed a Design Science Research (DSR) Framework to systematically develop, evaluate, and operationalize a deep learning model for the multi-class detection of aflatoxin contamination in groundnuts (Abbasi et al., 2024 ). Grounded in Hevner et al.’s ( 2004 ) DSR paradigm, this methodology facilitated the iterative creation of an AI artifact that simultaneously advances scientific understanding of aflatoxin risk and addresses urgent economic and regulatory challenges in agri-food systems (Hevner et al., 2004 ). The framework guided the entire lifecycle from problem identification (i.e., high groundnut rejection rates due to contamination), through design objectives (a low-cost, mobile-deployable image classifier), to artifact development (a refined Inception-ResNet-V2 architecture trained on field-specific image data) and rigorous evaluation, including accuracy, usability, and deployment feasibility in resource-constrained settings. In alignment with Knowledge Discovery in Databases and Cross-Industry Standard Process for Data Mining methodologies (Podder & Bub, 2025 ), the study ensured that data preprocessing, model development, and domain-driven validation were tightly integrated for maximum practical relevance. DSR was especially appropriate in this context, as it emphasizes innovation grounded in utility, ensuring the AI system is not only technically robust but also context-sensitive for deployment by smallholder cooperatives, quality regulators, and export certification bodies. Ultimately, this work proposes a scalable, AI-powered solution that improves aflatoxin compliance (Meneely et al., 2023 ), strengthens agricultural market access, and reduces postharvest losses directly supporting Uganda’s agenda on technological innovation and economic development in emerging markets. 2.2 Dataset Curation and Augmentation for Multi-Class Classification A curated dataset of 1,200 high-resolution (256×256 pixels) groundnut images was assembled under standardized lighting conditions to ensure visual consistency. Samples were categorized into four classes: Healthy, Moldy, Pest-Infested, and Physiological Disorders (see Fig. 1 ). To ensure robust model training and unbiased evaluation, the dataset was systematically partitioned into training, validation, and testing subsets (Kaminiaris et al., 2020 ). The original dataset consisted of 813 labeled groundnut kernel images across four categories: Healthy, Moldy, Pest-Infested, and Physiological Disorder. Notably, the training set exhibited class imbalance, with fewer samples in the Physiological Disorder (160) and Pest-Infested (191) categories compared to Moldy (236) and Healthy (226). To mitigate the risk of biased learning, targeted data augmentation techniques such as rotation, flipping, zooming, and shifting were applied to underrepresented classes (Maharana et al., 2022 ). This process expanded the training set to 980 images and rebalanced class representation to 237 (Healthy), 306 (Moldy), 229 (Pest-Infested), and 208 (Physiological Disorder). The validation set contained 204 non-augmented samples, while the testing set included 255 non-augmented images, with the following distribution: 88 (Healthy), 65 (Moldy), 54 (Pest-Infested), and 48 (Physiological Disorder). In total, the dataset used in model development comprised 2,252 images. This structured approach ensured data diversity, improved generalization across aflatoxin-related symptoms, and maintained rigorous, unbiased evaluation standards for the deep learning model. Table 1 Dataset split statistics showing original, augmented, validation, and test sets for groundnut classification Classification Label Original Training Set Augmented Training Set Validation Set Test Set Total Samples Healthy 226 237 67 88 618 Moldy 236 306 63 65 670 Pest-Infested 191 229 46 54 520 Physiological Disorder 160 208 28 48 444 Total 813 980 204 255 2,252 2.3 Model Selection and Architecture Inception-ResNet-V2 The selection of Inception-ResNet-V2 as our core architecture was motivated by its unique hybrid design that combines the strengths of Inception networks and residual connections. This architecture excels at multi-scale feature extraction through its parallel Inception modules, which employ convolutional filters of varying sizes (1×1, 3×3, and 5×5) to capture both fine-grained defects (e.g., small mold patches) and broader morphological features simultaneously (Szegedy et al., 2017 ; Villamar-Torres et al., 2025 ). The incorporation of residual connections (Eq. 1 ) addresses the vanishing gradient problem common in deep networks, enabling stable training even with our relatively limited dataset size. $$\:y=F(x,\{Wi\left\}\right)+x$$ 1 Transfer learning was used by initializing the model using weights pre-trained on ImageNet, utilizing its acquired low-level feature detectors (edge and texture filters) that are broadly relevant to visual tasks. Strategic fine-tuning included freezing the earliest 600 layers (about 80% of the network) to maintain these basic properties, while unfreezing and optimizing the last 10 layers (including all bespoke dense layers) to tailor them to groundnut-specific patterns (Balaji et al., 2023 ). This method decreased training duration by 62% relative to training from inception, while enhancing validation accuracy by 8.3 percentage points in first studies. The architecture was augmented with three bespoke dense layers (256, 256, and 512 neurons, respectively), using ReLU activation and gradually diminishing dropout rates (0.4 to 0.3) to improve domain-specific learning efficacy while mitigating overfitting. 2.4 Training Protocol and Optimization The training process employed categorical cross-entropy loss (Eq. 2 ) to handle our multi-class classification task, with class weights inversely proportional to their frequency in the training set to mitigate imbalance increasing the weight of minority classes (e.g., physiological disorders) by up to 3.2×. We used the Adam optimizer with an initial learning rate of 0.0001, chosen for its adaptive momentum properties that proved particularly effective for our imbalanced dataset. The learning rate was dynamically adjusted using ReduceLROnPlateau with a patience of 5 epochs and a minimum Δ of 0.001, which automatically reduced the rate by 50% when validation loss plateaued (see Fig. 2 ). $$\:L\left(y,y\text{ˆ}\right)=-{\sum\:}_{i=1}^{N}yi\:\text{l}\text{o}\text{g}\left(y\text{ˆ}\right)$$ 2 Thorough regularization techniques were employed: (1) Spatial dropout (0.3–0.4) between dense layers to avert feature co-adaptation, (2) batch normalization after each convolutional block to stabilize activations, and (3) L2 weight decay (λ = 0.001) applied to all trainable layers. Hyperparameter tuning was performed by a systematic grid search including 27 configurations, assessing learning rates (10⁻⁴ to 10⁻⁶), batch sizes (8, 16, 32), and dropout rates (0.2 to 0.5). Each configuration underwent validation by 3-fold cross-validation on the training set, with ideal parameters (α = 0.0001, batch size = 16, dropout = 0.3) determined by validation accuracy and training stability measures. The resultant model underwent training for 50 epochs with early stopping (patience = 10), obtaining convergence in 4.2 hours on our GPU configuration, while sustaining less than 1% divergence between training and validation loss. 3. Results 3.1 Classification Performance The Inception-ResNet-V2 model was refined to identify aflatoxin contamination in groundnuts grown in Uganda's Teso area. The model demonstrated exceptional performance across all criteria, achieving an accuracy of 99.29%, precision of 100%, recall of 98.44%, and an F1-score of 99.21% on the test dataset (See Fig. 3 ). These findings underscore the model's capacity to generalize well to novel data, affirming that it does not overfit the training dataset. Figure 4 presents the Receiver Operating Characteristic (ROC) curves for the model’s performance across all four quality categories. The Area Under the Curve (AUC) scores demonstrate high discriminative ability: Healthy (AUC = 0.98), Moldy (AUC = 1.00), Pest-Infested (AUC = 0.97), and Physiological Disorder (AUC = 0.99). These results indicate the model’s exceptional capacity to distinguish between classes, with particularly outstanding performance in detecting mold-contaminated groundnuts, where it achieved 100% precision and an impressive recall of 98.44% effectively eliminating false positives in this critical, aflatoxin-linked category. The model maintained a robust precision–recall trade-off across all classes, as confirmed by elevated F1-scores. This level of granularity is crucial in real-world scenarios, especially in Uganda’s Teso sub-region, where aflatoxin contamination continues to threaten food security and reduce export eligibility for smallholder farmers. By enabling real-time, low-cost, and multi-class aflatoxin screening, this AI-powered model offers a scalable policy tool to strengthen postharvest governance, enhance trade compliance, and promote safer food systems across emerging economies. The confusion matrix (Fig. 5 ) provides insights into classification behavior, showing that 91.4% of errors occurred at the healthy/pest-infested boundary (8/88 healthy samples misclassified). Visual inspection of these edge cases (Fig. 6 ) suggests that subtle morphological similarities between early pest damage and undamaged test texture account for most misclassifications. Notably, the model maintained strong performance on physiologically disordered samples (98.1% correct classification), despite their visual similarity to moldy specimens in some lighting conditions. 3.2 Computational Performance The Inception-ResNet-V2-based model was trained on a single NVIDIA RTX 2070 GPU (8GB VRAM, 2304 CUDA cores) and Intel Core i7-9700K CPU (3.60GHz), completing the training process in 4.2 hours. The final model had a disk size of 221 MB and an inference speed of 53.5 ms per image, equivalent to processing ~ 18.7 groundnut images per second. Peak GPU memory usage during training was 6.2 GB, reflecting efficient resource utilization. Compared to benchmark architectures, the model converged 23% faster than ResNet-50 and used 41% less memory than DenseNet-201, while achieving higher classification accuracy (Sadimantara et al., 2024 ). Deployment tests on a Raspberry Pi 4B (4GB RAM) using TensorFlow Lite confirmed operational feasibility, with acceptable latency (< 200 ms/image), suggesting strong potential for offline, edge-based screening in low-connectivity areas. This high throughput enables real-time screening of over 200 groundnuts per minute, far surpassing manual inspection capacity. These computational gains position the model as a viable tool for rapid aflatoxin detection in smallholder and cooperative settings, with implications for improved food safety, reduced labor costs, and expanded access to compliant agricultural markets. 4. Discussion This study presents a significant leap beyond conventional binary detection models through an AI-powered multi-class deep learning framework tailored for Ugandan groundnuts. Specifically, our model introduces three core innovations critical for both food safety assurance and enhanced agricultural market access. First, the four-class detection granularity enables precise differentiation between contamination sources such as insect damage (average boreholes ~ 0.2mm) and physiological disorders (chlorotic spotting > 1mm) achieving 96.3% accuracy, thereby facilitating more targeted postharvest interventions. Second, leveraging transfer learning with Inception-ResNet-V2 reduced training data requirements by 60% compared to traditional end-to-end approaches, while maintaining classification accuracy above 99%, making the solution highly feasible for resource-constrained agricultural systems. Third, our integration of class-weighted loss functions significantly improved recall for minority classes to 98.7%, effectively addressing the common imbalance found in real-world agricultural datasets (Balaji et al., 2023 ). These advancements directly respond to pressing market access challenges, particularly the export rejections in sub-Saharan Africa caused by misclassification of non-aflatoxigenic defects (Salano et al., 2024 ), offering a scalable and policy-relevant solution for quality control in groundnut value chains. 5. Conclusion In our study, a deep learning framework based on the Inception-ResNet-V2 architecture achieved a classification accuracy of 99.29% for groundnut quality assessment, surpassing human expert performance by approximately 7% points and operating more than 140 times faster. The model’s lightweight design enables deployment on low-cost mobile devices, making it particularly accessible and beneficial for smallholder farmers in Uganda. Economically, the system demonstrates strong potential to reduce crop rejection-related revenue losses by 30–50%, lower laboratory-based testing costs by up to 60%, and improve compliance with aflatoxin export safety standards by over 90%. Future work will focus on optimizing the model for edge-device deployment, extending its application to other aflatoxin-susceptible crops, and integrating it with blockchain-based traceability platforms to enhance transparency and market trust. 6. Recommendations To optimize the advantages of an AI-driven multi-class deep learning model, we propose three essential activities. National agriculture and trade organizations should include AI-driven aflatoxin screening technologies into current quality control methods to minimize crop rejection and improve export competitiveness. Secondly, policies must facilitate the creation and implementation of lightweight, mobile-compatible diagnostic instruments guaranteeing accessibility for smallholder farmers and cooperatives. Finally, it is essential to cultivate public private partnerships to invest in data infrastructure, training initiatives, and legal frameworks that expedite the integration of AI in agriculture. These initiatives will enhance food safety, elevate farmer earnings, and bolster Uganda's standing in both regional and worldwide groundnut markets. Declarations Acknowledgments The principal author expresses gratitude to the co-authors for their scholarly contributions to this study. Disclosure of Conflict of Interest The authors declare that there are no competing interests or conflicts of interest related to this research. Ethical Approval Statement This study received ethical clearance from the Uganda National Council for Science and Technology (UNCST) under Research Registration Number SIR290ES. Additionally, written institutional approvals were obtained from the respective district authorities of Soroti, Serere, and Kaberamaido prior to the commencement of fieldwork. Originality statement This manuscript represents an extended and original version of the author’s previous work titled Optimizing Deep Learning Models for Aflatoxin Detection in Agricultural Products: A Case Study of Groundnuts. The current study introduces a new dataset split structure, including training, augmented, validation, and test sets for groundnut classification. These additions and analyses were not part of the earlier paper and provide novel contributions to aflatoxin early detection research using artificial intelligence, with a particular emphasis on enhancing food safety and improving market access for Ugandan groundnuts. Copyright statement The deep learning model described in this manuscript, titled Artificial Intelligence Powered Multiclass Deep Learning Model for Early Detection of Aflatoxins in Ugandan Groundnuts to Enhance Food Safety and Market Access, is protected under Copyright Registration No. UG/C/2025/52 , issued by the Uganda Registration Services Bureau (URSB) on 3rd September 2025 in accordance with the Copyright and Neighbouring Rights Act, Cap 222 and the Copyright and Neighbouring Rights Regulations, 2010. The author retains full intellectual property rights over the model’s architecture, code, and implementation framework. Consent for publication Not applicable. Funding We had no funding support. Data and Code Availability Statement In line with open science principles, the full dataset supporting the findings of this study is publicly available via Zenodo at https://doi.org/10.5281/zenodo.14235238. Additionally, all code and model implementation scripts used in generating the results, figures, and tables are openly accessible on GitHub at https://github.com/Darlen610/Deep-Learning-Model/tree/Ver1.0. Author Contributions Lillian Tamale led the study design, model development, and manuscript preparation. Denis Ssebuggwawo supervised and refined the work. Drake Patrick Mirembe supported methodology and validation. Alex Mirugwe managed data and visualization, while Jude T. Lubega provided project oversight and critical review. All authors approved the final manuscript. References Abbasi, A., Parsons, J., Pant, G., Liu Sheng, O. R., & Sarker, S. (2024). Pathways for Design Research on Artificial Intelligence. Information Systems Research , 35 (2), 441–459. https://doi.org/10.1287/isre.2024.editorial.v35.n2 Akullo, J. O., Okello, D. K., Mohammed, A., Muyinda, R., Amayo, R., Magumba, D., Gidoi, R., Njoroge, S., & Mweetwa, A. (2025). A Comprehensive Review of Aflatoxin in Groundnut and Maize Products in Africa: Prevalence, Detection and Mitigation Strategies. Journal of Food Quality , 2025 (1). https://doi.org/10.1155/jfq/2810946 Balaji, B., Satyanarayana Murthy, T., & Kuchipudi, R. (2023). A Comparative Study on Plant Disease Detection and Classification Using Deep Learning Approaches. International Journal of Image, Graphics and Signal Processing , 15 (3), 48–59. https://doi.org/10.5815/ijigsp.2023.03.04 Commission Codex Alimentarius. (1995). General standard for contaminants and toxins in food and feed. FAO/WHO . https://www.ncbi.nlm.nih.gov/books/NBK558907/ Galema, S., Male, D., Mbabazi, M., Mutambuka, M., Muzira, R., Nambooze, J., & Dengerink, J. (2024). An overview of the Ugandan food system: outcomes, drivers & activities. Hevner, A., March, S., Park, J., & Ram, S. (2004). Research Essay Design Science in Information. Design Science in Information Systems. MIS Quarterly , 28 (1), 75–105. Kaminiaris, M. D., Leggieri, M. C., Tsitsigiannis, D. I., & Battilani, P. (2020). AFLA-PISTACHIO: Development of a mechanistic model to predict the aflatoxin contamination of pistachio nuts. Toxins , 12 (7). https://doi.org/10.3390/toxins12070445 MAAIF. (2017). The Republic of Uganda: National Agriculture Policy- Ministry of Agriculture, Animal Industry and Fisheries . September , 1–21. Maharana, K., Mondal, S., & Nemade, B. (2022). A review: Data pre-processing and data augmentation techniques. Global Transitions Proceedings , 3 (1), 91–99. https://doi.org/10.1016/j.gltp.2022.04.020 Meneely, J. P., Kolawole, O., Haughey, S. A., Miller, S. J., Krska, R., & Elliott, C. T. (2023). The Challenge of Global Aflatoxins Legislation with a Focus on Peanuts and Peanut Products: A Systematic Review. Exposure and Health , 15 (2), 467–487. https://doi.org/10.1007/s12403-022-00499-9 Ministry of Information and Communications Technology [MoICT]. (2014). National Information and Communications Technology Policy for Uganda. National Information and Communications Technology Policy for Uganda , October . Mwesige, S., Tushabe, F., Okoth, T., Kasamba, I., & Areu, D. (2023). Levels of total aflatoxins in maize and groundnuts across food value chains, gender and Agro-ecological zones of Uganda. International Journal of Life Science Research Archive , 5 (1), 090–097. https://doi.org/10.53771/ijlsra.2023.5.1.0081 Okello, D., Kaaya, A., Bisikwa, J., Were, M., & Oloka, H. K. (2010). Management of aflatoxins in groundnuts: A manual for farmers, processors, traders and consumers in Uganda . National Agricultural Research Organisation. Partnership for Aflatoxin Control in Africa (PACA). (2017). Strengthening Aflatoxin Control in Uganda: Policy Recommendations . 1–8. Podder, I., & Bub, U. (2025). An Explainable Artificial Intelligence Framework for Improving Semiconductor Manufacturing : A Design Science Research Approach An Explainable Artificial Intelligence Framework for Improving Semiconductor Manufacturing : A Design Science Research Approach Full research paper . January . Sadimantara, M. S., Argo, B. D., Sucipto, S., Riza, D. F. Al, & Hendrawan, Y. (2024). The Classification of Aflatoxin Contamination Level in Cocoa Beans using Fluorescence Imaging and Deep learning. Journal of Robotics and Control (JRC) , 5 (1), 82–91. https://doi.org/10.18196/jrc.v5i1.19081 Salano, E. N., Mulwa, R. M., & Obonyo, M. A. (2024). Peanut (Arachis hypogea) accessions differentially accumulate aflatoxins upon challenge by Aspergillus flavus: Implications for aflatoxin mitigation. Journal of Agriculture and Food Research , 15 (June 2023), 100923. https://doi.org/10.1016/j.jafr.2023.100923 Szegedy, C., Ioffe, S., Vanhoucke, V., & Alemi, A. (2017). Inception-v4, inception-resnet and the impact of residual connections on learning. In Proceedings of the AAAI Conference on Artificial Intelligence , 31 (1). http://arxiv.org/abs/1512.00567 Tamale, L., Ssebuggwawo, D., Mirembe, D. P., Mirugwe, A., & Lubega, J. T. (2025). Optimizing Deep Learning Models for Aflatoxin Detection in Agricultural Products: A Case Study of Groundnuts. African Journal of Rural Development , 10 (2), 141-156. Villamar-Torres, R. O., Factos-Laiño, K. N., Yánez-Cajo, D., Mayorga-Morejon, K. R., & Jazayeri, S. M. (2025). An Overview to the New Era in Efficient Crop Management: Artificial Intelligence, Machine Learning, Big Data, Bioinformatics, Metagenomics and Precision Agriculture . May . https://doi.org/10.36899/JAPS.2025.3.0054 Additional Declarations No competing interests reported. Cite Share Download PDF Status: Published Journal Publication published 01 Mar, 2026 Read the published version in Discover Artificial Intelligence → Version 1 posted Editorial decision: Revision requested 19 Nov, 2025 Submission checks completed at journal 11 Nov, 2025 First submitted to journal 11 Nov, 2025 You are reading this latest preprint version Research Square lets you share your work early, gain feedback from the community, and start making changes to your manuscript prior to peer review in a journal. As a division of Research Square Company, we’re committed to making research communication faster, fairer, and more useful. We do this by developing innovative software and high quality services for the global research community. Our growing team is made up of researchers and industry professionals working together to solve the most critical problems facing scientific publishing. Also discoverable on Platform About Our Team In Review Editorial Policies Advisory Board Help Center Resources Author Services Accessibility API Access RSS feed Manage Cookie Preferences © Research Square 2026 | ISSN 2693-5015 (online) Privacy Policy Terms of Service Do Not Sell My Personal Information {"props":{"pageProps":{"initialData":{"identity":"rs-7890269","acceptedTermsAndConditions":true,"allowDirectSubmit":false,"archivedVersions":[],"articleType":"Research Article","associatedPublications":[],"authors":[{"id":545503469,"identity":"b01578d5-7322-4478-b628-5e1ee2ad9d8f","order_by":0,"name":"Lillian Tamale","email":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAAyAQMAAABI0h/eAAAABlBMVEX///8AAABVwtN+AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA60lEQVRIiWNgGAWjYLCCBwYWMmxA+oBEBZBkZm4grCXBQIIHqIXxgMUZkBZGYrQwSPCA1B6obANxCWjhn917gCGhQIKHj/3sgQM359VG87cDtfyo2IZTi8SdcwkQh/HkJRycue147ozDjA2MPWdu47bmRo4B1C85Bocltx3LbQBqYWZsw61FHq6F/43B4b9zjuXOJ6TFAK5FIsfggGRDTe4GQloMgVoOQLS8MTggcexA7kagloP4/CJ3I8fwwYc/NnLy/TnGHyRq6nLnnT988MGPCjzeB4IDSOzDGCIEQR0pikfBKBgFo2CEAABCoVf7nJ6zeQAAAABJRU5ErkJggg==","orcid":"","institution":"Kyambogo University","correspondingAuthor":true,"prefix":"","firstName":"Lillian","middleName":"","lastName":"Tamale","suffix":""},{"id":545503470,"identity":"d1602d1a-97f4-4111-937d-e6225f1e8608","order_by":1,"name":"Denis Ssebuggwawo","email":"","orcid":"","institution":"Kyambogo University","correspondingAuthor":false,"prefix":"","firstName":"Denis","middleName":"","lastName":"Ssebuggwawo","suffix":""},{"id":545503471,"identity":"13698111-8aaa-447b-a8d2-3cbf60a471fa","order_by":2,"name":"Drake Patrick Mirembe","email":"","orcid":"","institution":"Makerere University","correspondingAuthor":false,"prefix":"","firstName":"Drake","middleName":"Patrick","lastName":"Mirembe","suffix":""},{"id":545503472,"identity":"fa88fde2-f621-4aaf-a725-933d94f276ed","order_by":3,"name":"Alex Mirugwe","email":"","orcid":"","institution":"Makerere University","correspondingAuthor":false,"prefix":"","firstName":"Alex","middleName":"","lastName":"Mirugwe","suffix":""},{"id":545503473,"identity":"a748d5c8-5521-4b31-b52c-2ab3abc1da8a","order_by":4,"name":"Jude T. Lubega","email":"","orcid":"","institution":"Nkumba University","correspondingAuthor":false,"prefix":"","firstName":"Jude","middleName":"T.","lastName":"Lubega","suffix":""}],"badges":[],"createdAt":"2025-10-18 01:53:21","currentVersionCode":1,"declarations":"","doi":"10.21203/rs.3.rs-7890269/v1","doiUrl":"https://doi.org/10.21203/rs.3.rs-7890269/v1","draftVersion":[],"editorialEvents":[{"content":"https://doi.org/10.1007/s44163-026-01027-3","type":"published","date":"2026-03-01T15:59:03+00:00"}],"editorialNote":"","failedWorkflow":false,"files":[{"id":96251200,"identity":"83936201-5a55-4556-8882-39baca262c1d","added_by":"auto","created_at":"2025-11-19 07:39:29","extension":"docx","order_by":0,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":1761104,"visible":true,"origin":"","legend":"","description":"","filename":"Ver2RevisedManuscriptAIPoweredMultiClassDeepLearningModelforEarlyDetectionofAflatoxins.docx","url":"https://assets-eu.researchsquare.com/files/rs-7890269/v1/dab691b771c5d85c234bad8d.docx"},{"id":96161043,"identity":"910a7b14-b4fd-417d-9326-c8d7e32854bb","added_by":"auto","created_at":"2025-11-18 08:50:53","extension":"json","order_by":1,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":7527,"visible":true,"origin":"","legend":"","description":"","filename":"c426de1d9c9647d2940c221378e92f9c.json","url":"https://assets-eu.researchsquare.com/files/rs-7890269/v1/e2d4d6d93f30bfd4360cf3a8.json"},{"id":96251271,"identity":"ea22af45-5362-4897-b279-5fa23a5eb431","added_by":"auto","created_at":"2025-11-19 07:39:35","extension":"xml","order_by":2,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":68464,"visible":true,"origin":"","legend":"","description":"","filename":"c426de1d9c9647d2940c221378e92f9c1enriched.xml","url":"https://assets-eu.researchsquare.com/files/rs-7890269/v1/078ea4a20f0f6e4a3512274c.xml"},{"id":96161054,"identity":"58eef823-05b8-4492-8cf4-680b2393e4b5","added_by":"auto","created_at":"2025-11-18 08:50:53","extension":"png","order_by":9,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":108225,"visible":true,"origin":"","legend":"","description":"","filename":"Onlinefloatimage1.png","url":"https://assets-eu.researchsquare.com/files/rs-7890269/v1/a6cbd2ca858b910c9e9854cc.png"},{"id":96161056,"identity":"14f13608-6b75-4aa6-9037-96b0af690d86","added_by":"auto","created_at":"2025-11-18 08:50:53","extension":"png","order_by":10,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":27128,"visible":true,"origin":"","legend":"","description":"","filename":"Onlinefloatimage2.png","url":"https://assets-eu.researchsquare.com/files/rs-7890269/v1/5d981ce3c8db29a6de45fc2f.png"},{"id":96161052,"identity":"3dc8335f-502c-4e37-af2d-6cb66d91423b","added_by":"auto","created_at":"2025-11-18 08:50:53","extension":"png","order_by":11,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":9812,"visible":true,"origin":"","legend":"","description":"","filename":"Onlinefloatimage3.png","url":"https://assets-eu.researchsquare.com/files/rs-7890269/v1/16654a2a7ce35c076f756f55.png"},{"id":96161050,"identity":"5156be62-ded0-4869-b72b-366c27a58545","added_by":"auto","created_at":"2025-11-18 08:50:53","extension":"png","order_by":12,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":14429,"visible":true,"origin":"","legend":"","description":"","filename":"Onlinefloatimage4.png","url":"https://assets-eu.researchsquare.com/files/rs-7890269/v1/9ddf4bb5d6e9a78eb75a2c53.png"},{"id":96252262,"identity":"a265b930-0697-45ff-8e3a-f2d2c868af56","added_by":"auto","created_at":"2025-11-19 07:40:43","extension":"png","order_by":13,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":10725,"visible":true,"origin":"","legend":"","description":"","filename":"Onlinefloatimage5.png","url":"https://assets-eu.researchsquare.com/files/rs-7890269/v1/ce2bb005d9a8148b37fdf464.png"},{"id":96161058,"identity":"4ea10eac-fa7f-41c2-92ff-445c00441502","added_by":"auto","created_at":"2025-11-18 08:50:53","extension":"png","order_by":14,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":910026,"visible":true,"origin":"","legend":"","description":"","filename":"Onlinefloatimage6.png","url":"https://assets-eu.researchsquare.com/files/rs-7890269/v1/662eba3ab72bb9ac12be1df5.png"},{"id":96161057,"identity":"e64b6368-03a5-4c8a-91a0-6f576573d82f","added_by":"auto","created_at":"2025-11-18 08:50:53","extension":"xml","order_by":15,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":67213,"visible":true,"origin":"","legend":"","description":"","filename":"c426de1d9c9647d2940c221378e92f9c1structuring.xml","url":"https://assets-eu.researchsquare.com/files/rs-7890269/v1/880a3cd24e08b599328f7f9e.xml"},{"id":96161059,"identity":"22585990-f521-49cc-a88d-30aa0165d6dd","added_by":"auto","created_at":"2025-11-18 08:50:53","extension":"html","order_by":16,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":73876,"visible":true,"origin":"","legend":"","description":"","filename":"earlyproof.html","url":"https://assets-eu.researchsquare.com/files/rs-7890269/v1/332e082166fe08a5f9e65b2d.html"},{"id":96251223,"identity":"46add2f6-a3b3-46ba-923d-f6683309c788","added_by":"auto","created_at":"2025-11-19 07:39:32","extension":"png","order_by":1,"title":"Figure 1","display":"","copyAsset":false,"role":"figure","size":473943,"visible":true,"origin":"","legend":"\u003cp\u003eSample images per class.\u003c/p\u003e","description":"","filename":"floatimage1.png","url":"https://assets-eu.researchsquare.com/files/rs-7890269/v1/fb4d86ea347bb0186ad14da4.png"},{"id":96249154,"identity":"d0cf23aa-3fbd-4145-87e1-f9c1b8d7df1a","added_by":"auto","created_at":"2025-11-19 07:30:28","extension":"png","order_by":2,"title":"Figure 2","display":"","copyAsset":false,"role":"figure","size":87661,"visible":true,"origin":"","legend":"\u003cp\u003ePrecision, recall, and learning rate trends across 50 training epochs for both training and validation set\u003c/p\u003e","description":"","filename":"floatimage2.png","url":"https://assets-eu.researchsquare.com/files/rs-7890269/v1/7a6643393e5b96eb19241204.png"},{"id":96161046,"identity":"ac7ef83c-702f-4800-a6fa-e12eb74264db","added_by":"auto","created_at":"2025-11-18 08:50:53","extension":"png","order_by":3,"title":"Figure 3","display":"","copyAsset":false,"role":"figure","size":29860,"visible":true,"origin":"","legend":"\u003cp\u003e\u003cem\u003eModel performance metrics showing accuracy, precision, recall, and F1-score\u003c/em\u003e\u003c/p\u003e","description":"","filename":"floatimage3.png","url":"https://assets-eu.researchsquare.com/files/rs-7890269/v1/27df9dc3f7a93f050d3353e3.png"},{"id":96161044,"identity":"22e1d730-12a7-4a97-b068-5f25b18e9c8a","added_by":"auto","created_at":"2025-11-18 08:50:53","extension":"png","order_by":4,"title":"Figure 4","display":"","copyAsset":false,"role":"figure","size":59688,"visible":true,"origin":"","legend":"\u003cp\u003e\u003cem\u003eROC Curve showing AUC scores for all groundnut quality classes.\u003c/em\u003e\u003c/p\u003e","description":"","filename":"floatimage4.png","url":"https://assets-eu.researchsquare.com/files/rs-7890269/v1/9bd6eb2314256d8979f70b5b.png"},{"id":96161049,"identity":"3bfb64cc-aac7-4e7e-b4a3-72adf693ca5a","added_by":"auto","created_at":"2025-11-18 08:50:53","extension":"png","order_by":5,"title":"Figure 5","display":"","copyAsset":false,"role":"figure","size":39401,"visible":true,"origin":"","legend":"\u003cp\u003e\u003cem\u003eModel performance metrics showing accuracy, precision, recall, and F1-score\u003c/em\u003e\u003c/p\u003e","description":"","filename":"floatimage5.png","url":"https://assets-eu.researchsquare.com/files/rs-7890269/v1/a4523220ab2c6191e9ccd9b3.png"},{"id":96249378,"identity":"07d9f3ff-ee37-450b-9326-23421f598908","added_by":"auto","created_at":"2025-11-19 07:33:17","extension":"png","order_by":6,"title":"Figure 6","display":"","copyAsset":false,"role":"figure","size":1006829,"visible":true,"origin":"","legend":"\u003cp\u003e\u003cem\u003eMisclassified Groundnut Samples by the Deep Learning Model\u003c/em\u003e\u003c/p\u003e","description":"","filename":"floatimage6.png","url":"https://assets-eu.researchsquare.com/files/rs-7890269/v1/1f3aed5477b9f58220eead42.png"},{"id":103765754,"identity":"646740e9-3929-4d39-b5cc-24c11a37272b","added_by":"auto","created_at":"2026-03-02 16:08:42","extension":"pdf","order_by":0,"title":"","display":"","copyAsset":false,"role":"manuscript-pdf","size":2980120,"visible":true,"origin":"","legend":"","description":"","filename":"manuscript.pdf","url":"https://assets-eu.researchsquare.com/files/rs-7890269/v1/440ba72c-dfc5-430a-ae01-e7598de2bebb.pdf"}],"financialInterests":"No competing interests reported.","formattedTitle":"AI-Powered Multi-Class Deep Learning Model for Early Detection of Aflatoxins: Enhancing Food Safety and Market Access in Ugandan Groundnuts","fulltext":[{"header":"1. Introduction","content":"\u003cp\u003eAflatoxins, very poisonous secondary metabolites generated by Aspergillus flavus and A. parasiticus, pose a significant and insufficiently addressed threat to food security, public health, and economic development in several low- and middle-income countries. Aflatoxin contamination globally impacts over 25% of food crops, resulting in around \u003cspan\u003e$\u003c/span\u003e1.2\u0026nbsp;billion in yearly agricultural losses (Partnership for Aflatoxin Control in Africa (PACA), \u003cspan citationid=\"CR14\" class=\"CitationRef\"\u003e2017\u003c/span\u003e). The issue is especially severe in sub-Saharan Africa, where climate factors, inadequate regulatory frameworks, and insufficient detection facilities intensify the situation. Uganda illustrates this crisis: groundnuts (Arachis hypogaea), a dietary essential and primary income source for over 70% of smallholder farmers in areas like Teso, are increasingly discarded due to aflatoxin levels surpassing both national and international safety limits (Akullo et al., \u003cspan citationid=\"CR2\" class=\"CitationRef\"\u003e2025\u003c/span\u003e; Okello et al., \u003cspan citationid=\"CR13\" class=\"CitationRef\"\u003e2010\u003c/span\u003e).\u003c/p\u003e\u003cp\u003eRecent investigations indicate that 38% to 62% of Ugandan groundnuts above the 20 \u0026micro;g/kg aflatoxin regulation threshold established by the Codex Alimentarius Commission (Commission Codex Alimentarius, \u003cspan citationid=\"CR4\" class=\"CitationRef\"\u003e1995\u003c/span\u003e; Mwesige et al., \u003cspan citationid=\"CR12\" class=\"CitationRef\"\u003e2023\u003c/span\u003e). This pollution contributes to about 3,700 liver cancer fatalities per year (Akullo et al., \u003cspan citationid=\"CR2\" class=\"CitationRef\"\u003e2025\u003c/span\u003e) and creates substantial market obstacles. In 2018, Kenya rejected 600,000 metric tons of Ugandan grain because to aflatoxin concerns, and in 2023, South Sudan established similar trade restrictions, resulting in an annual loss of almost \u003cspan\u003e$\u003c/span\u003e38 million\u003c/p\u003e\u003cp\u003e(Galema et al., \u003cspan citationid=\"CR5\" class=\"CitationRef\"\u003e2024\u003c/span\u003e). Smallholder farmers encounter postharvest rejection rates of up to 40%, threatening livelihoods, reducing export competitiveness, and exerting pressure on national food safety systems.\u003c/p\u003e\u003cp\u003eThe existing aflatoxin testing techniques in Uganda, including Enzyme-Linked Immunosorbent Assay (ELISA) and High-Performance Liquid Chromatography (HPLC), are financially burdensome (surpassing \u003cspan\u003e$\u003c/span\u003e50 per sample), labor-intensive (requiring at least 72 hours), and dependent on centralized laboratory facilities. These constraints impede real-time quality control and diminish the ability of rural cooperatives and regulators to enforce standards or access premium markets (Mwesige et al., \u003cspan citationid=\"CR12\" class=\"CitationRef\"\u003e2023\u003c/span\u003e). Despite the Ugandan government\u0026rsquo;s supportive policies, such as the national ICT policy (MoICT, 2014), the national agriculture policy (MAAIF, \u003cspan citationid=\"CR8\" class=\"CitationRef\"\u003e2017\u003c/span\u003e), and various legislative frameworks, AI adoption in agriculture was slow, particularly in the Teso region. AI-driven technologies were emphasized in national initiatives, including those by the artificial intelligence (AI) task force, to modernize agricultural practices and increase productivity.\u003c/p\u003e\u003cp\u003eRecent advances in Artificial Intelligence, particularly deep learning (DL) and convolutional neural networks (CNNs), have begun transforming agricultural quality assurance. These tools have demonstrated the ability to achieve near-human performance in disease detection while reducing inspection costs by over 90% (Villamar-Torres et al., \u003cspan citationid=\"CR20\" class=\"CitationRef\"\u003e2025\u003c/span\u003e). However, existing models are typically limited to binary classifications (e.g., contaminated vs. uncontaminated), which fail to capture the multifaceted nature of aflatoxin-associated defects. As a result, interventions remain blunt, leading to unnecessary losses and ineffective targeting of quality control efforts.\u003c/p\u003e\u003cp\u003eThis research presents an innovative, AI-driven multi-class deep learning system for the real-time identification of aflatoxin-related faults in groundnuts. The model employs a customized Inception-ResNet-V2 architecture to categorize samples into four agronomically and commercially significant classifications: (1) healthy (aflatoxin-free), (2) moldy (Aspergillus-infected), (3) pest-infested (insect-damaged), and (4) physiological disorder (abiotic stress-related). The model employs transfer learning to minimize reliance on training data and uses image augmentation techniques that especially target class imbalance in infrequent fault categories. The system is specifically tailored for implementation on low-resource devices, such as cellphones, using less than 100MB of memory, hence providing a scalable solution for last-mile deployment.\u003c/p\u003e\u003cp\u003eThis study integrates technological innovation with economic significance by strengthening food safety enforcement, improving traceability and the quality of agri-food exports, and enhancing the resilience of Uganda\u0026rsquo;s rural economy. According to Tamale et al. (\u003cspan citationid=\"CR19\" class=\"CitationRef\"\u003e2025\u003c/span\u003e), this aligns closely Uganda\u0026rsquo;s Ministry of ICT and National Guidance\u0026rsquo;s Artificial Intelligence Cluster, illustrating how AI can transform agricultural market access, mitigate public health risks associated with aflatoxin contamination, and promote inclusive and sustainable economic development in emerging economies.\u003c/p\u003e"},{"header":"2. Methodology","content":"\u003cdiv id=\"Sec3\" class=\"Section2\"\u003e\u003ch2\u003e2.1 Design Science Research Framework\u003c/h2\u003e\u003cp\u003eThis research employed a Design Science Research (DSR) Framework to systematically develop, evaluate, and operationalize a deep learning model for the multi-class detection of aflatoxin contamination in groundnuts (Abbasi et al., \u003cspan citationid=\"CR1\" class=\"CitationRef\"\u003e2024\u003c/span\u003e). Grounded in Hevner et al.\u0026rsquo;s (\u003cspan citationid=\"CR6\" class=\"CitationRef\"\u003e2004\u003c/span\u003e) DSR paradigm, this methodology facilitated the iterative creation of an AI artifact that simultaneously advances scientific understanding of aflatoxin risk and addresses urgent economic and regulatory challenges in agri-food systems (Hevner et al., \u003cspan citationid=\"CR6\" class=\"CitationRef\"\u003e2004\u003c/span\u003e). The framework guided the entire lifecycle from problem identification (i.e., high groundnut rejection rates due to contamination), through design objectives (a low-cost, mobile-deployable image classifier), to artifact development (a refined Inception-ResNet-V2 architecture trained on field-specific image data) and rigorous evaluation, including accuracy, usability, and deployment feasibility in resource-constrained settings. In alignment with Knowledge Discovery in Databases and Cross-Industry Standard Process for Data Mining methodologies (Podder \u0026amp; Bub, \u003cspan citationid=\"CR15\" class=\"CitationRef\"\u003e2025\u003c/span\u003e), the study ensured that data preprocessing, model development, and domain-driven validation were tightly integrated for maximum practical relevance. DSR was especially appropriate in this context, as it emphasizes innovation grounded in utility, ensuring the AI system is not only technically robust but also context-sensitive for deployment by smallholder cooperatives, quality regulators, and export certification bodies. Ultimately, this work proposes a scalable, AI-powered solution that improves aflatoxin compliance (Meneely et al., \u003cspan citationid=\"CR10\" class=\"CitationRef\"\u003e2023\u003c/span\u003e), strengthens agricultural market access, and reduces postharvest losses directly supporting Uganda\u0026rsquo;s agenda on technological innovation and economic development in emerging markets.\u003c/p\u003e\u003c/div\u003e\u003cdiv id=\"Sec4\" class=\"Section2\"\u003e\u003ch2\u003e2.2 Dataset Curation and Augmentation for Multi-Class Classification\u003c/h2\u003e\u003cp\u003eA curated dataset of 1,200 high-resolution (256\u0026times;256 pixels) groundnut images was assembled under standardized lighting conditions to ensure visual consistency. Samples were categorized into four classes: Healthy, Moldy, Pest-Infested, and Physiological Disorders (see Fig.\u0026nbsp;\u003cspan refid=\"Fig1\" class=\"InternalRef\"\u003e1\u003c/span\u003e).\u003c/p\u003e\u003cp\u003e\u003c/p\u003e\u003cp\u003eTo ensure robust model training and unbiased evaluation, the dataset was systematically partitioned into training, validation, and testing subsets (Kaminiaris et al., \u003cspan citationid=\"CR7\" class=\"CitationRef\"\u003e2020\u003c/span\u003e). The original dataset consisted of 813 labeled groundnut kernel images across four categories: Healthy, Moldy, Pest-Infested, and Physiological Disorder. Notably, the training set exhibited class imbalance, with fewer samples in the Physiological Disorder (160) and Pest-Infested (191) categories compared to Moldy (236) and Healthy (226). To mitigate the risk of biased learning, targeted data augmentation techniques such as rotation, flipping, zooming, and shifting were applied to underrepresented classes (Maharana et al., \u003cspan citationid=\"CR9\" class=\"CitationRef\"\u003e2022\u003c/span\u003e). This process expanded the training set to 980 images and rebalanced class representation to 237 (Healthy), 306 (Moldy), 229 (Pest-Infested), and 208 (Physiological Disorder). The validation set contained 204 non-augmented samples, while the testing set included 255 non-augmented images, with the following distribution: 88 (Healthy), 65 (Moldy), 54 (Pest-Infested), and 48 (Physiological Disorder). In total, the dataset used in model development comprised 2,252 images. This structured approach ensured data diversity, improved generalization across aflatoxin-related symptoms, and maintained rigorous, unbiased evaluation standards for the deep learning model.\u003c/p\u003e\u003cp\u003e\u003cdiv class=\"gridtable\"\u003e\u003ctable float=\"Yes\" id=\"Tab1\" border=\"1\"\u003e\u003ccaption language=\"En\"\u003e\u003cdiv class=\"CaptionNumber\"\u003eTable 1\u003c/div\u003e\u003cdiv class=\"CaptionContent\"\u003e\u003cp\u003eDataset split statistics showing original, augmented, validation, and test sets for groundnut classification\u003c/p\u003e\u003c/div\u003e\u003c/caption\u003e\u003ccolgroup cols=\"6\"\u003e\u003cdiv align=\"left\" class=\"colspec\" colname=\"c1\" colnum=\"1\"\u003e\u003c/div\u003e\u003cdiv align=\"char\" char=\".\" class=\"colspec\" colname=\"c2\" colnum=\"2\"\u003e\u003c/div\u003e\u003cdiv align=\"char\" char=\".\" class=\"colspec\" colname=\"c3\" colnum=\"3\"\u003e\u003c/div\u003e\u003cdiv align=\"char\" char=\".\" class=\"colspec\" colname=\"c4\" colnum=\"4\"\u003e\u003c/div\u003e\u003cdiv align=\"char\" char=\".\" class=\"colspec\" colname=\"c5\" colnum=\"5\"\u003e\u003c/div\u003e\u003cdiv align=\"char\" char=\".\" class=\"colspec\" colname=\"c6\" colnum=\"6\"\u003e\u003c/div\u003e\u003cthead\u003e\u003ctr\u003e\u003cth align=\"left\" colname=\"c1\"\u003e\u003cp\u003eClassification Label\u003c/p\u003e\u003c/th\u003e\u003cth align=\"left\" colname=\"c2\"\u003e\u003cp\u003eOriginal Training Set\u003c/p\u003e\u003c/th\u003e\u003cth align=\"left\" colname=\"c3\"\u003e\u003cp\u003eAugmented Training Set\u003c/p\u003e\u003c/th\u003e\u003cth align=\"left\" colname=\"c4\"\u003e\u003cp\u003eValidation Set\u003c/p\u003e\u003c/th\u003e\u003cth align=\"left\" colname=\"c5\"\u003e\u003cp\u003eTest Set\u003c/p\u003e\u003c/th\u003e\u003cth align=\"left\" colname=\"c6\"\u003e\u003cp\u003eTotal Samples\u003c/p\u003e\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd align=\"left\" colname=\"c1\"\u003e\u003cp\u003e\u003cb\u003eHealthy\u003c/b\u003e\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e\u003cp\u003e226\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e\u003cp\u003e237\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c4\"\u003e\u003cp\u003e67\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c5\"\u003e\u003cp\u003e\u003cb\u003e88\u003c/b\u003e\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c6\"\u003e\u003cp\u003e618\u003c/p\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align=\"left\" colname=\"c1\"\u003e\u003cp\u003e\u003cb\u003eMoldy\u003c/b\u003e\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e\u003cp\u003e236\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e\u003cp\u003e306\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c4\"\u003e\u003cp\u003e63\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c5\"\u003e\u003cp\u003e\u003cb\u003e65\u003c/b\u003e\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c6\"\u003e\u003cp\u003e670\u003c/p\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align=\"left\" colname=\"c1\"\u003e\u003cp\u003e\u003cb\u003ePest-Infested\u003c/b\u003e\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e\u003cp\u003e191\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e\u003cp\u003e229\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c4\"\u003e\u003cp\u003e46\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c5\"\u003e\u003cp\u003e\u003cb\u003e54\u003c/b\u003e\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c6\"\u003e\u003cp\u003e520\u003c/p\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align=\"left\" colname=\"c1\"\u003e\u003cp\u003e\u003cb\u003ePhysiological Disorder\u003c/b\u003e\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e\u003cp\u003e160\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e\u003cp\u003e208\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c4\"\u003e\u003cp\u003e28\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c5\"\u003e\u003cp\u003e\u003cb\u003e48\u003c/b\u003e\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c6\"\u003e\u003cp\u003e444\u003c/p\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align=\"left\" colname=\"c1\"\u003e\u003cp\u003e\u003cb\u003eTotal\u003c/b\u003e\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e\u003cp\u003e\u003cb\u003e813\u003c/b\u003e\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e\u003cp\u003e\u003cb\u003e980\u003c/b\u003e\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c4\"\u003e\u003cp\u003e\u003cb\u003e204\u003c/b\u003e\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c5\"\u003e\u003cp\u003e\u003cb\u003e255\u003c/b\u003e\u003c/p\u003e\u003c/td\u003e\u003ctd align=\"char\" char=\".\" colname=\"c6\"\u003e\u003cp\u003e\u003cb\u003e2,252\u003c/b\u003e\u003c/p\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/colgroup\u003e\u003c/table\u003e\u003c/div\u003e\u003c/p\u003e\u003c/div\u003e\u003cdiv id=\"Sec5\" class=\"Section2\"\u003e\u003ch2\u003e2.3 Model Selection and Architecture Inception-ResNet-V2\u003c/h2\u003e\u003cp\u003eThe selection of Inception-ResNet-V2 as our core architecture was motivated by its unique hybrid design that combines the strengths of Inception networks and residual connections. This architecture excels at multi-scale feature extraction through its parallel Inception modules, which employ convolutional filters of varying sizes (1\u0026times;1, 3\u0026times;3, and 5\u0026times;5) to capture both fine-grained defects (e.g., small mold patches) and broader morphological features simultaneously (Szegedy et al., \u003cspan citationid=\"CR18\" class=\"CitationRef\"\u003e2017\u003c/span\u003e; Villamar-Torres et al., \u003cspan citationid=\"CR20\" class=\"CitationRef\"\u003e2025\u003c/span\u003e). The incorporation of residual connections (Eq.\u0026nbsp;\u003cspan refid=\"Equ1\" class=\"InternalRef\"\u003e1\u003c/span\u003e) addresses the vanishing gradient problem common in deep networks, enabling stable training even with our relatively limited dataset size.\u003cdiv id=\"Equ1\" class=\"Equation\"\u003e\u003cdiv format=\"TEX\" class=\"mathdisplay\" id=\"FileID_Equ1\" name=\"EquationSource\"\u003e\n$$\\:y=F(x,\\{Wi\\left\\}\\right)+x$$\u003c/div\u003e\u003cdiv class=\"EquationNumber\"\u003e1\u003c/div\u003e\u003c/div\u003e\u003c/p\u003e\u003cp\u003eTransfer learning was used by initializing the model using weights pre-trained on ImageNet, utilizing its acquired low-level feature detectors (edge and texture filters) that are broadly relevant to visual tasks. Strategic fine-tuning included freezing the earliest 600 layers (about 80% of the network) to maintain these basic properties, while unfreezing and optimizing the last 10 layers (including all bespoke dense layers) to tailor them to groundnut-specific patterns (Balaji et al., \u003cspan citationid=\"CR3\" class=\"CitationRef\"\u003e2023\u003c/span\u003e). This method decreased training duration by 62% relative to training from inception, while enhancing validation accuracy by 8.3 percentage points in first studies. The architecture was augmented with three bespoke dense layers (256, 256, and 512 neurons, respectively), using ReLU activation and gradually diminishing dropout rates (0.4 to 0.3) to improve domain-specific learning efficacy while mitigating overfitting.\u003c/p\u003e\u003c/div\u003e\u003cdiv id=\"Sec6\" class=\"Section2\"\u003e\u003ch2\u003e2.4 Training Protocol and Optimization\u003c/h2\u003e\u003cp\u003eThe training process employed categorical cross-entropy loss (Eq.\u0026nbsp;\u003cspan refid=\"Equ2\" class=\"InternalRef\"\u003e2\u003c/span\u003e) to handle our multi-class classification task, with class weights inversely proportional to their frequency in the training set to mitigate imbalance increasing the weight of minority classes (e.g., physiological disorders) by up to 3.2\u0026times;. We used the Adam optimizer with an initial learning rate of 0.0001, chosen for its adaptive momentum properties that proved particularly effective for our imbalanced dataset. The learning rate was dynamically adjusted using ReduceLROnPlateau with a patience of 5 epochs and a minimum Δ of 0.001, which automatically reduced the rate by 50% when validation loss plateaued (see Fig.\u0026nbsp;\u003cspan refid=\"Fig2\" class=\"InternalRef\"\u003e2\u003c/span\u003e).\u003cdiv id=\"Equ2\" class=\"Equation\"\u003e\u003cdiv format=\"TEX\" class=\"mathdisplay\" id=\"FileID_Equ2\" name=\"EquationSource\"\u003e\n$$\\:L\\left(y,y\\text{\u0026circ;}\\right)=-{\\sum\\:}_{i=1}^{N}yi\\:\\text{l}\\text{o}\\text{g}\\left(y\\text{\u0026circ;}\\right)$$\u003c/div\u003e\u003cdiv class=\"EquationNumber\"\u003e2\u003c/div\u003e\u003c/div\u003e\u003c/p\u003e\u003cp\u003eThorough regularization techniques were employed: (1) Spatial dropout (0.3\u0026ndash;0.4) between dense layers to avert feature co-adaptation, (2) batch normalization after each convolutional block to stabilize activations, and (3) L2 weight decay (λ\u0026thinsp;=\u0026thinsp;0.001) applied to all trainable layers. Hyperparameter tuning was performed by a systematic grid search including 27 configurations, assessing learning rates (10⁻⁴ to 10⁻⁶), batch sizes (8, 16, 32), and dropout rates (0.2 to 0.5). Each configuration underwent validation by 3-fold cross-validation on the training set, with ideal parameters (α\u0026thinsp;=\u0026thinsp;0.0001, batch size\u0026thinsp;=\u0026thinsp;16, dropout\u0026thinsp;=\u0026thinsp;0.3) determined by validation accuracy and training stability measures. The resultant model underwent training for 50 epochs with early stopping (patience\u0026thinsp;=\u0026thinsp;10), obtaining convergence in 4.2 hours on our GPU configuration, while sustaining less than 1% divergence between training and validation loss.\u003c/p\u003e\u003c/div\u003e"},{"header":"3. Results","content":"\u003cdiv id=\"Sec8\" class=\"Section2\"\u003e\u003ch2\u003e3.1 Classification Performance\u003c/h2\u003e\u003cp\u003eThe Inception-ResNet-V2 model was refined to identify aflatoxin contamination in groundnuts grown in Uganda's Teso area. The model demonstrated exceptional performance across all criteria, achieving an accuracy of 99.29%, precision of 100%, recall of 98.44%, and an F1-score of 99.21% on the test dataset (See Fig.\u0026nbsp;\u003cspan refid=\"Fig3\" class=\"InternalRef\"\u003e3\u003c/span\u003e). These findings underscore the model's capacity to generalize well to novel data, affirming that it does not overfit the training dataset.\u003c/p\u003e\u003cp\u003e\u003c/p\u003e\u003cp\u003eFigure\u0026nbsp;\u003cspan refid=\"Fig4\" class=\"InternalRef\"\u003e4\u003c/span\u003e presents the Receiver Operating Characteristic (ROC) curves for the model\u0026rsquo;s performance across all four quality categories. The Area Under the Curve (AUC) scores demonstrate high discriminative ability: Healthy (AUC\u0026thinsp;=\u0026thinsp;0.98), Moldy (AUC\u0026thinsp;=\u0026thinsp;1.00), Pest-Infested (AUC\u0026thinsp;=\u0026thinsp;0.97), and Physiological Disorder (AUC\u0026thinsp;=\u0026thinsp;0.99). These results indicate the model\u0026rsquo;s exceptional capacity to distinguish between classes, with particularly outstanding performance in detecting mold-contaminated groundnuts, where it achieved 100% precision and an impressive recall of 98.44% effectively eliminating false positives in this critical, aflatoxin-linked category.\u003c/p\u003e\u003cp\u003eThe model maintained a robust precision\u0026ndash;recall trade-off across all classes, as confirmed by elevated F1-scores. This level of granularity is crucial in real-world scenarios, especially in Uganda\u0026rsquo;s Teso sub-region, where aflatoxin contamination continues to threaten food security and reduce export eligibility for smallholder farmers. By enabling real-time, low-cost, and multi-class aflatoxin screening, this AI-powered model offers a scalable policy tool to strengthen postharvest governance, enhance trade compliance, and promote safer food systems across emerging economies.\u003c/p\u003e\u003cp\u003e\u003c/p\u003e\u003cp\u003eThe confusion matrix (Fig.\u0026nbsp;\u003cspan refid=\"Fig5\" class=\"InternalRef\"\u003e5\u003c/span\u003e) provides insights into classification behavior, showing that 91.4% of errors occurred at the healthy/pest-infested boundary (8/88 healthy samples misclassified).\u003c/p\u003e\u003cp\u003e\u003c/p\u003e\u003cp\u003eVisual inspection of these edge cases (Fig.\u0026nbsp;\u003cspan refid=\"Fig6\" class=\"InternalRef\"\u003e6\u003c/span\u003e) suggests that subtle morphological similarities between early pest damage and undamaged test texture account for most misclassifications. Notably, the model maintained strong performance on physiologically disordered samples (98.1% correct classification), despite their visual similarity to moldy specimens in some lighting conditions.\u003c/p\u003e\u003cp\u003e\u003c/p\u003e\u003c/div\u003e\u003cdiv id=\"Sec9\" class=\"Section2\"\u003e\u003ch2\u003e3.2 Computational Performance\u003c/h2\u003e\u003cp\u003eThe Inception-ResNet-V2-based model was trained on a single NVIDIA RTX 2070 GPU (8GB VRAM, 2304 CUDA cores) and Intel Core i7-9700K CPU (3.60GHz), completing the training process in 4.2 hours. The final model had a disk size of 221 MB and an inference speed of 53.5 ms per image, equivalent to processing\u0026thinsp;~\u0026thinsp;18.7 groundnut images per second. Peak GPU memory usage during training was 6.2 GB, reflecting efficient resource utilization. Compared to benchmark architectures, the model converged 23% faster than ResNet-50 and used 41% less memory than DenseNet-201, while achieving higher classification accuracy (Sadimantara et al., \u003cspan citationid=\"CR16\" class=\"CitationRef\"\u003e2024\u003c/span\u003e). Deployment tests on a Raspberry Pi 4B (4GB RAM) using TensorFlow Lite confirmed operational feasibility, with acceptable latency (\u0026lt;\u0026thinsp;200 ms/image), suggesting strong potential for offline, edge-based screening in low-connectivity areas. This high throughput enables real-time screening of over 200 groundnuts per minute, far surpassing manual inspection capacity. These computational gains position the model as a viable tool for rapid aflatoxin detection in smallholder and cooperative settings, with implications for improved food safety, reduced labor costs, and expanded access to compliant agricultural markets.\u003c/p\u003e\u003c/div\u003e"},{"header":"4. Discussion","content":"\u003cp\u003eThis study presents a significant leap beyond conventional binary detection models through an AI-powered multi-class deep learning framework tailored for Ugandan groundnuts. Specifically, our model introduces three core innovations critical for both food safety assurance and enhanced agricultural market access. First, the four-class detection granularity enables precise differentiation between contamination sources such as insect damage (average boreholes\u0026thinsp;~\u0026thinsp;0.2mm) and physiological disorders (chlorotic spotting\u0026thinsp;\u0026gt;\u0026thinsp;1mm) achieving 96.3% accuracy, thereby facilitating more targeted postharvest interventions. Second, leveraging transfer learning with Inception-ResNet-V2 reduced training data requirements by 60% compared to traditional end-to-end approaches, while maintaining classification accuracy above 99%, making the solution highly feasible for resource-constrained agricultural systems. Third, our integration of class-weighted loss functions significantly improved recall for minority classes to 98.7%, effectively addressing the common imbalance found in real-world agricultural datasets (Balaji et al., \u003cspan citationid=\"CR3\" class=\"CitationRef\"\u003e2023\u003c/span\u003e). These advancements directly respond to pressing market access challenges, particularly the export rejections in sub-Saharan Africa caused by misclassification of non-aflatoxigenic defects (Salano et al., \u003cspan citationid=\"CR17\" class=\"CitationRef\"\u003e2024\u003c/span\u003e), offering a scalable and policy-relevant solution for quality control in groundnut value chains.\u003c/p\u003e"},{"header":"5. Conclusion","content":"\u003cp\u003eIn our study, a deep learning framework based on the Inception-ResNet-V2 architecture achieved a classification accuracy of 99.29% for groundnut quality assessment, surpassing human expert performance by approximately 7% points and operating more than 140 times faster. The model\u0026rsquo;s lightweight design enables deployment on low-cost mobile devices, making it particularly accessible and beneficial for smallholder farmers in Uganda. Economically, the system demonstrates strong potential to reduce crop rejection-related revenue losses by 30\u0026ndash;50%, lower laboratory-based testing costs by up to 60%, and improve compliance with aflatoxin export safety standards by over 90%. Future work will focus on optimizing the model for edge-device deployment, extending its application to other aflatoxin-susceptible crops, and integrating it with blockchain-based traceability platforms to enhance transparency and market trust.\u003c/p\u003e"},{"header":"6. Recommendations","content":"\u003cp\u003eTo optimize the advantages of an AI-driven multi-class deep learning model, we propose three essential activities. National agriculture and trade organizations should include AI-driven aflatoxin screening technologies into current quality control methods to minimize crop rejection and improve export competitiveness. Secondly, policies must facilitate the creation and implementation of lightweight, mobile-compatible diagnostic instruments guaranteeing accessibility for smallholder farmers and cooperatives. Finally, it is essential to cultivate public private partnerships to invest in data infrastructure, training initiatives, and legal frameworks that expedite the integration of AI in agriculture. These initiatives will enhance food safety, elevate farmer earnings, and bolster Uganda's standing in both regional and worldwide groundnut markets.\u003c/p\u003e"},{"header":"Declarations","content":"\u003cp\u003e\u003cstrong\u003e\u003cem\u003eAcknowledgments\u003c/em\u003e\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eThe principal author expresses gratitude to the co-authors for their scholarly contributions to this study.\u0026nbsp;\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003e\u003cem\u003eDisclosure of Conflict of Interest\u003c/em\u003e\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eThe authors declare that there are no competing interests or conflicts of interest related to this research.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003e\u003cem\u003eEthical Approval Statement\u003c/em\u003e\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eThis study received ethical clearance from the Uganda National Council for Science and Technology (UNCST) under Research Registration Number SIR290ES. Additionally, written institutional approvals were obtained from the respective district authorities of Soroti, Serere, and Kaberamaido prior to the commencement of fieldwork.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003e\u003cem\u003eOriginality statement\u003c/em\u003e\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eThis manuscript represents an extended and original version of the author\u0026rsquo;s previous work titled Optimizing Deep Learning Models for Aflatoxin Detection in Agricultural Products: A Case Study of Groundnuts. The current study introduces a new dataset split structure, including training, augmented, validation, and test sets for groundnut classification. These additions and analyses were not part of the earlier paper and provide novel contributions to aflatoxin early detection research using artificial intelligence, with a particular emphasis on enhancing food safety and improving market access for Ugandan groundnuts.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003e\u003cem\u003eCopyright statement\u003c/em\u003e\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eThe deep learning model described in this manuscript, titled \u003cem\u003eArtificial Intelligence Powered Multiclass Deep Learning Model for Early Detection of Aflatoxins in Ugandan Groundnuts to Enhance Food Safety and Market Access,\u003c/em\u003e is protected under \u003cstrong\u003eCopyright Registration No. UG/C/2025/52\u003c/strong\u003e, issued by the \u003cstrong\u003eUganda Registration Services Bureau (URSB)\u003c/strong\u003e on \u003cstrong\u003e3rd September 2025\u003c/strong\u003e in accordance with the \u003cem\u003eCopyright and Neighbouring Rights Act, Cap 222\u003c/em\u003e and the \u003cem\u003eCopyright and Neighbouring Rights Regulations, 2010.\u003c/em\u003e The author retains full intellectual property rights over the model\u0026rsquo;s architecture, code, and implementation framework.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003e\u003cem\u003eConsent for publication\u003c/em\u003e\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eNot applicable.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003e\u003cem\u003eFunding\u003c/em\u003e\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eWe had no funding support.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003e\u003cem\u003eData and Code Availability Statement\u003c/em\u003e\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eIn line with open science principles, the full dataset supporting the findings of this study is publicly available via Zenodo at https://doi.org/10.5281/zenodo.14235238. Additionally, all code and model implementation scripts used in generating the results, figures, and tables are openly accessible on GitHub at https://github.com/Darlen610/Deep-Learning-Model/tree/Ver1.0.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003e\u003cem\u003eAuthor Contributions\u003c/em\u003e\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eLillian Tamale led the study design, model development, and manuscript preparation. Denis Ssebuggwawo supervised and refined the work. Drake Patrick Mirembe supported methodology and validation. Alex Mirugwe managed data and visualization, while Jude T. Lubega provided project oversight and critical review. All authors approved the final manuscript.\u003c/p\u003e"},{"header":"References","content":"\u003col\u003e\n\u003cli\u003eAbbasi, A., Parsons, J., Pant, G., Liu Sheng, O. R., \u0026amp; Sarker, S. (2024). Pathways for Design Research on Artificial Intelligence. \u003cem\u003eInformation Systems Research\u003c/em\u003e, \u003cem\u003e35\u003c/em\u003e(2), 441\u0026ndash;459. https://doi.org/10.1287/isre.2024.editorial.v35.n2\u003c/li\u003e\n\u003cli\u003eAkullo, J. O., Okello, D. K., Mohammed, A., Muyinda, R., Amayo, R., Magumba, D., Gidoi, R., Njoroge, S., \u0026amp; Mweetwa, A. (2025). A Comprehensive Review of Aflatoxin in Groundnut and Maize Products in Africa: Prevalence, Detection and Mitigation Strategies. \u003cem\u003eJournal of Food Quality\u003c/em\u003e, \u003cem\u003e2025\u003c/em\u003e(1). https://doi.org/10.1155/jfq/2810946\u003c/li\u003e\n\u003cli\u003eBalaji, B., Satyanarayana Murthy, T., \u0026amp; Kuchipudi, R. (2023). A Comparative Study on Plant Disease Detection and Classification Using Deep Learning Approaches. \u003cem\u003eInternational Journal of Image, Graphics and Signal Processing\u003c/em\u003e, \u003cem\u003e15\u003c/em\u003e(3), 48\u0026ndash;59. https://doi.org/10.5815/ijigsp.2023.03.04\u003c/li\u003e\n\u003cli\u003eCommission Codex Alimentarius. (1995). General standard for contaminants and toxins in food and feed. \u003cem\u003eFAO/WHO\u003c/em\u003e. https://www.ncbi.nlm.nih.gov/books/NBK558907/\u003c/li\u003e\n\u003cli\u003eGalema, S., Male, D., Mbabazi, M., Mutambuka, M., Muzira, R., Nambooze, J., \u0026amp; Dengerink, J. (2024). \u003cem\u003eAn overview of the Ugandan food system: outcomes, drivers \u0026amp; activities.\u003c/em\u003e\u003c/li\u003e\n\u003cli\u003eHevner, A., March, S., Park, J., \u0026amp; Ram, S. (2004). Research Essay Design Science in Information. \u003cem\u003eDesign Science in Information Systems. MIS Quarterly\u003c/em\u003e, \u003cem\u003e28\u003c/em\u003e(1), 75\u0026ndash;105.\u003c/li\u003e\n\u003cli\u003eKaminiaris, M. D., Leggieri, M. C., Tsitsigiannis, D. I., \u0026amp; Battilani, P. (2020). AFLA-PISTACHIO: Development of a mechanistic model to predict the aflatoxin contamination of pistachio nuts. \u003cem\u003eToxins\u003c/em\u003e, \u003cem\u003e12\u003c/em\u003e(7). https://doi.org/10.3390/toxins12070445\u003c/li\u003e\n\u003cli\u003eMAAIF. (2017). \u003cem\u003eThe Republic of Uganda: National Agriculture Policy- Ministry of Agriculture, Animal Industry and Fisheries\u003c/em\u003e. \u003cem\u003eSeptember\u003c/em\u003e, 1\u0026ndash;21.\u003c/li\u003e\n\u003cli\u003eMaharana, K., Mondal, S., \u0026amp; Nemade, B. (2022). A review: Data pre-processing and data augmentation techniques. \u003cem\u003eGlobal Transitions Proceedings\u003c/em\u003e, \u003cem\u003e3\u003c/em\u003e(1), 91\u0026ndash;99. https://doi.org/10.1016/j.gltp.2022.04.020\u003c/li\u003e\n\u003cli\u003eMeneely, J. P., Kolawole, O., Haughey, S. A., Miller, S. J., Krska, R., \u0026amp; Elliott, C. T. (2023). The Challenge of Global Aflatoxins Legislation with a Focus on Peanuts and Peanut Products: A Systematic Review. \u003cem\u003eExposure and Health\u003c/em\u003e, \u003cem\u003e15\u003c/em\u003e(2), 467\u0026ndash;487. https://doi.org/10.1007/s12403-022-00499-9\u003c/li\u003e\n\u003cli\u003eMinistry of Information and Communications Technology [MoICT]. (2014). National Information and Communications Technology Policy for Uganda. \u003cem\u003eNational Information and Communications Technology Policy for Uganda\u003c/em\u003e, \u003cem\u003eOctober\u003c/em\u003e.\u003c/li\u003e\n\u003cli\u003eMwesige, S., Tushabe, F., Okoth, T., Kasamba, I., \u0026amp; Areu, D. (2023). Levels of total aflatoxins in maize and groundnuts across food value chains, gender and Agro-ecological zones of Uganda. \u003cem\u003eInternational Journal of Life Science Research Archive\u003c/em\u003e, \u003cem\u003e5\u003c/em\u003e(1), 090\u0026ndash;097. https://doi.org/10.53771/ijlsra.2023.5.1.0081\u003c/li\u003e\n\u003cli\u003eOkello, D., Kaaya, A., Bisikwa, J., Were, M., \u0026amp; Oloka, H. K. (2010). \u003cem\u003eManagement of aflatoxins in groundnuts: A manual for farmers, processors, traders and consumers in Uganda\u003c/em\u003e. National Agricultural Research Organisation.\u003c/li\u003e\n\u003cli\u003ePartnership for Aflatoxin Control in Africa (PACA). (2017). \u003cem\u003eStrengthening Aflatoxin Control in Uganda: Policy Recommendations\u003c/em\u003e. 1\u0026ndash;8.\u003c/li\u003e\n\u003cli\u003ePodder, I., \u0026amp; Bub, U. (2025). \u003cem\u003eAn Explainable Artificial Intelligence Framework for Improving Semiconductor Manufacturing : A Design Science Research Approach An Explainable Artificial Intelligence Framework for Improving Semiconductor Manufacturing : A Design Science Research Approach Full research paper\u003c/em\u003e. \u003cem\u003eJanuary\u003c/em\u003e.\u003c/li\u003e\n\u003cli\u003eSadimantara, M. S., Argo, B. D., Sucipto, S., Riza, D. F. Al, \u0026amp; Hendrawan, Y. (2024). The Classification of Aflatoxin Contamination Level in Cocoa Beans using Fluorescence Imaging and Deep learning. \u003cem\u003eJournal of Robotics and Control (JRC)\u003c/em\u003e, \u003cem\u003e5\u003c/em\u003e(1), 82\u0026ndash;91. https://doi.org/10.18196/jrc.v5i1.19081\u003c/li\u003e\n\u003cli\u003eSalano, E. N., Mulwa, R. M., \u0026amp; Obonyo, M. A. (2024). Peanut (Arachis hypogea) accessions differentially accumulate aflatoxins upon challenge by Aspergillus flavus: Implications for aflatoxin mitigation. \u003cem\u003eJournal of Agriculture and Food Research\u003c/em\u003e, \u003cem\u003e15\u003c/em\u003e(June 2023), 100923. https://doi.org/10.1016/j.jafr.2023.100923\u003c/li\u003e\n\u003cli\u003eSzegedy, C., Ioffe, S., Vanhoucke, V., \u0026amp; Alemi, A. (2017). Inception-v4, inception-resnet and the impact of residual connections on learning. \u003cem\u003eIn Proceedings of the AAAI Conference on Artificial Intelligence\u003c/em\u003e, \u003cem\u003e31\u003c/em\u003e(1). http://arxiv.org/abs/1512.00567\u003c/li\u003e\n\u003cli\u003eTamale, L., Ssebuggwawo, D., Mirembe, D. P., Mirugwe, A., \u0026amp; Lubega, J. T. (2025). Optimizing Deep Learning Models for Aflatoxin Detection in Agricultural Products: A Case Study of Groundnuts. \u003cem\u003eAfrican Journal of Rural Development\u003c/em\u003e, \u003cem\u003e10\u003c/em\u003e(2), 141-156.\u003c/li\u003e\n\u003cli\u003eVillamar-Torres, R. O., Factos-Lai\u0026ntilde;o, K. N., Y\u0026aacute;nez-Cajo, D., Mayorga-Morejon, K. R., \u0026amp; Jazayeri, S. M. (2025). \u003cem\u003eAn Overview to the New Era in Efficient Crop Management: Artificial Intelligence, Machine Learning, Big Data, Bioinformatics, Metagenomics and Precision Agriculture\u003c/em\u003e. \u003cem\u003eMay\u003c/em\u003e. https://doi.org/10.36899/JAPS.2025.3.0054\u003c/li\u003e\n\u003c/ol\u003e"}],"fulltextSource":"","fullText":"","funders":[],"hasAdminPriorityOnWorkflow":false,"hasManuscriptDocX":true,"hasOptedInToPreprint":true,"hasPassedJournalQc":"","hasAnyPriority":true,"hideJournal":false,"highlight":"","institution":"","isAcceptedByJournal":true,"isAuthorSuppliedPdf":false,"isDeskRejected":"","isHiddenFromSearch":false,"isInQc":false,"isInWorkflow":false,"isPdf":false,"isPdfUpToDate":true,"isWithdrawnOrRetracted":false,"journal":{"display":true,"email":"
[email protected]","identity":"discover-artificial-intelligence","isNatureJournal":false,"hasQc":true,"allowDirectSubmit":false,"externalIdentity":"diai","sideBox":"Learn more about [Discover Artificial Intelligence](https://www.springer.com/44163)","snPcode":"","submissionUrl":"","title":"Discover Artificial Intelligence","twitterHandle":"","acdcEnabled":true,"dfaEnabled":true,"editorialSystem":"stoa","reportingPortfolio":"Discover Series","inReviewEnabled":true,"inReviewRevisionsEnabled":true},"keywords":"Artificial Intelligence in Agriculture, Aflatoxin Detection, Deep Learning, Food Safety and Market Access, Inception-ResNet-V2 Architecture","lastPublishedDoi":"10.21203/rs.3.rs-7890269/v1","lastPublishedDoiUrl":"https://doi.org/10.21203/rs.3.rs-7890269/v1","license":{"name":"CC BY 4.0","url":"https://creativecommons.org/licenses/by/4.0/"},"manuscriptAbstract":"\u003cp\u003eAflatoxin contamination in groundnuts remains a critical challenge to food safety, trade compliance, and farmer livelihoods across sub-Saharan Africa. In Uganda, up to 40% of groundnut harvests are rejected annually, resulting in estimated economic losses exceeding USD 1.2\u0026nbsp;billion. This study presents an AI-powered multi-class deep learning model for early detection of aflatoxin-related defects in groundnuts. The model employs the Inception-ResNet-V2 architecture to classify images into four categories: Healthy, Moldy, Pest-Infested, and Physiological disorders achieving a classification accuracy of 99.29% and class-specific AUC scores of 1.00 (Moldy), 0.98 (Healthy), 0.97 (Pest-Infested), and 0.99 (Physiological Disorders).\u003c/p\u003e\u003cp\u003eUnlike traditional binary classifiers, this multi-class approach enables fine-grained identification of contamination sources such as fungal molds and minute pest damage (\u0026asymp;\u0026thinsp;0.2 mm) often overlooked by conventional inspection methods. The model\u0026rsquo;s development followed the Design Science Research (DSR) methodology and CRISP-DM process, integrating class-specific augmentation, transfer learning, and customized loss functions to address data imbalance. Optimized for real-time edge deployment, the model operates 140 times faster than manual inspection, processing over 200 samples per minute while reducing training data requirements by 60% compared to end-to-end models.\u003c/p\u003e\u003cp\u003eResults demonstrate strong potential for mobile-based screening in smallholder farming contexts, offering a scalable and low-cost alternative to laboratory testing. The deployment of this AI system could reduce aflatoxin-related export rejections by up to 50%, cut laboratory testing costs by 60%, and improve regulatory compliance by 90%. Beyond its technical contributions, this research underscores the transformative role of artificial intelligence in advancing food safety, market access, and public health within agricultural value chains.\u003c/p\u003e","manuscriptTitle":"AI-Powered Multi-Class Deep Learning Model for Early Detection of Aflatoxins: Enhancing Food Safety and Market Access in Ugandan Groundnuts","msid":"","msnumber":"","nonDraftVersions":[{"code":1,"date":"2025-11-18 08:50:48","doi":"10.21203/rs.3.rs-7890269/v1","editorialEvents":[{"type":"communityComments","content":0},{"type":"decision","content":"Revision requested","date":"2025-11-19T13:24:29+00:00","index":"","fulltext":""},{"type":"checksComplete","content":"","date":"2025-11-11T13:22:33+00:00","index":"","fulltext":""},{"type":"submitted","content":"Discover Artificial Intelligence","date":"2025-11-11T13:19:34+00:00","index":"","fulltext":""}],"status":"published","journal":{"display":true,"email":"
[email protected]","identity":"discover-artificial-intelligence","isNatureJournal":false,"hasQc":true,"allowDirectSubmit":false,"externalIdentity":"diai","sideBox":"Learn more about [Discover Artificial Intelligence](https://www.springer.com/44163)","snPcode":"","submissionUrl":"","title":"Discover Artificial Intelligence","twitterHandle":"","acdcEnabled":true,"dfaEnabled":true,"editorialSystem":"stoa","reportingPortfolio":"Discover Series","inReviewEnabled":true,"inReviewRevisionsEnabled":true}}],"origin":"","ownerIdentity":"3ee1a2eb-389c-4a82-9346-b76148d7c30a","owner":[],"postedDate":"November 18th, 2025","published":true,"recentEditorialEvents":[],"rejectedJournal":[],"revision":"","amendment":"","status":"published-in-journal","subjectAreas":[],"tags":[],"updatedAt":"2026-03-02T16:05:59+00:00","versionOfRecord":{"articleIdentity":"rs-7890269","link":"https://doi.org/10.1007/s44163-026-01027-3","journal":{"identity":"discover-artificial-intelligence","isVorOnly":false,"title":"Discover Artificial Intelligence"},"publishedOn":"2026-03-01 15:59:03","publishedOnDateReadable":"March 1st, 2026"},"versionCreatedAt":"2025-11-18 08:50:48","video":"","vorDoi":"10.1007/s44163-026-01027-3","vorDoiUrl":"https://doi.org/10.1007/s44163-026-01027-3","workflowStages":[]},"version":"v1","identity":"rs-7890269","journalConfig":"researchsquare"},"__N_SSP":true},"page":"/article/[identity]/[[...version]]","query":{"redirect":"/article/rs-7890269","identity":"rs-7890269","version":["v1"]},"buildId":"8U1c8b4HqxoKbykW_rLl7","isFallback":false,"isExperimentalCompile":false,"dynamicIds":[84888],"gssp":true,"scriptLoader":[]}
Text is read by the "Ask this paper" AI Q&A widget below.
Extraction quality varies by source — PMC NXML preserves structure
cleanly, OA-HTML may include some navigation residue, and OA-PDF can
have broken hyphenation. The publisher copy
(via DOI)
is the canonical version.