Exporting Models and TensorFlow Serving

Deep Learning with Keras and TensorFlow 10 min min read Updated: Nov 16, 2026 Advanced
Exporting Models and TensorFlow Serving
Advanced Topic 1 of 7

From Notebook to Production

A trained model inside a notebook helps nobody. To use it in a real product, you export it in a format that a server can load. TensorFlow Serving is a high-performance server made for this job.

Step 1: Export

python import keras model = keras.models.load_model("digit_model.keras") # Creates a folder with a TensorFlow SavedModel for inference model.export("export/digits/1")
Version folder: The last folder name, 1, is the model version. TensorFlow Serving loads the highest version and lets you roll out new versions without downtime.

Step 2: Inspect the Signature

bash saved_model_cli show --dir export/digits/1 --tag_set serve --signature_def serve

This shows the input name and shape that the server will expect, for example (None, 28, 28).

Step 3: Run TensorFlow Serving with Docker

bash docker run -p 8501:8501 \ --mount type=bind,source="$(pwd)/export/digits",target=/models/digits \ -e MODEL_NAME=digits \ tensorflow/serving

Step 4: Send a Request

python import json, requests import numpy as np import keras (_, _), (x_test, y_test) = keras.datasets.mnist.load_data() sample = (x_test[:2] / 255.0).astype("float32") payload = json.dumps({"instances": sample.tolist()}) url = "http://localhost:8501/v1/models/digits:predict" response = requests.post(url, data=payload) preds = np.array(response.json()["predictions"]) print(preds.argmax(axis=1), y_test[:2])
Result

The predicted digits match the true labels, for example [7 2] [7 2].

Useful Endpoints

URLPurpose
/v1/models/digitsModel status
/v1/models/digits/metadataSignature and input details
/v1/models/digits:predictGet predictions

Important Production Points

  • Put preprocessing (such as Rescaling) inside the model so the client sends raw data
  • Version your models and keep the old one until the new one is verified
  • Test with a few known samples before going live
  • Monitor prediction quality and latency over time
No Docker? Use the Flask API lesson that follows. It is simpler for small projects and learning, while TensorFlow Serving is better for high traffic.

Conclusion

Export your model, start TensorFlow Serving and send JSON requests. This is a standard path to production.

Quick Summary: model.export creates a SavedModel, Docker runs TensorFlow Serving and the REST predict endpoint returns predictions.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators