Hi BentoML team, here I want build a simple "hello...
# ask-for-help
p
Hi BentoML team, here I want build a simple "hello word" NN model using TensorFlow. Then I want to serve it using BentoML. The serving are success, but it says the Runner object has no attribute 'predict'. Can someone help me or give me advise about this? Thanks in advance.
model.py
Copy code
import tensorflow as tf
import keras
import numpy as np
import bentoml

X = np.array([-1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0], dtype=float)
Y = np.array([0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5], dtype=float)

model = keras.models.Sequential([
    keras.layers.Dense(1, input_shape=(1,))
])

model.compile(optimizer='sgd', loss='mean_squared_error')
model.fit(X, Y, epochs=500, batch_size=1)

print(model.predict([6.0]))

saved_model = bentoml.tensorflow.save_model('linreg', model)
service.py
Copy code
import numpy as np
import bentoml
from <http://bentoml.io|bentoml.io> import NumpyNdarray

runner = bentoml.tensorflow.get("linreg:latest").to_runner()
svc = bentoml.Service(name="linreg_service", runners=[runner])

@svc.api(input=NumpyNdarray(), output=NumpyNdarray())
def predict(input_series: np.ndarray):
    return runner.run(input_series)