File tree Expand file tree Collapse file tree
core/src/main/java/com/fpf/smartscansdk/core/embeddings
ml/src/main/java/com/fpf/smartscansdk/ml/models/providers/embeddings Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import android.graphics.Bitmap
55
66interface IEmbeddingProvider <T > {
77 val embeddingDim: Int
8+ suspend fun initialize ()
9+ fun isInitialized (): Boolean
810 fun closeSession () = Unit
911 suspend fun embed (data : T ): FloatArray
1012 suspend fun embedBatch (data : List <T >): List <FloatArray >
Original file line number Diff line number Diff line change @@ -29,9 +29,9 @@ class ClipImageEmbedder(
2929 override val embeddingDim: Int = 512
3030 private var closed = false
3131
32- suspend fun initialize () = model.loadModel()
32+ override suspend fun initialize () = model.loadModel()
3333
34- fun isInitialized () = model.isLoaded()
34+ override fun isInitialized () = model.isLoaded()
3535
3636 override suspend fun embed (data : Bitmap ): FloatArray = withContext(Dispatchers .Default ) {
3737 if (! isInitialized()) throw IllegalStateException (" Model not initialized" )
Original file line number Diff line number Diff line change @@ -42,9 +42,9 @@ class ClipTextEmbedder(
4242 override val embeddingDim: Int = 512
4343 private var closed = false
4444
45- suspend fun initialize () = model.loadModel()
45+ override suspend fun initialize () = model.loadModel()
4646
47- fun isInitialized () = model.isLoaded()
47+ override fun isInitialized () = model.isLoaded()
4848
4949 override suspend fun embed (data : String ): FloatArray = withContext(Dispatchers .Default ) {
5050 if (! isInitialized()) throw IllegalStateException (" Model not initialized" )
Original file line number Diff line number Diff line change @@ -29,11 +29,11 @@ class MiniLMTextEmbedder(
2929 private var closed = false
3030 override val embeddingDim: Int = 384 // MiniLM-L6-v2 dimension
3131
32- suspend fun initialize () {
32+ override suspend fun initialize () {
3333 model.loadModel()
3434 }
3535
36- fun isInitialized () = model.isLoaded()
36+ override fun isInitialized () = model.isLoaded()
3737
3838 override suspend fun embed (data : String ): FloatArray = withContext(Dispatchers .Default ) {
3939 if (! isInitialized()) throw IllegalStateException (" Model not initialized" )
You can’t perform that action at this time.
0 commit comments