The implementation of yolov5s on android for the yolov5s export contest
The yolov5 android is the implementation of yolov5s on android for the yolov5s export contest. It was created by a developer named David Salazar and it won first place in the competition.
The yolov5s export contest required the development of yolov5s on Android. Install the most recent Android apk from release on your device.
Environment
- Install Ubuntu 18.04 on your computer.
- Docker
- Tensorflow 2.4.0 is a version of Tensorflow that was released in
- PyTorch 1.7.0 is the latest version of PyTorch.
- 2021.3 OpenVino
- App for Android
- 4.2.1 of Android Studio
- minSdkVersion 28 minSdkVersion 28 minSdkVersion 28
- targetSdkVersion 29 targetSdkVersion 29 targetSdkVersion 29
- TfLite version 2.4.0
- Android Operating System
- Xiaomi Mi11 (128GB storage, 8GB RAM)
- MUI 12.5.8 is the operating system.
For host assessment and model conversion, we utilize a Docker container.
—recursive git clone cd yolov5s android docker build./ -f./docker/Dockerfile -t yolov5s android docker https://github.com/lp6m/yolov5s android yolov5s anrdoid bash run -it —gpus all -v pwd:/workspace
Files
- ./app
- This is an Android application.
- Copy./tflite model/*.tflite to app/tflite yolov5 test/app/src/main/assets/ and compile it using Android Studio.
- The software can infer with a variety of input sizes, inference accuracy, and model accuracy settings.
- Save the identified bounding box results as a json file in coco format for ‘Open Directory Mode.’
- Real-time detection from a camera picture (int8/320 precision and input size). On Mi11, the achieved FPS is about 15FPS.
- NOTE From the ‘Device’ menu, choose image/directory as an absolute path. In certain devices, the app does not allow you to choose a picture or directory from the ‘Recent’ section.
- ./benchmark
- ./convert model
- Model quantization script and model conversion instructions.
- ./docker
- The assessment and model conversion environment is set up using a Dockerfile.
- ./host
- detect.py: On the host environment, run image detection with the TfLite model.
- evaluate.py: Use the coco validation dataset and inference findings to do an evaluation.
- ./tflite model
Performance
Latency
The Xiaomi Mi11 was used to get these findings. For further information on the benchmark command, see benchmark/README.md. The pre/post processing time and data transmission time are not included in the latency.
model float32
delegate | [ms] 640640 | [ms] 320 320 |
---|---|---|
None at all (CPU) | 249 | 61 |
NNAPI is a non-profit organization that promotes (qti-gpu, fp32) | 156 | 112 |
NNAPI is a non-profit organization that promotes (qti-gpu, fp16) | 92 | 79 |
model int8
We attempted to speed up the inference process by utilizing NNAPI is a non-profit organization that promotes (qti-dsp) and offloading the computation to Hexagon DSP, however this did not work at this time. Please have a look at this page in detail.
delegate | [ms] 640640 | [ms] 320 320 |
---|---|---|
None at all (CPU) | 95 | 23 |
NNAPI is a non-profit organization that promotes (qti-default) | It’s not functioning. | It’s not functioning. |
NNAPI (qti-dsp) | It’s not functioning. | It’s not functioning. |
Accuracy
The assessment technique is described in host/README.md. For the nms parameter, we set conf thresh=0.25 and iou thresh=0.45.
a gadget, a model, and a delegate | 640 mAP 640 mAP 640 mAP 640 mAP | 320 mAP 320 mAP 320 mAP 320 mAP |
---|---|---|
fp32 host GPU (Tflite + PyTorch) | 27.8 | 26.6 |
host CPU (int8, Tflite + PyTorch) | 26.6 | 25.5 |
NNAPI is a non-profit organization that promotes (qti-gpu, fp16) | 28.5 | 26.8 |
the central processing unit (int8) | 27.2 | 25.8 |
Conversion of models
Rather than creating a tflite model from scratch, this project focuses on converting a model from PyTorch’s original implementation. This is how we transform models: ONNX -> OpenVino -> TfLite -> PyTorch We use openvino2tensorflow to transform the model from OpenVino to TfLite. The model conversion is described in convert model/README.md.
GitHub
https://github.com/lp6m/yolov5s android
The yolov5 tutorial is a tutorial that was implemented for the yolov5 export contest. It teaches how to implement the algorithm on android.
Related Tags
- yolov5 tflite
- yolov5 export onnx
- yolov5 tensorflow
- tf addv2 op is neither a custom op nor a flex op
- yolov5 weights download