0

Objective - I am working on a movie recommendation mobile application in Flutter which will ask for the user's favourite movie and will then recommend a bunch of other similar movies using machine learning model.

Problem - The Flutter application is ready, the model to recommend movies is also ready but the only problem here is the deployment of the model i.e how am I supposed to use my model with my Flutter application.

My Solution - I have figured out two methods -

The one which is working -

Either creating and hosting a Web API Service (say using flask) and calling the API Service from my Flutter application to fetch the result.

The one which is not working -

But on the other way if I use the Firebase Ml Kit there are few pre-defined ready to use models also there is one option to upload your own custom model but I could not find any informative material regarding how to use my own custom model with flutter. The examples and the videos which I have referred were using custom models but for Image Processing and Text Recognition etc. It will be a great help if anybody can throw some light on how to use your own model with flutter.

For Example, If I want to use the below model with flutter what will be the procedure for that..

import tensorflow as tf
import numpy as np
from tensorflow import keras
model = keras.Sequential([keras.layers.Dense(units=1,input_shape =[1])])
model.compile(optimizer='sgd',
          loss='mean_squared_error',
          metrics=['accuracy'])
xs = np.array([-1.0,0.0,1.0,2.0,3.0,4.0])
ys = np.array([-3.0,-1.0,0.0,3.0,5.0,7.0])
model.fit(xs,ys,epochs=500)
print(model.predict([10.0]))
keras_file = "test.tf"
keras.models.save_model(model,keras_file)
4
  • Hi, Akhil Shukla, were you able to implement the model in flutter Commented Jan 20, 2021 at 5:17
  • Hi Sravan , No I wasn't able to accomplish that using Flutter ML library but rather created a flask API and hosted my model into it and finally used Http library in flutter to call the API. Commented Jan 22, 2021 at 17:25
  • Akhil Shukla, I was able to implement the model in firebase. All, we need is tflite model. this is my github link. - github.com/SravanKumar35/Flutter-ML-Model-Integration Commented Jan 23, 2021 at 7:47
  • Thanks a lot Sravan for your help. I will refer from your repository. Commented Jan 23, 2021 at 18:00

1 Answer 1

2

You can use the firebase_ml_custom plugin to manage hosting the model and downloading it to user's device.

Sign up to request clarification or add additional context in comments.

1 Comment

Are you still using this package? How did you get past the outdated firebase dependencies?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.