BentoML shows how to turn Grounding DINO into a production service with a web API
BentoML walked through a practical scenario for serving Grounding DINO, a zero-shot model that detects objects from a text prompt. The author shows how to move inference into a Python service, add Pydantic validation, get Swagger UI automatically and build a Docker container. The result is an API with two endpoints: one returns JSON with bounding boxes and confidence scores, the other returns a finished image with the detections drawn on it.
AI-processed from Habr AI; edited by Hamidun News
BentoML showed a practical way to move Grounding DINO out of a notebook and into a production service without heavy MLOps tooling. Using a zero-shot object detector as the example, the author built an HTTP API, added parameter validation and showed how to run the service locally and in Docker.
Why BentoML
The article's main point is simple: training a model is not enough, you also have to deliver it properly to users. A production scenario needs storage and versioning of weights, resource control, a convenient API and a clear path to deployment. BentoML covers exactly that layer.
The framework lets you wrap model code written in Python into a service, prepare the environment automatically, build a Docker image and immediately get an HTTP interface with Swagger UI. For teams that do not want to build the whole MLOps stack by hand, this noticeably shortens the path from experiment to working service.
The example is Grounding DINO, a model for open-set object detection. Unlike classic detectors, it relies not only on the image but also on a text prompt. You can feed it a picture and a list of descriptions such as a cat or a remote control, and the model will try to find exactly those objects, even if they were not hard-coded in advance as fixed classes. It is a good case for a service: it has inference, text parameters and a visual result that is easy to return through an API.
How to build the service
The author starts with an ordinary dev example on Transformers: grounding-dino-tiny is loaded, the image goes through AutoProcessor, and the model then returns bounding boxes, confidence scores and text labels. This code is then moved into a class, GroundingDinoService, which is decorated as a BentoML service.
An important detail: the model weights are declared as a HuggingFaceModel at the class level, so BentoML downloads them in advance when building the artifact rather than during container initialization. This avoids the typical error of a missing model at startup.
- The runtime configuration sets Python 3.11 and dependencies via pyproject.toml
- The detect_image and render methods are exposed as HTTP endpoints through BentoML decorators
- Input parameters are described with Pydantic: prompt, box_threshold and text_threshold
- The result can be returned as JSON with a list of boxes or as a finished image with the detections drawn
"All of this is done in a single
Python file of under 100 lines."
In practice the service boils down to three parts: a private _detect method with the core inference logic, a public detect_image for the structured response and render for visualizing the result. This layout is convenient because the same logic serves both a machine client and a person who wants to quickly check the model through the interface or curl. Pydantic validation also rejects invalid parameters before the model is called.
Running it and the API
For local development, the author uses the bentoml serve command with port 3025 and auto-reload mode. Once started, the service automatically brings up Swagger UI, where you can upload an image, pass JSON with parameters and check the response right away. This is a convenient debugging mode: you edit the code, save the file and see how the service's behavior changes without rebuilding. For many teams, this development loop matters more than a runtime that is maximally optimized at startup.
The production variant is built with bentoml build and then containerized with bentoml containerize. After that, the service can be launched in Docker with a GPU and exposed on the desired port.
The demo service has two endpoints: /detect_image returns JSON with coordinates, classes and confidence, while /render saves and returns the image with the boxes drawn on it. The author also shows calls through the BentoML SDK client and through curl, so the service can be connected just as easily to internal pipelines and to external applications.
What this means
The piece is useful because it grounds the conversation about model serving: instead of an abstract MLOps architecture, it shows a short, reproducible path from a Python script with Grounding DINO to a container with an HTTP API. For small ML teams, it is a good template when they need to ship a vision model into a product quickly and not drown in infrastructure on the very first release.
Key Questions Answered
Why BentoML?
The article's main point is simple: training a model is not enough, you also have to deliver it properly to users. A production scenario needs storage and versioning of weights, resource control, a convenient API and a clear path to deployment. BentoML covers exactly that layer. The framework lets you wrap model code written in Python into a service, prepare the environment automatically, build a Docker image and immediately get an HTTP interface with Swagger UI. For teams that do not want to build the whole MLOps stack by hand, this noticeably shortens the path from experi
How to build the service?
The author starts with an ordinary dev example on Transformers: grounding-dino-tiny is loaded, the image goes through AutoProcessor, and the model then returns bounding boxes, confidence scores and text labels. This code is then moved into a class, GroundingDinoService, which is decorated as a BentoML service. An important detail: the model weights are declared as a HuggingFaceModel at the class level, so BentoML downloads them in advance when building the artifact rather than during container initialization. This avoids the typical error of a missing model at startup. The
What are the key details on Running it and the API?
For local development, the author uses the bentoml serve command with port 3025 and auto-reload mode. Once started, the service automatically brings up Swagger UI, where you can upload an image, pass JSON with parameters and check the response right away. This is a convenient debugging mode: you edit the code, save the file and see how the service's behavior changes without rebuilding. For many teams, this development loop matters more than a runtime that is maximally optimized at startup. The production variant is built with bentoml build and then containerized with bentom
Ship AI Faster with Founders, Engineers & Weekly Architecture Reviews
Inside Vibe Club (hamidun.com/club) — weekly live masterminds with Zhemal Khamidun, Tech Radar, full LMS access, and 370+ production Claude Code skills.
The AI world, distilled — once a week
Seven stories that actually mattered, hand-picked. No noise, no reposts, no press releases.
Done! Check your inbox for a confirmation.