Android
Deploy your On-device AI application to Android Studio
Deploy your own On-device AI Android application easily. MLange supports both Kotlin and Java implementations.
Prerequisites
Before you begin, make sure you have:
- Model Key: Prepare using Web Dashboard (SaaS) or CLI method
- Personal Key: Prepare using Web Dashboard (SaaS) method
Step-by-step Guide
Add ZeticMLange dependency
build.gradle
android {
...
packagingOptions {
jniLibs {
useLegacyPackaging true
}
}
}
dependencies {
implementation 'com.zeticai.mlange:mlange:+'
}build.gradle.kts
android {
...
packaging {
jniLibs {
useLegacyPackaging = true
}
}
}
dependencies {
implementation("com.zeticai.mlange:mlange:+")
}Initialize and run ZeticMLangeModel
// (1) Load Zetic MLange model
val model = ZeticMLangeModel(CONTEXT, PERSONAL_KEY, PROJECT_NAME)
// (2) Prepare model inputs
val inputs: Array<Tensor> = // Prepare your inputs
// (3) Run and get output tensors of the model
val outputs = model.run(inputs)// (1) Load Zetic MLange model
ZeticMLangeModel model = new ZeticMLangeModel(CONTEXT, PERSONAL_KEY, PROJECT_NAME);
// (2) Prepare model inputs
Tensor[] inputs = // Prepare your inputs;
// (3) Run and get output buffers of the model
Tensor[] outputs = model.run(inputs);Sample Application
Please refer to ZETIC MLange Apps repository for complete sample applications and more details.