Search code examples
androidgoogle-colaboratory

Adding an ML model into Android Studio


I have written an ML model using Keras in Google Colab which detects whether an animal is a cat or a dog based on an input image.

Now, I want to create an app in Android Studio that takes an image as input, uses the algorithm I have designed to detect whether the image is a cat or a dog and outputs the result.

My question is how can I incorporate this algorithm into Android Studio? My first thought was to rewrite the code in Java and copy it into Android Studio but writing Java in Google Colab would lead to multiple complications. Hence, is there a way to download the algorithm I have created and upload it into Android Studio such that it works? If not, what other approach can I implement?

My desired outcome is something where I can add the algorithm into Android Studio and write a code like:

if (algorithm == true)
    //output dog detected
else
    //output cat detected

Solution

  • Android Studio is just an IDE. It doesn't run the actual code. And no, it doesn't run Python.

    You should be able to export the Keras model into a offline format that Android can use via Tensorflow; Keras deep learning model to android

    Alternatively, to deploy an "online model", you'd run a hosted web-server that exposed the model over HTTP, which your Android code would send in requests to and parse the response.