ONNX Runtime Mobile QuestionAnswering Android sample application with Ort-Extensions support for pre/post processing
This is a basic QuestionAnswering example application for ONNX Runtime on Android with Ort-Extensions support for pre/post processing. The demo app accomplishes the task of answering the question provided by users.
The model used here is from the source: HuggingFace](https://huggingface.co/docs/transformers/model_doc/mobilebert) and accommodated into ONNX version with pre/post processing support.
- Android Studio Dolphin | Android Studio Electric Eel | 2022.1.1 Patch 2+ (installed on Mac/Windows/Linux)
- Android SDK 29+
- Android NDK r22+
- An Android device or an Android Emulator
Clone this repository to get the sample application.
[email protected]:microsoft/onnxruntime-inference-examples.git
- The model used is under
mobile\examples\question_answering\android\app\src\main\res\raw
.
prepare_models.py
in the directory will do the model-preparing work. The whole procedure includes four steps.
- download model from huggingface.
- convert model to onnx.
- quantize onnx model.
- add pre/post processing to onnx model.
NOTE: Please install onnxruntime-extensions package following this according to your platform.
This script works for both Mac and Linux by default. If you want to work it in windows, you should prepare the environment by yourself and run prepare_models.py
in windows.
Model will be placed at mobile\examples\question_answering\android\app\src\main\res\raw
automatically.
cd mobile/examples/question_answering/android
bash prepare_models.sh
Connect your Android Device to your computer or select the Android Emulator in Android Studio Device manager.
Then select Run -> Run app
and this will prompt the app to be built and installed on your device or emulator.
Now you can try and test the question answering android app by clicking the ">" action button.
Here are some sample example screenshots of the app.