# LungVision: X-ray Imagery Classification for On-Edge Diagnosis Applications
###### Abstract  
This study presents a comprehensive analysis of utilizing TensorFlow Lite on mobile phones for the on-edge medical diagnosis of lung diseases. This paper focuses on the technical deployment of various deep learning architectures to classify nine respiratory system diseases using X-ray imagery. We propose a simple deep learning architecture that experiments with six different convolutional neural networks. Various quantization techniques are employed to convert the classification models into TensorFlow Lite, including post-classification quantization with floating point 16 bit representation, integer quantization with representative data, and quantization-aware training. This results in a total of 18 models suitable for on-edge deployment for the classification of lung diseases. We then examine the generated models in terms of model size reduction, accuracy, and inference time. Our findings indicate that the quantization-aware training approach demonstrates superior optimization results, achieving an average model size reduction of 75.59%. Among many CNNs, MobileNetV2 exhibited the highest performance-to-size ratio, with an average accuracy loss of 4.1% across all models using the quantization-aware training approach. In terms of inference time, TensorFlow Lite with integer quantization emerged as the most efficient technique, with an average improvement of 1.4 s over other conversion approaches. Our best model, which used EfficientNetB2, achieved an F1-Score of approximately 98.58%, surpassing state-of-the-art performance on the X-ray lung diseases dataset in terms of accuracy, specificity, and sensitivity. The model experienced an F1 loss of around 1% using quantization-aware optimization. The study culminated in the development of a consumer-ready app, with TensorFlow Lite models tailored to mobile devices. m 202417280. [[https://doi.org/10.3390/a1707028](https://doi.org/10.3390/a1707028)]([https://doi.org/10.3390/a1707028](https://doi.org/10.3390/a1707028))  
restrictions of these devices. For instance, Android's Google Play enforces an application size limitation of 200 MB at max [9], while the App Store of IOS has a slightly higher bound of 500 MB [10]. In practice, the application size can influence the user satisfaction, device performance, and storage capacity. As a result, developers aim towards reducing the size of the application as much as possible without compromising on the quality of the application. These consequences explain the fact that the average android application has a size of around 12 MB, while IOS applications have an average size of 35 MB [11], which are far below the maximum application size restrictions enforced by the respective operating systems. In general, deep learning models suffer from a lack of explainability, leading to an uncertainty in the reliability of real-world systems. This problem is addressed in [12] by adding a reliability estimate to the predictions of the generated models and modelling aleatoric and epistemic uncertainties in the deep learning models. Neural network models tend to have a high number of weights (parameters) that rarely go below a million. Consequently, a trained model is stored along with all its associated weights, resulting in a large model size. This makes it infeasible to have a functional neural network model within your application build. For this reason, many developers opt for having the neural network on an external resource, such as a database or a cloud [13]. However, external resources decrease the security of the diagnosis process, given the possibility of data leakage, privacy breaches, or unintentional third-party access to patients' records. A more reasonable solution is model quantization [14], where the way in which weights are stored is altered to reduce the size of the model, with minimal impact on the overall performance. Quantization can be carried out through storing the weights in smaller formats than the usual float-32, such as float-16, int-8, or even int-4 in some cases.