C.W.K.
Stream
Lesson 05 of 07 · published

Exporting for Serving

~9 min · serialize

Level 0Keras Apprentice
0 XP0/97 lessons0/20 achievements
0/120 XP to next level120 XP to go0% complete

Saving is for you, exporting is for the world

Everything so far has been about save — round-tripping a model so you can keep training it. export is the opposite direction: it produces an inference-only artifact that a serving system can run, often one that has never heard of Keras. The single model.export() call takes a format= argument, and that one argument picks which deployment world you're targeting.

One call, four destinations

Each format answers a different deployment question. tf_saved_model is the TensorFlow ecosystem's native serving format — feed it to TF Serving or TF.js. onnx is the vendor-neutral interchange standard; export to ONNX when the inference runtime (Triton, ONNX Runtime, a hardware vendor's stack) expects it. openvino targets Intel's optimized inference engine for CPU-bound deployments. litert (the format formerly branded TFLite) is the mobile and edge target — small, quantizable, built to run on phones and microcontrollers.

The point isn't to memorize four strings. It's that the model you trained is a single source of truth, and exporting is a projection of it onto whatever runtime your deployment happens to need.

Code

Export to four serving formats·python
# TF SavedModel (for TF Serving)
model.export("model_dir", format="tf_saved_model")

# ONNX (cross-platform inference)
model.export("model.onnx", format="onnx")

# OpenVINO (Intel optimized inference)
model.export("model_ov", format="openvino")

# TFLite (mobile/edge)
model.export("model.tflite", format="litert")

External links

Exercise

Train MNIST. Both: model.save('mnist.keras') and model.export('mnist_export'). Compare disk sizes. Then convert the export to TFLite and inspect the .tflite size — should be much smaller.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.