The Classification of Aflatoxin Contamination Level in Cocoa Beans using Fluorescence Imaging and Deep learning

— Aflatoxin contamination in cacao is a significant problem in terms of trade losses and health effects. This calls for the need for a non-invasive, precise, and effective detection strategy. This research contribution is to determine the best deep-learning model to classify the aflatoxin contamination level in cocoa beans based on fluorescence images and deep learning to improve performance in the classification. The process involved inoculating and incubating Aspergillus flavus (6mL/100g) to obtain aflatoxin-contaminated cocoa beans for 7 days during the incubation period. Liquid Mass Chromatography (LCMS) was used to quantify the aflatoxin in order to categorize the images into different levels including “free of aflatoxin”, “contaminated below the limit”, and “contaminated above the limit”. 300 images were acquired through a mini studio equipped with UV lamps. The aflatoxin level was classified using several pre-trained CNN approaches which has high accuracy such as GoogLeNet, SqueezeNet, AlexNet, and ResNet50. The sensitivity analysis showed that the highest classification accuracy was found in the GoogLeNet model with optimizer: Adam and learning rate: 0.0001 by 96.42%. The model was tested using a testing dataset and obtain accuracy of 96% based on the confusion matrix. The findings indicate that combining CNN with fluorescence images improved the ability to classify the amount of aflatoxin contamination in cacao beans. This method has the potential to be more accurate and economical than the current approach, which could be adapted to reduce aflatoxin's negative effects on food safety and cacao trade losses.


INTRODUCTION
Aflatoxin exposure has a significant detrimental impact on consumer health and the global economy.A recent review by [1] estimated that 60% -80% of the world's food crops were contaminated by aflatoxin.Aflatoxin can harm human health, leading to death [2][3], cancer [4][5], immune system disruption [6], and stunted child growth [7][8].Aspergillus flavus produces aflatoxin, a secondary metabolite that thrives in uncontrolled processing and storage condition [9].The contamination needs to be controlled early due to its thermostable nature, which can complicate the removal process from the supply chain [10].This is necessary because of the recent increase in the market awareness of product quality [11] as well as the existence of strict regulations governing the maximum intake of aflatoxin by international institutions such as the 20 ppb limit imposed by the European Commission [12].
One of commodity that can become contaminated with aflatoxin is cocoa [13].Cocoa beans are one of the important commodities in the world as indicated by their retail value reaching USD 100 billion in 2021.The total trade volume of cocoa and its products in the year 2018-2019 was also reported to be $50.9 billion with a 2.12% increase in export value [14].However, several challenges have been identified in relation to the export of cocoa such as the reduction in the quality due to the risk of mycotoxins [15].The detection of aflatoxin was observed to currently rely on the application of chemical approaches involving high costs, destructive processes, sophisticated equipment, and labor expertise [16] such as ELISA [17], HPLC [18], and LCMS [19].Another method is computer vision which involves utilizing different image acquisition technologies such as Color imaging [20], Near-infrared (NIR) Spectroscopy [21][22], Mid-infrared (MIR) Spectroscopy [23][24], Near-infrared (NIR) Hyperspectral Imaging [25][26], and even X-Ray Imaging [27] to detect mycotoxin.However, these image acquisition technologies have some limitations.For instance, color imaging has a limited electromagnetic range, making it unable to detect mycotoxin contamination at an early stage, despite its high detection accuracy of up to 89% [28].Hyperspectral imaging has high accuracy [29] but requires expensive equipment [30].This requires an image acquisition approach that is simple but has high accuracy.Ultraviolet (UV) induced fluorescence imaging is an alternative technique involving the utilization of the excitation-emission properties of fluorescence light.This is possible because every organic material, including aflatoxin, exhibits different fluorescence properties [31].Previous research already showed that aflatoxin has an excitation wavelength of 365 nm and an emission wavelength of 455 nm [32].The fluorescence properties were used in the hyperspectral fluorescence imaging approach to detect the aflatoxin in maize [33].However, this approach requires relatively expensive equipment, necessitating a relatively  [34], 365 nm LEDs were used as the excitation light source in a color camera to capture the optical characteristics of fluorescence images produced by UV light in the visible region.The target fluorophores were observed to have been able to emit in the visible region thereby, enabling the use of simplified imaging techniques.
This indicates that there is potential for using fluorescence imaging in this study.
Convolutional Neural Network (CNN) is an approach commonly used for image classification [35][36][37].This was further confirmed by the findings of recent research that machine learning is increasingly being applied in the field of agriculture, particularly to identify the quality of agricultural products.The phenomenon was associated with the machine learning's capabilities in the classification process, which is a recent development in computer vision [38].Hendrawan [39] classified Indonesian coffee types using a pre-trained network with a testing accuracy of 99.6%.Momeny [40] also employed the Inception-v4 CNN to grade and detect counterfeit saffron with an accuracy of 99.5%.CNNs can not only be used for classifying reflectance images but are also well-suited for handling fluorescence images.The findings of the research support this statement.For example the classification performance of fluorescence images was reported to be better than that of reflectance images, as shown by Wei [41] where fluorescence images had a higher accuracy of 97.5% in the process of classifying tea leaves.This research contribution is to determine the best deeplearning model to classify the aflatoxin contamination level in cocoa beans based on fluorescence images and deep learning to improve performance in the classification.The results are expected to offer an alternative, accurate method for classifying aflatoxin contamination levels in cocoa beans, which possible adapted to reduce aflatoxin's negative effects on food safety and cacao trade losses.

