TheBushidoCollective/han
jutsu-tensorflow
January 24, 2026
Select agents to install to:
npx add-skill https://github.com/TheBushidoCollective/han/blob/main/jutsu/jutsu-tensorflow/skills/tensorflow-model-deployment/SKILL.md -a claude-code --skill tensorflow-model-deploymentInstallation paths:
.claude/skills/tensorflow-model-deployment/# TensorFlow Model Deployment
Deploy TensorFlow models to production environments using SavedModel format, TensorFlow Lite for mobile and edge devices, quantization techniques, and serving infrastructure. This skill covers model export, optimization, conversion, and deployment strategies.
## SavedModel Export
### Basic SavedModel Export
```python
# Save model to TensorFlow SavedModel format
model.save('path/to/saved_model')
# Load SavedModel
loaded_model = tf.keras.models.load_model('path/to/saved_model')
# Make predictions with loaded model
predictions = loaded_model.predict(test_data)
```
### Create Serving Model
```python
# Create serving model from classifier
serving_model = classifier.create_serving_model()
# Inspect model inputs and outputs
print(f'Model\'s input shape and type: {serving_model.inputs}')
print(f'Model\'s output shape and type: {serving_model.outputs}')
# Save serving model
serving_model.save('model_path')
```
### Export with Signatures
```python
# Define serving signature
@tf.function(input_signature=[tf.TensorSpec(shape=[None, 224, 224, 3], dtype=tf.float32)])
def serve(images):
return model(images, training=False)
# Save with signature
tf.saved_model.save(
model,
'saved_model_dir',
signatures={'serving_default': serve}
)
```
## TensorFlow Lite Conversion
### Basic TFLite Conversion
```python
# Convert SavedModel to TFLite
converter = tf.lite.TFLiteConverter.from_saved_model('saved_model_dir')
tflite_model = converter.convert()
# Save TFLite model
with open('model.tflite', 'wb') as f:
f.write(tflite_model)
```
### From Keras Model
```python
# Convert Keras model directly to TFLite
converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()
# Save to file
import pathlib
tflite_models_dir = pathlib.Path("tflite_models/")
tflite_models_dir.mkdir(exist_ok=True, parents=True)
tflite_model_file = tflite_models_dir / "mnist_model.tflite"
tflite_model_file.write_bytes(tflite_m