Deep Learning-Based Meat Freshness Detection with Segmentation and OOD-Aware Classification
Authors: Hutama Arif Bramantyo, Mukarram Ali Faridi, Rui Chen, Clarissa Harris, Yin Sun
Organizations: Electrical & Computer Engineering Department, College of Engineering, Auburn University, Auburn, AL 36849 USA · Department of Agricultural and Environmental Sciences, College of Agriculture, Environment & Nutrition Sciences, Tuskegee University, Tuskegee, AL 36088 USA
In this study, we present a meat freshness classification framework from Red-Green-Blue (RGB) images that supports both packaged and unpackaged meat datasets. The system classifies four in-distribution (ID) meat classes and uses an out-of-distribution (OOD)-aware abstention mechanism that flags low-confidence samples as No Result. The pipeline combines U-Net-based segmentation with deep feature classifiers. Segmentation is used as a preprocessing step to isolate the meat region and reduce background, producing more consistent inputs for classification. The segmentation module achieved an Intersection over Union (IoU) of 75% and a Dice coefficient of 82%, producing standardized inputs for the classification stage. For classification, we benchmark five backbones: Residual Network-50 (ResNet-50), Vision Transformer-Base/16 (ViT-B/16), Swin Transformer-Tiny (Swin-T), EfficientNet-B0, and MobileNetV3-Small. We use nested 5x3 cross-validation (CV) for model selection and hyperparameter tuning. On the held-out ID test set, EfficientNet-B0 achieves the highest accuracy (98.10%), followed by ResNet-50 and MobileNetV3-Small (both 97.63%) and Swin-T (97.51%), while ViT-B/16 is lower (94.42%). We additionally evaluate OOD scoring and thresholding using standard OOD metrics and sensitivity analysis over the abstention threshold. Finally, we report on-device latency using TensorFlow Lite (TFLite) on a smartphone, highlighting practical accuracy-latency trade-offs for future deployment.
Figures & tables
Fig. 1: Experiment setup for packaged meat image collection.
Fig. 2: Representative examples of the No Result (irrelevant/OOD) set, including empty trays, plates, and background-only images.
Category
Train
Val
Test
Total
Share (%)
Packaged Fresh Meat
656
138
146
940
15.0
Packaged Spoiled Meat
805
170
180
1,155
18.5
Unpackaged Fresh Meat
1,159
246
256
1,661
26.6
Unpackaged Spoiled Meat
1,187
252
261
1,700
27.2
Total
3,807
806
843
5,456
100.0
TABLE I: Per-class distribution after cleaning and stratified 70/15/15 splitting for the four in-distribution freshness classes. Unpackaged sources: [ 32 , 33 , 34 ] ; Packaged: this study (Apr 2024).
Hyperparameter
Search Range / Setting
Head learning rate (Inner-1)
1×10−3 – 3×10−3
Backbone learning rate (Inner-2)
1×10−5 – 3×10−4
Weight decay (Inner-1)
1×10−4 – 1×10−1
Label smoothing α
{0.0,0.1}
MixUp α
{0.0,0.2}
Batch size
32
TABLE II: Hyperparameter search space explored during inner-loop tuning under the nested 5 × 3 CV framework (classification).
Backbone
IoU
Dice
Precision
Recall
Pixel Acc.
ResNet-18
0.7211 [0.703, 0.739]
0.8021 [0.786, 0.817]
0.7780 [0.761, 0.794]
0.8727 [0.857, 0.888]
0.8569 [0.846, 0.868]
ResNet-34
0.7494 [0.731, 0.767]
0.8188 [0.802, 0.835]
0.8186 [0.802, 0.835]
0.8490 [0.832, 0.866]
0.8777 [0.867, 0.889]
ResNet-50
0.7320 [0.713, 0.750]
0.8057 [0.789, 0.822]
0.8103 [0.793, 0.826]
0.8419 [0.825, 0.859]
0.8709 [0.860, 0.882]
TABLE III: Global segmentation performance of U-Net backbones with 95% confidence intervals.
Backbone
Packaged Fresh
Packaged Spoiled
Unpackaged Fresh
Unpackaged Spoiled
ResNet-18
0.8726 [0.842, 0.900]
0.7749 [0.741, 0.808]
0.6693 [0.639, 0.699]
0.6501 [0.612, 0.687]
ResNet-34
0.8888 [0.859, 0.915]
0.8072 [0.771, 0.842]
0.6898 [0.659, 0.722]
0.6900 [0.653, 0.728]
ResNet-50
0.8900 [0.858, 0.918]
0.7997 [0.763, 0.834]
0.6738 [0.643, 0.704]
0.6541 [0.615, 0.693]
TABLE IV: Per-class IoU performance with 95% confidence intervals.
Model
Acc (%)
F1 (%)
Prec. (%)
Rec. (%)
ResNet-50
98.47 ± 0.37
98.47 ± 0.37
98.51 ± 0.35
98.47 ± 0.37
Swin-T
97.75 ± 0.64
97.75 ± 0.64
97.80 ± 0.62
97.75 ± 0.64
ViT-B/16
94.16 ± 1.03
94.13 ± 1.05
94.67 ± 0.76
94.16 ± 1.03
EfficientNet-B0
97.88 ± 0.72
97.88 ± 0.72
97.96 ± 0.67
97.88 ± 0.72
MobileNetV3-Small
96.64 ± 0.93
96.63 ± 0.93
96.91 ± 0.79
96.64 ± 0.93
TABLE V: Nested CV stability (outer-fold mean ± SD).
Model
Acc. (Mean ± SD, %)
Head LR
Backbone LR
Weight Decay
Label Smooth
Mixup α
Best Epoch
ResNet-50
98.47 ± 0.37
0.003
1e − 4
0.0005
0.0
0.0
19–30
Swin-T
97.75 ± 0.64
0.0015
7e − 5
0.1
0.0
0.0
13–30
ViT-B/16
94.16 ± 1.03
0.001
5e − 5
0.05
0.1
0.0
13–30
EfficientNet-B0
97.88 ± 0.72
0.001
0.0003
0.0001
0.1
0.0
17–30
MobileNetV3-Small
96.64 ± 0.93
0.001
0.0003
0.0005
0.0
0.2
17–30
TABLE VI: Nested cross-validation (5 outer × 3 inner) results and best hyperparameters per model.
TABLE VIII: Retrain results on the held-out ID test set.
Fig. 3: Training vs validation accuracy curves for five models during retraining with OOD-enabled inference.
Class
ResNet-50
Swin-T
ViT-B/16
EfficientNet-B0
MobileNetV3-Small
Prec.
Rec.
F1
Prec.
Rec.
F1
Prec.
Rec.
F1
Prec.
Rec.
F1
Prec.
Rec.
F1
Packaged Fresh
0.986
0.952
0.969
0.935
0.993
0.963
0.971
0.911
0.940
0.973
0.993
0.983
0.954
0.986
0.970
Packaged Spoiled
0.962
0.989
0.975
0.994
0.944
0.969
0.931
0.978
0.954
0.994
0.978
0.986
0.989
0.961
0.975
Unpackaged Fresh
0.959
1.000
0.979
0.992
0.969
0.980
0.895
1.000
0.945
0.959
1.000
0.979
0.959
1.000
0.979
Unpackaged Spoiled
1.000
0.958
0.978
0.970
0.992
0.981
1.000
0.885
0.939
1.000
0.958
0.978
1.000
0.958
0.978
Macro Avg
0.977
0.975
0.975
0.973
0.975
0.973
0.949
0.943
0.944
0.982
0.982
0.982
0.975
0.976
0.975
TABLE IX: Per-class performance of five models on the held-out ID test set ( N=843 ).
Fig. 4: Confusion matrices on the held-out ID test set ( N=843 ) for the four in-distribution classes (Packaged Fresh, Packaged Spoiled, Unpackaged Fresh, Unpackaged Spoiled). Errors mostly occur within the same packaging type (fresh vs. spoiled), which is the hardest visual boundary.
Fig. 5: Representative failure cases: (i) glare on packaged samples, (ii) occlusion/clutter, and (iii) borderline freshness with subtle cues.
Model
Method
AUROC
AUPR
FPR@95TPR
ResNet-50
MSP
0.927
0.911
0.242
ENERGY
0.939
0.941
0.254
ODIN
0.930
0.927
0.281
Swin-T
MSP
0.981
0.992
0.0250
Energy
0.996
0.998
0.0025
ODIN
0.997
0.997
0.0025
TABLE X: OOD detection results across scoring methods on the OOD benchmark.
Fig. 6: Threshold sweep on the in-distribution (4-class) set: τ vs. coverage (fraction of samples kept).
Fig. 7: Threshold sweep on the in-distribution (4-class) set: τ vs. rejection rate (fraction of samples abstained).
Pair
n11
n10
n01
n00
χ2
p -value
Δacc (A–B)
95% CI
ResNet50 (A) vs ViT (B)
788
35
8
12
16.331
5.32×10−5
+0.0320
[0.0169,0.0471]
ViT (A) vs Swin-T (B)
778
18
44
3
10.512
0.0012
−0.0308
[−0.0490,−0.0127]
ViT (A) vs EfficientNet-B0 (B)
790
6
37
10
21.605
3.35×10−6
−0.0368
[−0.0518,−0.0217]
ViT (A) vs MobileNetV3-Small (B)
780
16
43
4
11.932
0.0005
−0.0320
[−0.0498,−0.0143]
Swin-T (A) vs MobileNetV3-Small (B)
815
7
8
13
0.0167
0.8973
−0.0012
[−0.0102,0.0078]
TABLE XI: McNemar paired contingency tables and confidence intervals for pairwise comparison of test accuracy on the held-out ID test set ( N=843 ). McNemar χ2 statistics use the continuity-corrected form (∣n10−n01∣−0.5)2/(n10+n01)(df=1) .
Class
ResNet-50
Swin-T
ViT-B/16
EfficientNet-B0
MobileNetV3-Small
Packaged Fresh
0.950 (0.921–0.974)
0.944 (0.916–0.969)
0.889 (0.847–0.925)
0.946 (0.918–0.970)
0.932 (0.899–0.960)
Packaged Spoiled
0.958 (0.933–0.978)
0.951 (0.927–0.973)
0.921 (0.891–0.947)
0.955 (0.932–0.975)
0.939 (0.911–0.964)
Unpackaged Fresh
0.982 (0.970–0.993)
0.982 (0.970–0.993)
0.936 (0.913–0.956)
0.975 (0.960–0.988)
0.961 (0.943–0.976)
Unpackaged Spoiled
0.983 (0.970–0.993)
0.983 (0.971–0.993)
0.928 (0.903–0.951)
0.974 (0.959–0.987)
0.958 (0.939–0.975)
Macro Avg
0.968 (0.954–0.980)
0.965 (0.951–0.978)
0.919 (0.899–0.938)
0.963 (0.948–0.976)
0.947 (0.930–0.963)
TABLE XII: Per-class F1-score with 95% bootstrap confidence intervals (percentile, B=4000 ) on the held-out ID test set ( N=843 ).
TABLE XIII: Quantitative comparison of prior RGB-based meat-freshness studies and this work. Results from this study are reported on the held-out ID test set. OOD performance is evaluated separately (Section IV-D ).
Model
Params (M)
Latency (ms)
Device / Runtime
Accuracy (%)
Train Time (min/epoch)
ResNet–50
25.6
76.92
Galaxy A55, Android 16, TFLite Benchmark
97.63
1.10
EfficientNet–B0
5.3
17.21
Galaxy A55, Android 16, TFLite Benchmark
98.10
0.76
MobileNetV3–Small
2.5–2.9
6.36
Galaxy A55, Android 16, TFLite Benchmark
97.63
0.74
Swin–T (Tiny)
27.5–28
108.17
Galaxy A55, Android 16, TFLite Benchmark
97.51
0.78
ViT–B/16
86
462.75
Galaxy A55, Android 16, TFLite Benchmark
94.42
0.84
TABLE XIV: Computational efficiency. Test accuracy and training time were measured on our lab GPU setup (RTX 6000 Ada), while mobile latency was benchmarked by us on a Samsung Galaxy A55 (SM-A556E), Android 16, using the TensorFlow Lite Benchmark APK (this work). Accuracy corresponds to the held-out ID test accuracy (Table VIII ).
Woody Breast (WB) and Spaghetti Meat (SM) myopathies significantly impact poultry meat quality, yet current detection methods rely either on subjective manual evaluation or costly laboratory-grade imaging systems. We address the problem of low-cost, non-destructive multi-class myopathy classification using consumer smartphones. MyoVision is introduced as a mobile transillumination imaging framework in which 14-bit RAW images are captured and structural texture descriptors indicative of internal tissue abnormalities are extracted. To classify three categories (Normal, Woody Breast, Spaghetti Meat), we propose a NEATBoost-Attention Ensemble model, which is a neuroevolution-optimized weighted fusion of LightGBM and attention-based MLP models. Hyperparameters are automatically discovered using NeuroEvolution of Augmenting Topologies (NEAT), eliminating manual tuning and enabling architecture diversity for small tabular datasets. On a dataset of 336 fillets collected from a commercial processing facility, our method achieves 82.4% test accuracy (F1 = 0.83), outperforming conventional machine learning and deep learning baselines and matching performance reported by hyperspectral imaging systems costing orders of magnitude more. Beyond classification performance, MyoVision establishes a reproducible mobile RGB-D acquisition pipeline for multimodal meat quality research, demonstrating that consumer-grade imaging can support scalable internal tissue assessment.
Chaitanya Pallerla, Siavash Mahmoudi, Dongyi Wang
Department of Biological and Agricultural Engineering, University of Arkansas, Fayetteville, AR · Department of Food Science, University of Arkansas, Fayetteville, AR
Deep learning models are increasingly deployed in safety-critical applications, where reliable out-of-distribution (OOD) detection is essential to ensure robustness. Existing methods predominantly rely on the penultimate-layer activations of neural networks, assuming they encapsulate the most informative in-distribution (ID) representations. In this work, we revisit this assumption to show that intermediate layers encode equally rich and discriminative information for OOD detection. Based on this observation, we propose a simple yet effective model-agnostic approach that leverages internal representations across multiple layers. Our scheme aggregates features from successive convolutional blocks, computes class-wise mean embeddings, and applies L_2 normalization to form compact ID prototypes capturing class semantics. During inference, cosine similarity between test features and these prototypes serves as an OOD score--ID samples exhibit strong affinity to at least one prototype, whereas OOD samples remain uniformly distant. Extensive experiments on state-of-the-art OOD benchmarks across diverse architectures demonstrate that our approach delivers robust, architecture-agnostic performance and strong generalization for image classification. Notably, it improves AUROC by up to 4.41% and reduces FPR by 13.58%, highlighting multi-layer feature aggregation as a powerful yet underexplored signal for OOD detection, challenging the dominance of penultimate-layer-based methods. Our code is available at: https://github.com/sgchr273/cosine-layers.git.
Hyperspectral imaging (HSI) offers nondestructive assessment of fish freshness by detecting biochemical alterations across spectral bands. However, conventional deep learning approaches do not fully address the particular characteristics of HSI data, such as spectral dominance over spatial textures, ordinal label structure, and a small number of training samples. We propose SGNet (Spectral-Grouped Network), a lightweight architecture that separates spectral and spatial feature extraction using grouped convolutions and a depthwise spatial pathway. A dual attention mechanism that couples channel-wise squeeze-and-excitation with spatial gating adaptively highlights informative features. SGNet achieves 97.8% classification accuracy and 0.64 days mean absolute error (MAE) with just 4.75M parameters when tested on our newly developed 16-day refrigerator-stored salmon fillet dataset. Ablation studies validate the contribution of each component, while comparisons demonstrate a five- to eighteen-fold parameter reduction relative to ResNet-50 and Vision Transformers. Our findings indicate that domain-aware design supports precise, real-time freshness prediction for industrial implementation.
Kazi Nabiul Alam, Pooneh Bagheri Zadeh, Akbar Sheikh-Akbari
School of Built Environment, Engineering, and Computing, Leeds Beckett University. Leeds LS6 3QS, United Kingdom.