{'fraction_non_alphanumeric': 0.023830719715127027, 'fraction_numerical': 0.008628364034787372, 'mean_word_length': 5.238359675352413, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Modeling Generalized Specialist Approach To Train Quality Resilient Snapshot Ensemble

Convolutional neural networks (CNNs) apply well with food image recognition due to the ability to learn discriminative visual features. Nevertheless, recognizing distorted images is challenging for existing CNNs. Hence, the study modelled a generalized specialist approach to train a quality resilient ensemble. The approach aids the models in the ensemble framework retain general skills of recognizing clean images and shallow skills of classifying noisy images with one deep expertise area on a particular distortion. Subsequently, a novel data augmentation random quality mixup (RQMixUp) is combined with snapshot ensembling to train G-Specialist. During each training cycle of G-Specialist, a model is fine-tuned on the synthetic images generated by RQMixup, intermixing clean and distorted images of a particular distortion at a randomly chosen level. Resultantly, each snapshot in the ensemble gained expertise on several distortion levels, with shallow skills on other quality distortions. Next, the filter outputs from diverse experts were fused for higher accuracy. The learning process has no additional cost due to a single training process to train experts, compatible with a wide range of supervised CNNs for transfer learning. Finally, the experimental analysis on three real-world food and a Malaysian food database showed significant improvement for distorted images with competitive classification performance on pristine food images.


II. INTRODUCTION AND CURRENT
METHODOLOGIES A vital aspect overlooked in existing methodology framework is the visual quality of food images. In real-world computer vision applications, images undergo various distortions, such as blur or additive noise during capturing or transmission. Generally, current CNNs shows extreme sensitivity to these image distortions [1] [2][3] [4]. Nevertheless, Dodge and Karam [6] stated that the distorted images do not represent adversarial samples for CNNs but the images cause a significant reduction in classification performance. Figure 1 shows the effect of image quality on the prediction performance of CNNs trained on pristine food images. When the predicted label is correct, its confidence decreases significantly with the increasing high distortion severity, indicating that features learnt from the dataset of pristine images are not invariant to image distortion nor useable for applications with varying image quality. Past studies addressed this challenge by fine-tuning with corrupted images at all distortion levels [3] [7], making the CNN model resilient to quality distortions. Nonetheless, the method requires large distorted datasets at all quality levels, which are not available and is time-consuming. Besides, finetuning with low-quality images decreases the accuracy of the clean food photos and increases the epochs to converge the model. Although other methods feature quantization [9]], stability learning [8], and Deep correct [5] reduce the impact of image quality on CNNs, requiring architectural level changes in the pre-trained models. Similarly, stability learning and feature quantization decrease the Top 1 accuracy, whereas Deep correct increases the floating-point operations (FLOPS) during training and testing. The study extended the CNN-based approach by combining multiple networks with a robust ensemble framework G-Specialist resilient against large variations in quality distortions. Unlike image denoising methods, such as Block Matching 3D denoising (BM3D) [16] and Non-locally Centralized Sparse Representation (NCSR) [17] (which predict the known distortion intensity during training and testing), the G-Specialist approach trains an ensemble for all distortion levels simultaneously.
Accordingly, the study introduced a generalized specialist approach in deep learning with each CNN in the ensemble carrying the general skills of recognizing pristine images, specialist skills on a particular distortion (Gaussian noise or blur) at all distortion levels, and shallow skills on other distortions. Thus, a suitable solution to train generalized specialists during the ensemble learning process is data augmentation.
The proposed RQMixup increases the quantifiable data value without increasing the size of training data or change in the model architecture. Moreover, the approach generates a synthetic sample coupled with snapshot ensembling [10], creating a mixture of experts resilient to distortions and improves classification performance on pristine images without extra training time or increasing the training dataset.
The study has done experimentation on Malaysian Food database [ref], the largest database yet to the authors' best arXiv:2206.05853v1 [cs.CV] 12 Jun 2022 knowledge and experimented on other three publicly available large food databases that will be publicly available online [25].

A. General Architecture
The proposed framework is based on the recent emergence of efficient neural networks [18][19] [20]. Furthermore, the study selected MobileNetV3 [18] as it is resource-efficient, a crucial requirement of on-device computation for edge devices. Next, RQMixup was combined with snapshot ensembling to train a mixture of robust experts G-Specialist that are resilient to extreme image distortions. Figure 2 shows the general architecture of the framework.

B. Random MixUp Data Augmentation
Data involves driving and powering artificial intelligence (equivalent to fuel for learning algorithms), a fundamental ingredient in supervised machine learning problems with a quantified value in algorithmic classification tasks measurable by the Data Shapley method [11] for supervised classification tasks. Hence, the study developed a generic method that increases the quantified value of data sets in algorithmic decisions to train robust models resilient to different quality distortions without significant changes at the architecture level.
Accordingly, the study chose RQMixup that generates a synthetic image to fine-tune quality resilient deep learning models and used two copies of the same training dataset, applying randomly chosen distortion levels to one copy of the dataset during training. Next, raw vectors of cleaned and noisy images and their corresponding labels were mixed using a strategy similar to mixup. For example, raw vectors of a clean set of images in each batch are mixed by applying blurring on the copy of the same set of the training dataset for the Gaussian blur, randomly selecting the blur intensity (1,3,5,7,9,11,13, and 15) for each batch. Consequently, fine-tuning the model with synthetic images turns the model into an expert on all intensity levels of Gaussian blur in the test samples. Equations 1 and 2 compute the mixup of feature-target vectors of the pristine and corrupted images.
Specifically, is the raw input vector and is the one-hot label encodings of the noisy image at the random distortion level, is the raw input vector, and is the one-hot label encodings of the pristine image. Meanwhile, Figure 3 shows samples of synthetic images generated to fine-tune a model in a single cycle. Notably, the proposed method does not increase the training images required to fine-tune the model

