---
title: "Deploying TensorFlow Vision Models in Hugging Face with TF Serving"
description: "A Vision Transformer image classifier from Hugging Face Transformers can be served locally with TensorFlow Serving by exporting it as a SavedModel with preprocessing and postprocessing embedded in the graph."
url: "https://swe.quest/articles/deploying-tensorflow-vision-models-in-hugging-face-with-tf-serving-a278ea9a908befbd"
canonical: "https://huggingface.co/blog/tf-serving-vision"
source: "Hugging Face"
published: "2022-07-25"
difficulty: "medium"
kind: "How-to"
reading_minutes: 8
tags: ["inference","computer-vision","python","rpc"]
---

# Deploying TensorFlow Vision Models in Hugging Face with TF Serving

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2022-07-25, 8 min read, How-to. Original: [https://huggingface.co/blog/tf-serving-vision](https://huggingface.co/blog/tf-serving-vision)

## Summary

A Vision Transformer image classifier from Hugging Face Transformers can be served locally with TensorFlow Serving by exporting it as a SavedModel with preprocessing and postprocessing embedded in the graph. A custom serving signature accepts base64-encoded JPEG strings, then decodes, resizes, normalizes and transposes them to channel-first, and returns a class label plus softmax confidence. Building these steps into the model cuts request payload size and avoids training-serving skew. The walkthrough covers launching tensorflow\_model\_server and querying both the REST endpoint (port 8501) and the gRPC endpoint (port 8500), including how to select a model version.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Computer vision](https://swe.quest/tags/computer-vision.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)
- [RPC & gRPC](https://swe.quest/tags/rpc.md) (Backend & APIs)

## Prerequisites

- TensorFlow SavedModel basics
- Python ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))
- REST and gRPC basics ([easy posts on API design](https://swe.quest/tags/api-design.md?difficulty=easy))

## Keywords

TensorFlow Serving, Vision Transformer, Hugging Face Transformers, SavedModel, gRPC, TensorFlow

## Related posts

- [Deploying 🤗 ViT on Kubernetes with TF Serving](https://swe.quest/articles/deploying-vit-on-kubernetes-with-tf-serving-72269d9df3724559.md): Hugging Face · 2022-08-11 · Medium · 12 min read · Inference & serving, Kubernetes, Containers, Cloud platforms
  A Vision Transformer from Hugging Face Transformers, exported as a TensorFlow SavedModel, is packaged into a custom TensorFlow Serving Docker image and deployed to a GKE cluster.
- [Deploying 🤗 ViT on Vertex AI](https://swe.quest/articles/deploying-vit-on-vertex-ai-1cefa91d85f70e80.md): Hugging Face · 2022-08-19 · Medium · 10 min read · Inference & serving, Cloud platforms, ML platforms, Computer vision, Python
  A TensorFlow ViT B/16 SavedModel from 🤗 Transformers, with base64 image preprocessing and label postprocessing baked into its signature, can be served on Google Cloud Vertex AI in four SDK steps: upload to the Model Registry, create an Endpoint, deploy with machine/accelerator specs and traffic split, then send prediction requests.
- [My Journey to a serverless transformers pipeline on Google Cloud](https://swe.quest/articles/my-journey-to-a-serverless-transformers-pipeline-on-google-cloud-202ccbc112026927.md): Hugging Face · 2021-03-18 · Medium · 8 min read · Serverless, Inference & serving, Cloud platforms, Python, Containers
  A Hugging Face transformers sentiment-analysis pipeline (DistilBERT fine-tuned on SST-2) was deployed as a low-traffic microservice on Google Cloud Run after AI Platform Prediction (beta instability, checkpoint not a pure TensorFlow model) and App Engine (TensorFlow install failure, PyTorch handling only 2 requests per instance) fell short.
- [Timm ❤️ Transformers: Use any timm model with transformers](https://swe.quest/articles/timm-transformers-use-any-timm-model-with-transformers-ae757824718fc026.md): Hugging Face · 2025-01-16 · Medium · 10 min read · Computer vision, Model training, Inference & serving, Python
  TimmWrapper lets any timm vision model load through Hugging Face transformers' Auto classes and pipeline API.
- [Getting Started with Hugging Face Inference Endpoints](https://swe.quest/articles/getting-started-with-hugging-face-inference-endpoints-d2f6b69d4c5ca480.md): Hugging Face · 2022-10-14 · Medium · 5 min read · Inference & serving, ML platforms, Cloud platforms
  Hugging Face Inference Endpoints deploys Hub models to managed cloud infrastructure in a few clicks, demonstrated here with a fine-tuned Swin image classifier on a GPU instance in AWS eu-west-1.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
