# On-Edge Deployment of Vision Transformers for Medical Diagnostics Using the Kvasir-Capsule Dataset
## 1 Introduction  
The use of medical datasets for training image classification models has been in constant growth ever since the introduction of large-scale neural networks [1], aided by advancements in hardware and computing. Although increasing model performance traditionally comes with the cost of higher complexities, different applications led to the creation of frameworks designed to implement lightweight models that maintain high performance. One well-used framework is the TensorFlow Lite (TFLite) framework, built on the TensorFlow (TF) software library for machine learning [2]. Correct predictions in neural network (NN) models are critical, especially within the medical domain. Maintaining high classification performance without human intervention remains of utmost importance, as incorrect classification could be a matter of life or death for a patient [3]. As a result, models tend to be both large (in terms of size and parameters) and complex [4]. Given recent advancements in image classification tasks particularly based on transformer architectures, this paper explores the downsizing of vision transformer (ViT)-based models for the sake of easy on-hand deployment, broadening the applications and potential implementations of medical image classifiers, whilst attempting to retain the respective performance metrics. In particular, our study aims at using state-of-the-art ViT-based classifiers designed for implementation on edge devices and studying theirperformance--a task that currently has little exploration in the medical domain given the novelty of ViTs, introduced only in 2021 [5]. Given the lack of explainability in deep learning models as a whole, neural network classifiers tend to suffer from large memory allocations and a significantly greater number of weights. This makes them a rather unfavorable approach for on-device deployment, especially as far as edge devices are concerned [6]. With the growing applications of classifiers for a variety of medical-domain applications in edge devices, quantization has emerged as an extremely fast-growing area of research that dates back to 2015 [7]. Although quantization as a concept can be approached in many ways, the two main types are post-training quantization and training-aware quantization models. In this study, we aim to focus on two techniques for quantization: float-16 (F16) quantization (a post-training technique) and quantization-aware training (QAT) [8]. Specifically, we present our findings using the Kvasir-Capsule [9] dataset, a large-scale image dataset collected from medical wireless capsule endoscopies (WCEs). Kvasir-Capsule has been curated and is focused on classifying gastrointestinal anomalies along the digestive tract. By doing so, we aim to develop quantized models using TFLite to compare the performance pre- and post-quantization, giving us a good overview of how \"small\" a model can be before the performance is deemed less than adequate. As evident within the literature that will be presented, there are currently no known TFLite implementations of ViTs on Kvasir-Capsule, which is where the novelty of this paper is highlighted best. The main contributions of this study can be summarized as follows:  
1. Conduct a comprehensive evaluation of several state-of-the-art transformer-based CNN architectures specifically built for on-hand deployment on the Kvasir-Capsule dataset, namely, EfficientViT, MobileViT, EfficientFormer, and RepViT;
2. Compare model performance based on different quantization methods available within the TFLite framework, namely, F16 quantization and QAT. The remainder of this paper is structured as follows: We begin with Section 2, examining the literature in the field, specifically looking at classification models trained on the Kvasir-Capsule dataset. Section 3 gives more context on the dataset, the models chosen, and the methodology used in the paper, whilst Section 4 presents our findings, divided into the performance metrics of the models in general and then the metrics of the model deployed on phones.