Skip to content

Conversation

@luhmirin-s
Copy link
Collaborator

This started as a spike to see if it is possible, but turned into a pretty nice future-proof solution. Here are the main changes:

  • Removed the generated model bindings in favour of more manual model handling.
  • Added a custom model file argument to the configuration. The template version is also provided to ensure there is a built-in mechanism for the caller to know which model was used.
  • Change the model manager to either load the provided file or fall back to the model file provided in the assets.

Benefits of this change:

  • It would allow SID to have a model file download mechanism and then provide those files to SimFace based on the project configuration. This, in turn, allows us to have per-project tuned models configured and managed separately from the SimFace.
  • It greatly simplifies the process of debugging the model files in unit/android tests.

@luhmirin-s luhmirin-s requested review from Thinkorswim and gstrag May 30, 2025 10:59
@luhmirin-s luhmirin-s force-pushed the feature/MS-990-custom-model-support branch 5 times, most recently from 0c144cc to 649442f Compare May 30, 2025 12:15
@luhmirin-s luhmirin-s force-pushed the feature/MS-990-custom-model-support branch from 649442f to bd27df7 Compare May 30, 2025 12:20
Copy link
Collaborator

@Thinkorswim Thinkorswim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Might be useful to separate the files in androidTest into tests and utilities folders to make it a bit cleaner.

assertArrayEquals(GOOD_FACE_EMBEDDING, resultFloat, 0.1F)
}

private fun openTestModelFile(resourceName: String = "edgeface_test"): File {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we extract this logic into a separate utils file? It seems like it could be reusable across future tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed into an extention method of Context and moved to TestContextExt.

return tempFile
}

private fun getFaceEmbeddingFromBitmap(bitmap: Bitmap): FloatArray = simFace
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with this, otherwise not really useful to have it as a separate function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty specific for this test class. It was extracted into a function to make the test case easier to read.

Copy link
Collaborator

@gstrag gstrag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvements!

@luhmirin-s luhmirin-s merged commit e7f4ffe into main Jun 12, 2025
2 checks passed
@luhmirin-s luhmirin-s deleted the feature/MS-990-custom-model-support branch June 12, 2025 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants