Skip to content

Commit

Permalink
App/Activity: Support Yolov8 model
Browse files Browse the repository at this point in the history
This patch adds yolov8 ml offloading.
Tensor query client has to decode the result which server sends.

Signed-off-by: Yelin Jeong <[email protected]>
  • Loading branch information
niley7464 authored and wooksong committed Jun 15, 2024
1 parent 567b179 commit 6cdba2b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ class MainActivity : ComponentActivity() {
inner class ModelViewHolder(itemView: View) :
RecyclerView.ViewHolder(itemView) {
fun bind(info: ModelInfo) {
val name = itemView.findViewById<TextView>(R.id.name)
val start = itemView.findViewById<Button>(R.id.start)
val stop = itemView.findViewById<Button>(R.id.stop)
val port = itemView.findViewById<TextView>(R.id.port)

name.text = info.name
start.setOnClickListener(View.OnClickListener {
val serverPort = mService?.startServer(info.name, info.filter)
port.text = "Listening on port: " + serverPort.toString();
Expand Down Expand Up @@ -120,14 +122,22 @@ class MainActivity : ComponentActivity() {
// todo: Use database instead of just ArrayList
val modelList = ArrayList<ModelInfo>()
val path = getExternalFilesDir(null)!!.absolutePath

val mobileNet = File("$path/mobilenet_v1_1.0_224_quant.tflite")
val filter = "other/tensor,format=static,dimension=(string)3:224:224:1,type=uint8,framerate=0/1 ! " +
"tensor_filter framework=tensorflow-lite model=" + mobileNet.getAbsolutePath() + " ! " +
val mobileNetFilter = "other/tensor,format=static,dimension=(string)3:224:224:1,type=uint8,framerate=0/1 ! " +
"tensor_filter framework=tensorflow-lite model=" + mobileNet.absolutePath + " ! " +
"other/tensor,format=static,dimension=(string)1001:1,type=uint8,framerate=0/1"

val mobileNetInfo = ModelInfo("MobileNet", filter)
val mobileNetInfo = ModelInfo("MobileNet", mobileNetFilter)
modelList.add(mobileNetInfo)

val yolov8 = File("$path/yolov8s_float32.tflite")
val yolov8Filter = "other/tensors,num_tensors=1,format=static,dimensions=3:224:224:1,types=float32,framerate=0/1 ! " +
"tensor_filter framework=tensorflow-lite model=" + yolov8.absolutePath + " ! " +
"other/tensors,num_tensors=1,types=float32,format=static,dimensions=1029:84:1,framerate=0/1"

val yolov8Info = ModelInfo("Yolov8", yolov8Filter)
modelList.add(yolov8Info)

val recyclerView = findViewById<RecyclerView>(R.id.model_list)
recyclerView.adapter = ModelAdapter(modelList)
recyclerView.layoutManager = LinearLayoutManager(this, )
Expand Down
4 changes: 4 additions & 0 deletions ml_inference_offloading/src/main/res/layout/models.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<Button
android:id="@+id/start"
android:layout_width="wrap_content"
Expand Down

0 comments on commit 6cdba2b

Please sign in to comment.