A. Materials
The materials used included pure strain A. flavus (Inacc F44) was collected from Lembaga Ilmu Pengetahuan Indonesia (LIPI) microbiology laboratory, Cibinong, Indonesia.Forastero cocoa beans that had been fermented for 5 days with a shelf life of 3 months in a warehouse from the Pusat Penelitian Kopi dan Kakao, Jember, Indonesia.The fermented beans were unbroken, free of mycotoxin contamination and had a low moisture content of 6%.The chemicals used were aqua dest, NaCl, methanol, alcohol, and potato dextrose broth (PDB) media.
The hardware used was image acquisition mini studio consisting of a Canon EOS 700D DSLR camera with dimensions of 133×100×79 mm, equipped with a PL filter.The camera had 18MP resolution specifications with a CMOS sensor, ISO 100-12800, a shutter speed of 30-1/4000 seconds, and Full HD video.22.3×14.9mm CMOS sensor size.UV Lamp Model: LDR2-100UV3-365-N, input 24V(DC)/23W, manufactured by CCS Inc as a UV light source.The power supply had 30V/5A Specification with code MDB-K305D.A LED Pulse Controller, Brand GARDASOFT with model PP820C, which was equipped with 8 channels that can regulate a maximum current of 20A was used, with an input of 12-48V.A mini studio frame was assembled from several angles with a thickness of 2 mm combined using 10mm nuts and a Lenovo laptop with Intel Core i5-7200u specifications, 2.50GHz CPU 2.71GHz, and 16GB memory.Aflatoxin quantification using Liquid Chromatography Mass Spectrometry (LCMS)/MS brand (Hitachi L 6200).

B. Method
The research's outline stages can be seen in Fig. 1.As seen in Fig. 1, this study uses the inoculation and incubation of A. flavus to produce aflatoxins-contaminated cocoa beans.The fluorescence image acquisition process is carried out and the last step is the implementation of a pre-trained CNN model.The following provides a detailed explanation of each of the aforementioned stages.

1) Fungus Inoculum
Fungal inoculation is carried out to obtain cocoa beans contaminated with aflatoxin.Fungal inoculum was obtained by culturing pure A. flavus in 10 mL of nutrient broth (DIFCO 234000) and incubating it at room temperature for 3 days.In 100 mL of NB media, the culture was revived, re-inoculated, and incubated at room temperature for three more days.To create a stock inoculum for the vaccination of cocoa beans, the resulting culture was then incubated for an additional three days at room temperature in 1000 mL of NB media.60 mL/ kg of cocoa beans were added to the fungal inoculum, which was then incubated with A. flavus at 30° C and 90% RH until day 7.

