How to use my Huggingface model in Kotlin app (production, MVP)?

Hi
I have a simple website using Jeremy JS code in order to use my model in web app.You can check it here :slight_smile:
https://mydopeideas.com/equip.html

However , I like to use this API with Kotlin in android native app ? Anyone have a good resources I could check ?

I also have a problem with model , how I make my model a way that if the image is not in those categories it says wrong image or something ?

You can convert your model to ONNX, TFLite or Torchscript. There’s an informative thread over here: From simple imageClassification model to android/ios app? - #7 by dnth

With respect to the “out of domain” question, there’s three options (top of my head):

  1. hope the model predicts out of domain images with low confidence, but I have rarely seen this to be the case.
  2. Create an additional category filled with out of domain images. Could work, but creates the burden of deciding what images go into that category.
  3. Use BCEWithLogitsLossFlat loss, there’s good write up in walkwithfastai: Lesson 3 - Unknown Labels (Pets Revisited) | walkwithfastai

Curious to know the results :slight_smile:

1 Like

@bahman_apl

If you’re open to hosting your model in the cloud it’s easier to get larger models to work on mobile.

In my other blog, I hosted my model on Hugging Face Spaces and call the model endpoint in my app. The app was made using Flutter so it works on iOS and Android. It can even be made to work as a web app. But I’ve not tried this.

The plus point of doing this is that you don’t have to deal with model conversion, optimizing model on your device, etc.