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)