Principle:Tensorflow Serving SavedModel Preparation
| Knowledge Sources | |
|---|---|
| Domains | Data_Preparation, Deployment |
| Last Updated | 2026-02-13 17:00 GMT |
Overview
A model acquisition process that obtains a pre-trained SavedModel from a model hub or custom training pipeline and organizes it into the versioned directory structure required by TensorFlow Serving.
Description
Before deployment, a SavedModel must be in the correct directory layout: <base_path>/<version_number>/saved_model.pb. Models can be sourced from:
- TensorFlow Hub: Pre-trained models downloaded as compressed archives
- Custom training: Models exported via SavedModelBuilder or tf.saved_model.save()
- Model registries: Organizational model stores
The version number must be a positive integer. TensorFlow Serving discovers versions by scanning for integer-named subdirectories.
Usage
Use this as the first step in any Kubernetes deployment. The model must be prepared locally or in a shared filesystem before being baked into a Docker image.
Theoretical Basis
# Abstract model preparation (NOT real implementation)
# Option 1: Download from TF Hub
download(url="https://tfhub.dev/.../resnet_50/.../1", dest="/tmp/resnet.tar.gz")
extract(archive="/tmp/resnet.tar.gz", dest="/tmp/resnet/123/")
# Option 2: Export from training
model = train(data)
export(model, path="/tmp/resnet/123/")
# Result: /tmp/resnet/123/saved_model.pb + /tmp/resnet/123/variables/