# Classification of OCT Images of the Human Eye Using Mobile Devices
## 3 Android-Based Application for OCT Classification
### Implementing Neural Networks in a Mobile Application  
Three different methods of model conversion were analyzed to implement neural networks for image classification on mobile devices: TensorFlow Lite (TF Lite), ONNX, and Firebase ML. Their advantages and disadvantages are discussed below. TensorFlow Lite is a solution that converts TensorFlow models to a smaller, more efficient machine learning format. In this solution, one can use:  
* pre-trained models from TensorFlow Lite;
* modify existing models;
* build one's own TensorFlow models, then convert them to the TensorFlow Lite format. The TensorFlow Lite [19] model is represented in an efficient, portable FlatBuffers format (files with the _.tflite_ extension). This allows for reduced size and faster inference (via direct access to data without additional analysis/unpacking steps). This solution enables efficient operation on devices with limited computational and memory resources. The advantages and disadvantages of this method are discussed in Table 4. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Layer Type** & **Output Shape** & **Filter Size** & **Drop Fraction** & **Activation** & **Parameters Number** \\ \hline Image & \(224\times 224\times 3\) & — & — & — & — \\ Convolution 2D & \(222\times 222\times 32\) & \(3\times 3\) & — & ReLU & 896 \\ MaxPooling2D & \(111\times 111\times 32\) & \(2\times 2\) & — & — & — \\ Dropout & \(111\times 111\times 32\) & — & 0.25 & — & — \\ Convolution 2D & \(109\times 109\times 64\) & \(3\times 3\) & — & ReLU & 18,496 \\ Dropout & \(109\times 109\times 64\) & — & 0.25 & — & — \\ Convolution 2D & \(107\times 107\times 128\) & \(3\times 3\) & — & ReLU & 73,856 \\ Dropout & \(107\times 107\times 128\) & — & 0.4 & — & — \\ Flatten & \(1\times 1\),465,472 & — & — & — & — \\ Dense & \(1\times 128\) & — & — & ReLU & 187,580,544 \\ Dropout & \(1\times 128\) & — & 0.4 & — & — \\ Dense & \(1\times 5\) & — & — & Softmax & 645 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Structure of tested 3-layer CNN. The generation of a network model in the _.tflite_ format can be performed using the TensorFlow Lite Model Maker library. This library, using Transfer Learning, reduces the amount of training data required and shortens training time. Another solution is to build a TensorFlow model and use the TensorFlow Lite Converter. In this case, it is possible to optimize the model, for example, through quantization, to adapt the model for operation on a mobile device. \begin{table}
\begin{tabular}{p{142.3 pt} p{142.3 pt} p{142.3 pt}} \hline \hline
**Advantages** & **Disadvantages** \\ \hline \(\bullet\) & low processing time (no data transfer to the server, no waiting for results to be returned) & \(\bullet\) & limited computing capabilities—lower computing power compared to full-featured multi-processor servers \\ \(\bullet\) & privacy (no personal data leave the device, can be performed on sensitive data) & \(\bullet\) & limited model size—the size of the model (its overall complexity, including data preprocessing logic and the number of layers in the model) must be limited to avoid excessively slow performance, and the models fit within the limited memory of the mobile or edge device \\ \(\bullet\) & support for various languages, including C++, Python (version 3.5 and higher) & \(\bullet\) & limited data size—with large data libraries, the data may need to be stored and accessed off-device \\ \(\bullet\) & high performance thanks to hardware acceleration and model optimization & \(\bullet\) & fewer supported TensorFlow operations—TensorFlow Lite has a smaller subset of model operations compared to TensorFlow (requires ensuring original model compatibility with the capabilities of TensorFlow Lite runtimes) \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Advantages and disadvantages of TensorFlow Lite.