2) Measurement of Aflatoxin Levels
The concentration of aflatoxin in the samples was measured using LCMS.The LC system consisted of: The Aflatoxin (AF) standard and pure samples were dissolved in 1 ml of mobile phase solution, which was then added to the LCMS/ESI in 6 μL.All of the tested AF contained protons, [M+ H]+, with a residence time of 1,000 ms per ion.The test tube containing the pure sample or the aflatoxin working standard was supplemented with 0.1 mL of trifluoroacetic acid (TFA) for LC analysis.The selected ions (m/z) monitored for the target were 313 for AFB1, 315 for AFB2, 329 for AFG1, and 331 for AFG2 [42].The tube was vortexed, diluted with 0.9 ml of an acetonitrile-water solution (1:9), and allowed to sit in the dark for 15 minutes at room temperature.The resulting solution was then tested for reverse-phase LC analysis using 20 μL.Using electron ionization in multiple reaction monitoring modes, aflatoxin was discovered.The results of the LC/MS-MS data analysis gave the extract's compounds' molecular weight and chromatogram in the form of peaks, allowing for the calculation of how many compounds were total in each sample.For each measurement, three times were performed.

3) Image Acquisition
Canon EOS 700D camera was used to capture images of cocoa beans for up to seven days following the inoculation of A. flavus to obtain images of cocoa beans in 3 different aflatoxin contamination classes (aflatoxin free, below threshold, and above threshold).400×600 pixel JPG files were used to save the generated images, then the image is resized to 224×224 pixels as the input image to the CNN [43].The image was captured in a studio that featured a 365 nm UV LED lamp made by CCS Inc. in Japan.The UV lamp was positioned 350 mm away from the sample unit, emitting 6.9 Wm2 of radiation on average.Additionally, a UV bandpass filter was placed in front of the UV light source and the camera to block out the light that was reflected.It performs similarly to a UV cut filter but only lets 0.3% of 365 nm to pass through.In the subunit of image acquisition, a highresolution CMOS camera of 5×3078 pixels was used, namely the EOS Kiss×7 (Canon Inc., Japan) with ISO 200, F-5.6, and manual exposure of 1/3 second for fluorescence image recording placed 450 mm from the sample location.The image acquisition unit measures 18.5 cm×18.5 cm×29 cm and is connected to the light source through an optic fiber, as shown in Fig. 2.

Fig. 2. Image acquisition unit
Each cocoa bean is spaced approximately 5 cm apart in the arrangement.After seven days of image acquisition, 300 fluorescence images with 12 cocoa beans each were obtained.Based on the findings of the LCMS test, the image is then classified into three classes of contamination.

4) Deep Learning Modeling
The model was created using deep learning to classify the aflatoxin contamination level in cocoa beans.Four different pre-trained CNN types were used in the process: SqueezeNet [44], GoogLeNet [45], ResNet50 [46], and AlexNet [47].The CNN architecture for the classification is presented in the following Fig. 3.As seen in Fig. 3, the cocoa image becomes input to the CNN model and then convolution and pooling are used to extract features.In the fully connected layer, classification is carried out so that the output is three classes of aflatoxin contamination in cocoa beans.Each pre-trained CNN was applied using several parameter settings such as optimizer (Adam, SGDm, RMSProp) [48], initial learning rate = 0.0001 and 0.00005 [49], epoch 20 of minibatch size 20 [50], L2Regularization = 0.00001 [51], momentum = 0 [52], learning rate drop period = 10 [53], and learner drop factor = 0 [54].The value of sequence padding is 0 [55].Padding affects network functionality and has a significant impact on performance and accuracy [56].After validation, the CNN models were tested using 20 new images for each aflatoxin contamination level category.Moreover, the confusion matrix method [36] was used to determine the classification accuracy of the testing dataset in order to evaluate the performance of the CNN models.The architecture of the pre-trained CNN used is presented in the following Fig. 4.
The ability of pre-trained CNNs to expedite and streamline the training process is one of its key advantages.The pre-trained model's weights and features can be used as a starting point and adjusted to particular task, rather than having to be started from scratch [57].Each pre-trained network possess various architectures, parameter counts, and levels of complexity, all of which affect the accuracy and classification rate [58].

