Accuracy Is Not Enough: An Efficiency- and Statistics-Aware Benchmark of ResNet50 and Vision Transformer for Explainable Multi-Class Gastrointestinal Diseases Classification
Organizations: Department of Research and Training, Centre for Medical and Agro Computing (C-MAC), Accra, Ghana · Department of Computer Science, Ghana Communication Technology University, Accra, Ghana · PerceptronCare Lab.
Abstract
Automated classification of gastrointestinal (GI) findings in endoscopic images could support early diagnosis, but architectures are often chosen on accuracy alone. We present a controlled, reproducible benchmark of ResNet50 and ViT-B/16 for eight-class GI classification on the public Kvasir dataset (4,000 images), using a stratified split (400 test images) and stratified group 5-fold cross-validation over all images. In cross-validation, ResNet50 and ViT-B/16 reached 92.12% and 91.70% accuracy, and a two one-sided tests (TOST) procedure showed equivalence within a +/-3 percentage-point margin (difference +0.43 points, 90% CI -0.33 to +1.18; p < 0.001). The architectures differed mainly in cost: ResNet50 had 3.6 times fewer parameters and 4.3 times fewer operations, 2.5-fold lower single-image CPU latency (69 vs. 177 ms) and 3.8-fold higher GPU throughput. Cross-validated calibration was similar (expected calibration error 0.021 vs. 0.023). An edge-oriented transformer, MobileViT-S, was most accurate on the test split (95.5%) but lost 9.4 points when an acquisition artefact present in some classes (the ScopeGuide inset) was occluded, whereas ResNet50 was not significantly affected. On 500 unseen polyp images with expert masks, both models' Grad-CAM maps focused on the lesion (3.6 times chance). On a de-duplicated external subset of GastroVision (1,998 images), accuracy fell to 78-80% for all three models and differences between them remained small. Accuracy differences between architectures were thus small relative to the effects of shortcut learning and domain shift, whereas efficiency differences were large. An efficient CNN is a defensible default for resource-constrained screening, but no model is deployment-ready without local validation.
Figures & tables
| Class | Images (%) | Most common resolution | Distinct resolutions | ScopeGuide inset (%) |
|---|---|---|---|---|
| dyed-lifted-polyps | 500 (12.5) | 720 576 | 2 | 71.2 |
| dyed-resection-margins | 500 (12.5) | 720 576 | 1 | 70.2 |
| esophagitis | 500 (12.5) | 1280 1024 | 3 | 0.0 |
| normal-cecum | 500 (12.5) | 720 576 | 1 | 96.6 |
| normal-pylorus | 500 (12.5) | 1280 1024 | 3 | 0.0 |
| normal-z-line | 500 (12.5) | 1280 1024 | 3 | 0.0 |
| Class | Precision | Recall | F1-score | Support |
|---|---|---|---|---|
| dyed-lifted-polyps | 0.936 | 0.880 | 0.907 | 50 |
| dyed-resection-margins | 0.889 | 0.960 | 0.923 | 50 |
| esophagitis | 0.857 | 0.840 | 0.848 | 50 |
| normal-cecum | 0.980 | 1.000 | 0.990 | 50 |
| normal-pylorus | 0.962 | 1.000 | 0.980 | 50 |
| normal-z-line | 0.843 | 0.860 | 0.851 | 50 |
| Class | Precision | Recall | F1-score | Support |
|---|---|---|---|---|
| dyed-lifted-polyps | 1.000 | 0.860 | 0.925 | 50 |
| dyed-resection-margins | 0.877 | 1.000 | 0.935 | 50 |
| esophagitis | 0.875 | 0.840 | 0.857 | 50 |
| normal-cecum | 0.962 | 1.000 | 0.980 | 50 |
| normal-pylorus | 0.980 | 1.000 | 0.990 | 50 |
| normal-z-line | 0.846 | 0.880 | 0.863 | 50 |
| Metric | ResNet50 [95% CI] | ViT-B/16 [95% CI] |
|---|---|---|
| Correct predictions | 375 / 400 | 369 / 400 |
| Overall accuracy (Wilson CI) | 93.75% [90.94, 95.73] | 92.25% [89.21, 94.49] |
| Macro-averaged F1 (bootstrap CI) | 0.937 [0.913, 0.960] | 0.922 [0.895, 0.947] |
| Accuracy difference (R50 ViT), 95% paired bootstrap CI | +1.50 pp [ 0.50, +3.50] | (paired) |
| 90% CI for the difference / TOST p ( 3 pp) | [0.00, +3.25] / 0.066 | (paired) |
| McNemar exact p / 2 (continuity-corrected) | p = 0.21 | 2 = 1.56 |
| Models | ViT correct | ViT incorrect |
|---|---|---|
| ResNet50 correct | 364 | 11 |
| ResNet50 incorrect | 5 | 20 |
| McNemar’s test | 2 (cc) = 1.56 | exact p = 0.21 |
| Class | ResNet50 F1 [95% CI] | ViT-B/16 F1 [95% CI] |
|---|---|---|
| dyed-lifted-polyps | 0.92 [0.86, 0.98] | 0.91 [0.84, 0.96] |
| dyed-resection-margins | 0.93 [0.88, 0.98] | 0.92 [0.86, 0.97] |
| esophagitis | 0.86 [0.78, 0.93] | 0.85 [0.76, 0.92] |
| normal-cecum | 0.98 [0.95, 1.00] | 0.99 [0.97, 1.00] |
| normal-pylorus | 0.99 [0.97, 1.00] | 0.98 [0.95, 1.00] |
| normal-z-line | 0.86 [0.78, 0.93] | 0.85 [0.77, 0.92] |
| Metric | ResNet50 | ViT-B/16 |
|---|---|---|
| Fold-wise accuracy, mean SD (%) | 92.13 0.76 | 91.70 0.72 |
| Fold-wise macro-F1, mean SD ( 100) | 92.10 0.78 | 91.67 0.77 |
| Pooled out-of-fold accuracy [95% Wilson CI] (%) | 92.12 [91.25, 92.92] | 91.70 [90.80, 92.52] |
| Pooled accuracy (R50 ViT) [90% bootstrap CI] (pp) | +0.43 [ 0.33, +1.18] | (paired) |
| McNemar exact p (pooled; discordant 178 / 161) | 0.385 | (paired) |
| TOST p ( 3 pp) / smallest equivalence margin (pp) | <0.001 / 1.18 | (paired) |
| Metric | ResNet50 | ViT-B/16 | MobileViT-S |
|---|---|---|---|
| Test accuracy, primary split (%) | 93.75 | 92.25 | 95.50 |
| Macro-F1, primary split | 0.937 | 0.922 | 0.955 |
| Cross-validated accuracy (%) | 92.12 | 91.70 | — |
| External accuracy, GastroVision (%) | 78.08 | 79.63 | 78.33 |
| Parameters (M) / MACs (G) | 23.52 / 4.13 | 85.80 / 17.61 | 4.94 / 1.24 |
| GPU throughput, batch 32, FP32 (img/s) | 336.5 | 87.9 | 444.4 |
| Metric | ResNet50 | ViT-B/16 | MobileViT-S |
|---|---|---|---|
| Parameters (M) | 23.52 | 85.80 | 4.94 |
| MACs (G) | 4.13 | 17.61 | 1.24 |
| GPU latency, batch 1, FP32 (ms) | 5.4 [5.3–5.5] | 13.1 [13.1–13.4] | 7.6 [7.5–7.8] |
| GPU latency, batch 1, FP16 (ms) | 5.8 [5.7–5.9] | 5.9 [5.8–6.1] | 10.0 [9.9–10.2] |
| GPU throughput, batch 32, FP32 (img/s) | 336.5 | 87.9 | 444.4 |
| GPU throughput, batch 32, FP16 (img/s) | 762.8 | 288.6 | 662.5 |
| Metric | ResNet50 = 0.05 | ViT-B/16 = 0.05 | ResNet50 = 0 | ViT-B/16 = 0 | MobileViT-S | ResNet50 CV | ViT-B/16 CV |
|---|---|---|---|---|---|---|---|
| Accuracy | 0.938 [0.912, 0.960] | 0.922 [0.895, 0.948] | 0.938 [0.912, 0.960] | 0.938 [0.912, 0.960] | 0.955 [0.935, 0.975] | 0.921 [0.913, 0.929] | 0.917 [0.908, 0.926] |
| ECE, 15 equal-width bins | 0.025 [0.017, 0.050] | 0.039 [0.023, 0.065] | 0.045 [0.030, 0.071] | 0.050 [0.033, 0.075] | 0.032 [0.023, 0.054] | 0.021 [0.017, 0.030] | 0.023 [0.019, 0.032] |
| ECE, 10 equal-width bins | 0.025 [0.014, 0.048] | 0.020 [0.015, 0.049] | 0.039 [0.023, 0.064] | 0.050 [0.032, 0.074] | 0.031 [0.019, 0.052] | 0.017 [0.013, 0.026] | 0.018 [0.013, 0.026] |
| ECE, 15 equal-mass bins | 0.032 [0.030, 0.061] | 0.060 [0.047, 0.089] | 0.030 [0.018, 0.057] | 0.046 [0.025, 0.069] | 0.042 [0.035, 0.066] | 0.016 [0.014, 0.026] | 0.019 [0.017, 0.029] |
| Class-wise ECE | 0.017 [0.015, 0.024] | 0.017 [0.014, 0.023] | 0.015 [0.011, 0.021] | 0.015 [0.010, 0.021] | 0.013 [0.013, 0.019] | 0.013 [0.013, 0.015] | 0.011 [0.011, 0.014] |
| Brier score | 0.107 [0.071, 0.145] | 0.127 [0.086, 0.170] | 0.105 [0.069, 0.144] | 0.107 [0.068, 0.149] | 0.080 [0.050, 0.113] | 0.122 [0.110, 0.134] | 0.128 [0.116, 0.140] |
| Class | ResNet50 = 0.05 | ViT-B/16 = 0.05 | ResNet50 = 0 | ViT-B/16 = 0 | MobileViT-S | ResNet50 CV | ViT-B/16 CV |
|---|---|---|---|---|---|---|---|
| dyed-lifted-polyps | 0.020 [0.011, 0.035] | 0.010 [0.004, 0.025] | 0.017 [0.008, 0.029] | 0.015 [0.005, 0.028] | 0.012 [0.009, 0.021] | 0.010 [0.009, 0.015] | 0.008 [0.006, 0.013] |
| dyed-resection-margins | 0.019 [0.012, 0.033] | 0.014 [0.005, 0.026] | 0.016 [0.007, 0.029] | 0.013 [0.005, 0.024] | 0.015 [0.011, 0.024] | 0.010 [0.008, 0.014] | 0.010 [0.008, 0.015] |
| esophagitis | 0.025 [0.018, 0.044] | 0.029 [0.015, 0.047] | 0.028 [0.020, 0.048] | 0.031 [0.016, 0.048] | 0.019 [0.013, 0.036] | 0.014 [0.011, 0.020] | 0.009 [0.007, 0.016] |
| normal-cecum | 0.012 [0.009, 0.019] | 0.015 [0.011, 0.021] | 0.006 [0.002, 0.014] | 0.003 [0.000, 0.008] | 0.016 [0.011, 0.024] | 0.011 [0.010, 0.015] | 0.012 [0.011, 0.015] |
| normal-pylorus | 0.010 [0.007, 0.014] | 0.011 [0.007, 0.017] | 0.004 [0.001, 0.011] | 0.003 [0.000, 0.009] | 0.010 [0.006, 0.014] | 0.014 [0.014, 0.016] | 0.013 [0.012, 0.015] |
| normal-z-line | 0.029 [0.022, 0.047] | 0.023 [0.014, 0.043] | 0.027 [0.019, 0.047] | 0.031 [0.016, 0.048] | 0.016 [0.015, 0.035] | 0.017 [0.014, 0.023] | 0.010 [0.008, 0.016] |
| Model | Class | Sensitivity | FPR | Precision at 12.5% | PPV 1% | PPV 2% | PPV 5% | PPV 10% | PPV 20% |
|---|---|---|---|---|---|---|---|---|---|
| ResNet50 | esophagitis | 0.818 | 0.018 | 0.865 | 0.311 | 0.477 | 0.702 | 0.833 | 0.918 |
| ResNet50 | polyps | 0.948 | 0.011 | 0.924 | 0.462 | 0.635 | 0.817 | 0.904 | 0.955 |
| ResNet50 | ulcerative-colitis | 0.934 | 0.004 | 0.971 | 0.702 | 0.827 | 0.925 | 0.963 | 0.983 |
| ViT-B/16 | esophagitis | 0.812 | 0.014 | 0.892 | 0.369 | 0.542 | 0.753 | 0.866 | 0.935 |
| ViT-B/16 | polyps | 0.886 | 0.004 | 0.969 | 0.691 | 0.819 | 0.921 | 0.961 | 0.982 |
| ViT-B/16 | ulcerative-colitis | 0.972 | 0.014 | 0.910 | 0.417 | 0.591 | 0.789 | 0.887 | 0.947 |
| Metric | ResNet50 unadjusted | ResNet50 prior-shift corrected | ViT-B/16 unadjusted | ViT-B/16 prior-shift corrected |
|---|---|---|---|---|
| Accuracy | 0.930 [0.922, 0.938] | 0.944 [0.937, 0.951] | 0.934 [0.927, 0.942] | 0.948 [0.940, 0.954] |
| ECE, 15 equal-width bins | 0.025 [0.020, 0.033] | 0.021 [0.015, 0.028] | 0.026 [0.023, 0.033] | 0.023 [0.019, 0.029] |
| ECE, 10 equal-width bins | 0.021 [0.017, 0.029] | 0.020 [0.014, 0.027] | 0.027 [0.022, 0.034] | 0.021 [0.016, 0.028] |
| ECE, 15 equal-mass bins | 0.025 [0.020, 0.032] | 0.022 [0.018, 0.030] | 0.024 [0.020, 0.031] | 0.022 [0.019, 0.030] |
| Class-wise ECE | 0.016 [0.015, 0.018] | 0.012 [0.012, 0.015] | 0.016 [0.015, 0.018] | 0.010 [0.010, 0.013] |
| Brier score | 0.105 [0.095, 0.117] | 0.094 [0.084, 0.105] | 0.102 [0.093, 0.113] | 0.090 [0.080, 0.100] |
| Method | n | Pointing-game hit rate | Energy-in-lesion | Chance level (lesion area) | IoU (top-20% map) |
|---|---|---|---|---|---|
| ResNet50 Grad-CAM | 500 | 0.868 [0.838, 0.896] | 0.553 [0.533, 0.573] | 0.154 [0.143, 0.165] | 0.396 [0.380, 0.412] |
| ViT-B/16 Grad-CAM | 500 | 0.728 [0.688, 0.766] | 0.575 [0.552, 0.599] | 0.154 [0.143, 0.165] | 0.350 [0.333, 0.367] |
| ViT-B/16 attention rollout | 500 | 0.624 [0.582, 0.666] | 0.325 [0.309, 0.340] | 0.154 [0.142, 0.165] | 0.337 [0.323, 0.350] |
| ResNet50 SHAP | 50 | 0.500 [0.360, 0.640] | 0.270 [0.221, 0.323] | 0.161 [0.122, 0.204] | 0.207 [0.179, 0.235] |
| ViT-B/16 SHAP | 50 | 0.500 [0.360, 0.640] | 0.252 [0.206, 0.301] | 0.161 [0.124, 0.203] | 0.173 [0.150, 0.197] |
| ResNet50 LIME | 50 | 0.600 [0.460, 0.740] | 0.431 [0.365, 0.495] | 0.161 [0.123, 0.203] | 0.301 [0.255, 0.349] |
| Model | n | Accuracy, original (%) | Accuracy, inset occluded (%) | Prediction flips (%) | Lost / gained | McNemar exact p |
|---|---|---|---|---|---|---|
| ResNet50 | 149 | 95.30 | 93.96 | 4.7 | 4 / 2 | 0.69 |
| ViT-B/16 | 149 | 93.29 | 89.26 | 8.1 | 9 / 3 | 0.15 |
| MobileViT-S | 149 | 96.64 | 87.25 | 10.7 | 14 / 0 | <0.001 |
| Method | Attribution mass on the inset | Inset area fraction (chance level) | Ratio to chance |
|---|---|---|---|
| ResNet50 Grad-CAM | 0.217 | 0.183 | 1.19 |
| ResNet50 LIME | 0.242 | 0.183 | 1.32 |
| ResNet50 SHAP | 0.248 | 0.183 | 1.36 |
| ViT-B/16 Grad-CAM | 0.133 | 0.183 | 0.73 |
| ViT-B/16 LIME | 0.203 | 0.183 | 1.11 |
| ViT-B/16 SHAP | 0.151 | 0.183 | 0.82 |
| Class | n (prevalence) | ResNet50 | ViT-B/16 | MobileViT-S |
|---|---|---|---|---|
| dyed-lifted-polyps | 137 (6.9%) | 0.839 | 0.920 | 0.920 |
| dyed-resection-margins | 233 (11.7%) | 0.927 | 0.923 | 0.914 |
| esophagitis | 102 (5.1%) | 0.647 | 0.677 | 0.569 |
| normal-cecum | 103 (5.2%) | 0.825 | 0.864 | 0.786 |
| normal-pylorus | 365 (18.3%) | 0.671 | 0.871 | 0.836 |
| normal-z-line | 313 (15.7%) | 0.713 | 0.671 | 0.744 |
Medical Image Classification
Medical image classification uses computational models to identify diseases, grade severity, and support decisions from clinical images.
See all 503 papers