For general-purpose Custom Deployment instructions, click here
First spin up a Jupyter server
After your Jupyter server is ready click Go to JupyterLab.
os.system('python3 -m pip install flask')
from flask import Flask, escape, request
from tensorflow.keras.applications.resnet50 import ResNet50
from tensorflow.keras.preprocessing import image
from tensorflow.keras.applications.resnet50 import preprocess_input, decode_predictions
import numpy as np
model = ResNet50(weights='imagenet')
app = Flask(__name__)
img_path = 'dog.jpg'
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)
preds = model.predict(x)
# decode the results into a list of tuples (class, description, probability)
# (one such list for each sample in the batch)
return 'Predicted:' + str(decode_predictions(preds, top=3))
if __name__ == '__main__':
After that copy this code for a Flask server serving a TensorFlow/Keras based pretrained ResNet50 model with Imagenet weights into your JupyterLab environment in the project directory.
Then go to the Custom Deployments tab to deploy your model.
Pick your project and name for the deployments as well as the command to run the server and instance count and size.
After the model is deployed you can check the logs to see that it is running