A. Quantification of Aflatoxin Level in Cocoa Beans Inoculated with Aspergillus Flavus
In this study analyzed total aflatoxin (AF) which is the total of aflatoxin B1 (AFB1), aflatoxin B2 (AFB2), aflatoxin G1 (AFG1) and aflatoxin (AFG2).The detection limit of the LC-MS/MS test in this research was 1 ppb (part per billion).Samples were considered positively contaminated when the aflatoxin concentration was ≥ Limit of detection (LOD).Fig. 5 indicated that the control did not detect aflatoxin at the limit of Reporting limit (RL) = 1 µg/kg, while the Aflatoxin (AF) inoculation treatment on days 1-7 did not detect AFB2 and AFG2.Furthermore, AFB1 and AFG1 levels increased during the observation period, with AFG1 showing the largest increase in aflatoxin level at 83.10 ppb on day 7, followed by AFB1 at 9.77 ppb on day 7. Aflatoxin level was significantly different in each observation.The higher concentration of AFG1 than AFB1 in this research was in line with [16], where aflatoxins in cocoa beans were analyzed in several regions in Brazil.The results showed an incidence of aflatoxin level in cocoa beans aflatoxin G1 higher than B1.However, some findings revealed that AFB1 and AFG1 levels were equal or AFB1 level was higher than AFG1.Compared to the incidence of aflatoxin contamination in other commodities such as peanuts, various reports obtained a higher level of AFG1 than AFB1 [58], while others detected elevated AFB1 than AFG1 [59] [60].Comparable concentration patterns of Muhammad Syukri Sadimantara, The Classification of Aflatoxin Contamination Level in Cocoa Beans using Fluorescence Imaging and Deep learning AFB1 and AFG1 were also reported in beans from Brazil [61] and Burkina Faso [62].
The aflatoxin concentration in cocoa beans was found to exceed the threshold on day 3 after inoculating.Hruska [33] discovered that the aflatoxin level in corn kernels inoculated with A. flavus fungus exceeded the threshold on day 7.This condition occurred due to various factors that affected mold growth and aflatoxin production.Intrinsic factors included water activity [59], pH [60], redox potential [61], substrate [62], inhibitors [63], and osmotic pressure [64].Meanwhile, extrinsic factors were related to environmental conditions such as temperature and humidity [65].The incubator's temperature and relative humidity (RH), the amount of media added, and cocoa bean nutrient content (substrate) were all factors under control in this study that affected aflatoxin levels.In order to drive the growth of mold and the generation of aflatoxin, the incubator's temperature and RH were set to 30 o C and 90 RH, respectively.Biotrop [66] reported that compared to temperatures of 40° C and 80 RH, a temperature of 30 o C with 90 RH was better for the development of molds and the production of aflatoxin.This is due to the mold's inability to grow at 40° C with a 70% RH.
Nutrients from the substrate such as lipids, carbon, nitrogen, and amino acids are among the factors that can affect aflatoxin production [67].Cocoa beans, which are composed of cocoa butter (50%), mainly stearic acid, oleic acid and palmitic acid, containing protein (11%), including glutamate, arginine and leucine provide an ideal commodity type for mold and aflatoxin development.Glutamate is a source of arginine and proline [68], which are nitrogen sources to stimulate aflatoxin production [9].The highest aflatoxins are induced by glutamate and aspartate, followed by arginine [62].Nitrogen in the form of nitrite and nitrate also increases the level of aflatoxin production [69].Moreover, aflatoxin biosynthesis is also triggered by lipophilic epoxy fatty acids and induced by ergo-sterol oxidation [70].