C. Snapshot Ensembling to Train G-Specialist by Modeling Generalized Specialist Approach
Although the single model fine-tuned on synthetic images generated by the RQMixup delivers all the distortion levels of particular noise, multiple types of noises exist, such as Gaussian additive noise and blur. Therefore, the study employed snapshot ensembling to train generalized specialists on various distortions while inheriting the core benefit Train 1 Get M experts.
The process follows Loshchilov et al.'s [12] cyclic annealing schedule to converge with multiple local minima and train M generalized specialists in a single training process using synthetic images generated by RQMixup. The learning rate was lowered at a very fast pace in each cycle, converging the model towards local minima after a minimum of 32 epochs. The process was repeated multiple times to obtain M generalized experts through multiple convergences. The learning rate alpha is as follows: Specifically, T is the total number of iterations and f is a monotonically decreasing function. Thus, the training process of the whole framework was split into M cycles whereby each cycle starts with a higher learning rate annealed towards a smaller learning rate to converge towards local minima. A larger learning rate at the start of the cycle provides the model energy to escape a critical point while a smaller learning rate converges the model to local minima. In the experiment, f is shifted cosine function following Loshchilov et al. [12] ( ) = The M-value is 2 for the Gaussian noise and blur. The total cycles were kept equivalent to the number of distortions because during each process cycle, the generalized specialist was trained on a particular distortion by applying snapshot ensembling. The method enabled each snapshot to classify the clean images with a particular distortion, such as Gaussian additive noise at all intensity levels with confidence. Although the method is not an expert on another distortion, such as blurring, it possesses shallow skills of recognizing blur images. Hence, the data augmentation in the second cycle mixes the clean images with a randomly chosen intensity level of blurring, turning the second snapshot of the model to an expert on all distortion levels in the images with shallow skills on other distortions. As the model usually converges to local minima at the end of every cycle, a snapshot of the model weights was taken before training the next generalized experts on another distortion type. Furthermore, an M snapshot was used in the final ensemble after training the model for M cycles. Besides making each snapshot expert to the particular type of noise, the method also inherits the benefits of ensembling for clean photos as each snapshot converges to different local minima. Contrary to a single model, the ensemble of these snapshots has lower test errors, as shown in Table II and III. The ensemble prediction during testing is the average of M experts equivalent to the total snapshots. Let I (w, h, and c) represent a pre-processed input image of size w × h pixels, and c is the number of channels of the input image. After feeding the image to the input conv2d of a snapshot in the ensemble, g(x) will be the softmax score from a snapshot. Additionally, the final output of the ensemble is an average of all models.

IV. EXPERIMENT AND RESULTS
The experiments were performed on a server with 25 GB of random access memory (RAM) equipped with 16 GB of the graphics processing unit (GPU). Besides, all the experiments were performed using Python on three publically available large food databases (FOOD101 [13], UECFOOD100 [14], UECFOOD256 [15]) and a database of Malaysian foods. Table  I summarizes the crucial attributes of the datasets.

A. G-Specialist Analysis on Distorted Test Images
The G-Specialist was evaluated against the ensemble model on test images distorted with the Gaussian noise and blurring, with a standard deviation of 10 to 100. Meanwhile, the Gaussian kernel during blurring of test images was varied from 1 to 15. Figure 5 shows the test image results distorted with Gaussian noise and blur for all datasets, denoting that the G-Specialist significantly outperformed the ensemble fine-tuned on pristine images with a significant difference for a higher noise level. Additionally, both models had similar training costs.
The study also identified whether synthetic data adds value to the model by employing a gradient explainer [21] to compute average Shapley values on test images distorted with Gaussian noise and blur. Figure 6 shows that the noise level increases while the test images average Shapley value decreases . Nonetheless, the Shapley values for G-Specialists were significantly higher than the ensemble fine-tuned with pristine images, suggesting improved robustness by increasing the data value

B. Results on Pristine Test Images
The results in Table II of Top 1 6. The average Shapley value shows that as the noise level increases, the average Shapley value on noisy images decreases test data. The study only reported the highest performers, with more results seen in [24], [26], [27], [25], and [28].

C. Results on Malaysian Food Database
Malaysian Food database is comprised of 775 classes with 37,198 instances and these classes were selected based on recommendations from an expert dietician. The images were collected from Google search, Bing search, social media and authors' data using smartphones for capturing food images. Besides, the study used the same experimental settings as the other three datasets. Figure 5 depicts that G-Specialist outperformed other methods on test images distorted with Gaussian noise and blur. Meanwhile, Table III suggests that the G-Specialist was better at recognizing food images than a single model and other variants of MobileNet. Additionally, Figure 7 illustrates that the study approach in considering relevant pixels for recognizing food images increases the model transparency.

V. CONCLUSION
Observably, efficient neural networks trained on pristine images had poor classification performance for the distorted images affected by blur or additive noise. The G-Specialist in the study addressed the issue by modeling a generalized specialist approach to increase data value by generating synthetic images on the fly during fine-tuning, helping each model in an ensemble retain the general skill of recognizing clean images and deep expertise on all intensity levels of a particular distortion. Significantly, the study proved that each model in the ensemble individually contributed to a better prediction for noisy test images by becoming an expert on a particular noise, such as blur or additive noise.
Secondly, the study presented that the models in an ensemble converge to different local minima improved classification performance on pristine data compared to a single model. Most importantly, the study has experimented on Malaysian Food database publicly available for further enrichment and evaluation besided performing experiments on three publicly available real-world image datasets. The results showed that the proposed G-Specialist consistently outperformed other methods on pristine images and recognized noisy test images with great precision than the other methodologies.