This content originally appeared on DEV Community and was authored by Jesse Williams
In this rapidly growing field of the computer vision domain, deploying some cutting edge state of the art models from research to production environments can be a really tough task to look for. Models like the Segment Anything Model (SAM) by Meta offer remarkable capabilities however, it comes with some complexities that can create problems for seamless integration. Jozu on the other hand acts as an MLOps platform that is designed to streamline this integration with its new features. It has simplified the deployment process, which enables the teams to bring out amazing models like SAM into the production with less problems and minimal friction.
Exploring Segment Anything Model (SAM)
Segment Anything Model (SAM) developed by Meta AI, represents a significant advancement in image segmentation. Trained on a vast dataset of over 11 million images and 1.1. Billion masks, SAM improvised at generating high quality object masks from various input prompts, such as points or boxes. Its architecture consists of three main components, image encoder, prompt encoder and mask decoder, working together in unison to provide precise segmentation results.
One of the SAM's unique features is its zero shot performance, allowing it to generalize across various segmentation tasks without additional training. This kind of flexibility makes it a great tool for applications ranging from medical imaging to autonomous vehicles. However, even after its capabilities, integrating SAM into production environments can be a challenging task, due to its deployment complexities and due to this Jozu's features comes in handy which provides a streamlined pathway to use SAM effectively.
Jozu's Hugging Face Import Feature: From 🤗 to 🚀
Imagine, you have found a perfect model on Hugging Face website, let's consider SAM in this case, and you are ready to take it out of the research lab and drop it into a real world pipeline. The only problem you can face is "Model Deployment" which can feel like trying to set up the IKEA furniture without instructions and maybe missing half of the screws.
This is where the Jozu's Hugging Face import feature can swoop in. This feature makes it simple to import pre-trained models directly from the Hugging Face. Whether you are building an API, integrating into a product or just want to test inference without writing or using a boilerplate code. The Jozu's CLI and platform handles the heavy tasks so you don't have to.
Think of it as:
- Hugging face acting as the cool research playground.
- On the other side Jozu's as the clean, production ready rocket pad.
Importing SAM into Jozu – Step-by-Step
So are you ready to get the SAM (Segment Anything Model) up and running in your environment? Here is how you can go from "nothing" to "segment anything" in sight:
Prerequisites:
- A Jozu account (Sign up at jozu.ml)
- A Hugging Face account (Sign up at Hugging Face)
Once signed up to Jozu's site head to the top right corner of the web page you will see an "Add Repository" button, click on that and you will see the "Import from Hugging Face feature".
As you click on the feature, you will get a pop up window like this:
Add the required details, in our case as we are importing the SAM from the Hugging Face we will be adding the SAM's Hugging Face link along with the Hugging face access token which can be created by clicking on the profile picture on the hugging face website, getting a drop down menu and then "Access Tokens". After that you can add required details like organization, repository name, tag name and visibility which is by default public, and then click on Import.
📌 Note: As the Segment Anything large model can be of large size therefore, it will take time to import. In that case you will be notified on your email once your model has been imported successfully.
Once done, you can see in your repositories list that your model kit is ready. In this example we are using the "sam-vit-base" model.
Running Segment Anything (SAM) Locally with kit-cli
So you have imported SAM from Hugging Face to Jozu. But what if you want to use its segmentation powers locally or maybe testing, tweaking or just showing off to your team.
For that, you can use the kit-cli, a CLI tool that can help you to pull, unpack, and run models straight from jozu.ml like you are handling Docker images but cooler and model focused.
First things first: install kit-cli:
# For macOS
brew install jozu/tap/kit
# Or use pip (if available)
pip install kit-cli
Pull the SAM Model and Unpack it
We are grabbing the sam-vit-base model from Jozu's model registry:
kit pull jozu.ml/siddhesh-bangar/sam-vit-base:latest
This will pull all the layers and dependencies needed to get the model up and running on your local setup. Think of it like you are fetching a pre-trained brain and now it just needs a body a.k.a. your runtime.
Moreover, to make sure that everything is in place:
kit list
This will show your available models, version and their sizes as you can see in the image below our sam-vit-base model is now sitting in the third line.
Later, unpack the pulled model into a directory, so you can inspect and use the files.
kit unpack jozu.ml/siddhesh-bangar/sam-vit-base:latest -d <path-to-the-folder>
You'll see the model components nicely laid out, including:
- pytorch_model.bin
- tf_model.h5
- model.safetensors
- config.json
- preprocessor_config.json
- And even a README.md to guide your next steps
Note: Here we have packed the sam-vit-base model from the hugging face therefore the components will vary based on the type of model you pack from the hugging face (sam-vit-huge, sam-vit-large)
Now, you have pulled the model, unpacked it like a pro, and now you are ready for the real show, running a large language model (LLM) locally using kit-cli. Whether you are testing or integrating. This process is smoother than your third cup of coffee.
Deploying Your Model as a Model Kit
Alright, you've pulled the SAM model, unpacked it and might have even checked if it works locally. But real MLOps superheroes don't stop there. Let's get this model deployed in a real Kubernetes cluster because nothing says "production-ready" like a wall of YAML and a pod that doesn't CrashLoopBackOff… at least on the first try!
Here's how to take your Hugging Face-imported SAM ModelKit and drop it into the cloud (or your local K8s playground) with KitOps, without losing your mind or your coffee.
1: Using the init Container for Kubernetes
1.1: Create your Kubernetes YAML file
Imagine Kubernetes as your trusty sous-chef, but before the real work starts, you need all your ingredients out of the box and on your kitchen counter. That's what the init container does for your SAM ModelKit: it pulls your model from the Jozu Hub and unpacks it before your main app even starts.
Here is how your YAML file should look like:
apiVersion: v1
kind: Pod
metadata:
name: sam-modelkit-test
spec:
initContainers:
- name: kitops-init
image: ghcr.io/kitops-ml/kitops-init:latest
env:
- name: MODELKIT_REF
value: "jozu.ml/siddhesh-bangar/sam-vit-base:latest"
- name: UNPACK_PATH
value: /modelkit
volumeMounts:
- name: modelkit-volume
mountPath: /modelkit
containers:
- name: sam-server
image: siddddhesh/sam-api-server:latest # Your own HuggingFace-based FastAPI server image
ports:
- containerPort: 8000
volumeMounts:
- name: modelkit-volume
mountPath: /app/modelkit
volumes:
- name: modelkit-volume
emptyDir: {}
Here it's what happening:
- The init container (kitops-init) grabs your SAM ModelKit from Jozu and unpacks it to a shared volume.
- The main container (sam-server) is your own FastAPI server, running the Hugging Face SAM implementation (yes, the one you coded with love and too many linter warnings). It picks up the model weights right from /app/modelkit—easy peasy!
- Both containers share the modelkit-volume, so your model is always ready, like instant noodles but for AI.
1.2: Rolling your own API server
Since we are going through the Hugging Face style, the API server runs code like:
from fastapi import FastAPI
from transformers import SamModel, SamProcessor
app = FastAPI()
@app.on_event("startup")
def load_model():
global predictor
model_dir = "/app/modelkit" # Directory with config.json, pytorch_model.bin, etc.
# Load HuggingFace's SAM model and processor
model = SamModel.from_pretrained(model_dir)
processor = SamProcessor.from_pretrained(model_dir)
predictor = (model, processor)
@app.get("/health")
def health():
return {"status": "running"}
Note: Here I have just created an example app that will show us the status of running of the sam model server, you can mold this app.py according to your project and requirements.
No more pickle errors, no PyTorch device drama, and best of all: your endpoints are ready to segment anything you throw at them (within reason—please, no pizzas).
Once done you can also create your Dockerfile and requirements.txt file so that you can build and push them as a dockerfile, here is a small example that can help you to make you own as per your requirement.
Dockerfile:
FROM python:3.10-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY app.py .
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
Requirements.txt:
torch==2.5.1 # Or >=2.0,<2.6
transformers
opencv-python # If you use OpenCV for image handling
fastapi
uvicorn
Pillow # Often needed for HuggingFace image models
Once you have build all these files you are set to push this as a docker container and run on one of the kube pods
I have created my project structure something like this:
Next, you have to build and push the project files to the docker container. Here are the commands that will help you to do that, hope you have your docker daemon running in the background of your machine.
docker build -t <your-docker-username>/sam-api-server:latest .
docker push <your-docker-username>/sam-api-server:latest
Once done, you can deploy it to kubernetes pod using this command, make sure you have minikube installed if not you can do that by brew install minikube
and then minikube start
kubectl apply -f sam-pod.yaml
Wait for the kubernetes pod to get ready and be in the running state, you can check that via these commands:
kubectl logs pod/sam-modelkit-pod -c kitops-init
kubectl logs pod/sam-modelkit-pod -c sam-server
kubectl get pods
Next, you can port forward the pod to your local machine, or however you want:
kubectl port-forward pod/sam-modelkit-pod 8000:8000
In another terminal you can check the status of the pod if it running using this command:
curl http://localhost:8000/health
Once you see this, congratulations you are able to run deploy your Segment Anything Model as a model kit using Kubernetes.
2: Using the Kit CLI Container
Alternatively, you can also use the Kit CLI container to pull and unpack the ModelKit directly:
docker run ghcr.io/kitops-ml/kitops:latest pull jozu.ml/siddhesh-bangar/sam-vit-base:latest
This command allows us to pull the SAM ModelKit and makes it available for the application. Once deployed, you can test the SAM model to ensure it is working as expected.
Conclusion
And there you have it, a complete journey from downloading Segment Anything (SAM) on Hugging Face to deploying it like a boss using Jozu and KitOps. Along the way, we explored SAM's mind blowing segmentation magic, imported it in seconds using Jozu's Hugging Face integration. Packaged it neatly as a reusable ModelKit and deployed it like pros both locally and in the cloud.
What used to be a painful multi day task full of YAML rage and broken containers is now a clean, streamlined experience almost like model deployment on easy mode. SO if you are developing proof of concept, testing SAM on custom data, or scaling into production, the Jozu + KitOps combo has your back.
This content originally appeared on DEV Community and was authored by Jesse Williams

Jesse Williams | Sciencx (2025-06-26T14:40:39+00:00) From Hugging Face to Production: Deploying Segment Anything (SAM) with Jozu’s Model Import Feature. Retrieved from https://www.scien.cx/2025/06/26/from-hugging-face-to-production-deploying-segment-anything-sam-with-jozus-model-import-feature/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.