B. Image acquisition and analysis
Fluorescence images were acquired for this study by excitation of UV light at 365 nm wavelength.Airborne mycotoxin is detected using an excitation source of 360-370 nm; and 435-440 nm for substrate in food materials [71].Furthermore, the fluorescence image of cocoa beans obtained is shown in Fig. 6 and Fig.In Fig. 7, cocoa beans image can be observed with blue UV light emission on day 7.This emission occurs when fluorophores are excited by UV light at a specific wavelength, resulting in a longer wavelength.AFB1 and AFB2 have blue fluorescent colors, while AFG1 and AFG2 have green colors [72].On the other hand, Fig. 6(b) shows that cocoa beans contaminated with aflatoxins are below the threshold at which, in theory, they should excite light as a sign of aflatoxin contamination; however, none of the cocoa beans exhibit light excitation.However, cocoa beans that produce excitation are not an absolute indicator of the presence of aflatoxin.It should be noted that aflatoxins are not the only ones responsible for UV light emission.According to Gao [73], UV fluorescence light may also be emitted by oil in grains and dust in the air.It's possible that accuracy will decrease if aflatoxins are only detected using blue-green fluorescence under UV light.Therefore, in the subsequent stage, deep learning approaches were employed to improve the accuracy of the detection process.

C. CNN Performances
This research was conducted using four pre-trained CNN models including AlexNet, GoogLeNet, ResNet50, and SqueezeNet to classify the aflatoxin contamination level in cocoa beans.Moreover, sensitivity analysis was conducted through different variations of optimization methods such as Adam, SGDm, and RMSProp as well as initial learning rates set at 0.0001 and 0.00005.The performance of these models is presented in the following Table I.
The pre-trained CNN models were observed to have produced different accuracy values with the lowest, 76.69%, for GoogLeNet, optimizer: SGDm, learning rate: 0.00005 and the highest, 96.42%, for GoogLeNet, optimizer: Adam, learning rate: 0.0001.This means GoogLeNet, optimizer: Adam, learning rate: 0.0001 was the best combination to classify the level of aflatoxin contamination in cocoa beans using fluorescence images.Moreover, the average accuracy based on the type of pre-trained network showed that ResNet50 had the highest average accuracy of 91.48%, followed by AlexNet at 92.8%, GoogLeNet at 87.2%, and SqueezeNet at 87.15%.This was observed to be consistent with the findings of Liu [74] that ResNet has better accuracy than other models such as VGG-16 and MobileNet during the process of comparing the CNN models for fruit classification.However, it was discovered from Table I  This was likely due to ResNet50 having a higher depth of 50 layers which was more than AlexNet with 5 layers, SqueezeNet with 18 layers, and GoogLeNet with 22 layer.There are more weights and biases to update during training when the parameter size is larger.This may result in longer training times for the model by making it more complex and difficult to optimize [75].The Adam optimizer was observed to have provided the highest average classification accuracy of 93.12% followed by RMSProp at 89.8% and SGDm at 84.88%.Adam optimizer is a first-order gradient-based optimization method with a stochastic function considered suitable for direct application to classification models with large data and parameters [76].Furthermore, a 0.0001 learning rate was also discovered to have generally led to higher accuracy with an average value of 90.42% while 0.00005 had 87.9%.This is consistent with the findings of Hendrawan [77] that a learning rate of 0.0001 produced better classification accuracy compared to 0.00005 for tempeh quality.
The training process for the six best models presented in Fig. 7 showed an increase in the classification accuracy as the iterations progressed.Different patterns of accuracy graphs were also obtained using the RMSprop optimizer and the validation value was observed to be increasing but fluctuating.Meanwhile, the Adam optimizer, specifically for the ResNet50 model with a learning rate of 0.0001, showed a stable training and validation process.Adam and its modification are more preferred approaches in neural networks.Due to its exponential moving averages for both gradient and squared gradient, which significantly improve neural network training, Adam is a well-liked optimizer.These methods yield additional information about the global minimum by forcing optimization through the use of moment estimate.Furthermore, this improvement enhances the accuracy of object categorization and pattern recognition.[78].The performance graphs for training and validation showed a rapid progression in the initial epochs, followed by convergence in the subsequent epochs, resulting in an accuracy value that approached an impressive 96.42%.The loss value consistently decreased as the iterations increased, signifying the effectiveness of the training process.The six top-performing CNN models exhibited comparable patterns, with the loss value converging towards 0. These six top performing models showed remarkable performance in classifying aflatoxin contamination levels using pre-trained networks as indicated in Fig. 8.
The determination of the best results from the training and validation process was followed by the evaluation of the CNN models' performance using the testing dataset.The confusion matrix results in Fig. 9 showed that the average accuracy of the testing dataset was 96.6% and this was considered high for the classification of the aflatoxin contamination level in cocoa beans.A confusion matrix is a matrix representation of the prediction summary.Through a comparison of the predicted and true classes, it demonstrates the number of correct and wrong predictions for each class.This information may be utilized to make decisions and optimize our algorithms [79].These results were comparable to the testing accuracy of 99% recorded by Albarrak [80] for date fruit classification.The CNN models were able to accurately classify 100% without errors for the "free of aflatoxin" and "contaminated above the limit" categories but had an error of 10% for the "contaminated below the limit" by misclassifying cocoa beans as contaminated above the limit.This means the models classified the cocoa beans contaminated below the limit with an accuracy of 90%.Even though there is misclassification, this type of miscalculation can still be tolerated compared to the false negative type of miscalculation, namely miscalculation of aflatoxincontaminated cocoa beans categorized as aflatoxin-free, which will have a negative impact on ensuring food safety.This high accuracy means the constructed CNN models can effectively classify the aflatoxin contamination level in cocoa beans as "free of aflatoxin," "contaminated below the limit," and "contaminated above the limit".Based on the results obtained above, CNN models and fluorescence images can be combined in the future to serve as an alternative method to classify the level of aflatoxin contamination in cocoa beans.This approach can also offer better accuracy and cost efficiency than existing methods.The combination of CNN models and fluorescence images is expected to minimize the impact of aflatoxin on health and losses in the cacao trade.However, this research still uses an acquisition unit on immovable objects, so further research is needed to develop an acquisition system with an acquisition unit that can record images using a motorized stage so that it approaches applications in quality control in the cacao industry.

