Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App: Support Yolov8 model #38

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,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 @@ -134,14 +136,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