IV. CONCLUSION
In conclusion, this study demonstrated the effectiveness of utilizing pre-trained CNN models in combination with fluorescence images to accurately classify aflatoxin contamination levels in cocoa beans.Through a comparative analysis of GoogLeNet, SqueezeNet, AlexNet, and ResNet50, it was determined that the GoogLeNet model, optimized with Adam and a learning rate of 0.0001, achieved remarkable classification accuracy, with a validation accuracy of 96.42% and a testing accuracy of 96%.These results highlight the potential of deep learning techniques and image-based approaches for addressing the crucial issue of aflatoxin contamination in cocoa beans.
The success of this study opens up avenues for further research and applications.The proposed method offers a noninvasive and cost-effective means to assess the safety of cocoa beans, aiding in maintaining the quality and value of this essential commodity.Moreover, the use of fluorescence imaging holds promises for early detection of contamination, contributing to proactive interventions in the food supply chain.Future research could explore the scalability of this approach across different varieties of cocoa beans and under varying environmental conditions.By integrating cutting-edge technology with the agriculture and food safety sectors, this study contributes to the ongoing efforts to ensure food security, trade compliance, and public health.As the field of deep learning continues to evolve, it is anticipated that innovative solutions like this will further revolutionize food quality assessment and safety assurance.

Fig. 5 .
Fig. 5. Changes in aflatoxin levels after inoculation of A. flavus on cocoa beans

Fig. 6 .
Fig. 6.Difference of reflectance and fluorescence imaging (a) Reflectance image (b) Fluorescence image Fig. 6 shows how the reflectance and fluorescence images of aflatoxin-contaminated cocoa beans differ from one another.While there are some cocoa beans in the fluorescence image that excite blue light, as shown in Fig. 6 (b), there are

Fig. 9 .
Fig. 9. Confusion matrix for the aflatoxin level classification in cocoa beans using fluorescence images that ResNet50 required the longest training time of 58.2 minutes while AlexNet has the shortest at approximately 28.2 minutes.

TABLE I .
COMPARISON OF THE ACCURACY OF SEVERAL PRE-TRAINED CNN ARCHITECTURES DEVELOPED TO CLASSIFY THE AFLATOXIN CONTAMINATION LEVEL USING FLUORESCENCE IMAGES