The digital tailor: how SAM 3 cuts garments out of images

Last month we saw how a pose detector, RTMPose, helps us detect images with garments actually being worn; here is the link to the article.
Images of worn garments can’t be used to create outfits in our Social App. That’s because they’re being worn and may have been shot from different angles. Even detail shots of the product itself, which are usually discarded, fall into this category.
However, there are services we offer our clients, such as Visual Search, based on a RAG that returns similar or matching products: in that specific case, having more images shot from different perspectives, worn or not, is an asset for us. But how can we “clean them up” to isolate only the garment, ignoring the background and, above all, discarding the person wearing it?
Object detection with deep learning
In recent years, the evolution of VLMs has brought many benefits to computer vision, so one might naturally ask: is a single call to, say, a GPT-5.x enough for me? – In this case, no: because of cost and limitations, it isn’t really the right tool.
A powerful VLM can isolate garments, giving us the bounding boxes, that is, the coordinates where the product sits within the image, in a way very similar to convolutional models (CNNs), such as YOLO 26. However, even though it remains a valid method for isolating a garment within a photo, even a full-body one, it doesn’t give us something perfectly clean and free of backgrounds or people.

To “cut out” the product we therefore need a segmentation model that doesn’t just detect it by telling us where it is, but is able to isolate and extract it precisely by generating a mask. While a VLM is poorly suited to this task, it’s also true that the transformer part of the architecture in segmentation models has been fundamental to the evolution of this kind of computer vision.
Segment Anything Model
One of the best-known deep learning segmentation models is called SAM, Segment Anything Model, and was developed by Meta in 2023. The first version was very successful and was followed by a second version (SAM2) in 2024, which increases its precision enough that it can be used in real time on video and to segment several objects in the same scene. As good as the output of the two SAM models is, it isn’t easy to integrate into a custom workflow, since they operate in point-to-segment mode, meaning they need a visual target as input, for example the coordinates of a point in the area to segment. In November 2025 Meta released a new version of the model, called SAM3, which avoids these dynamics entirely thanks to a text encoder in place of point-to-segment: it was developed by training it with an open vocabulary, so it’s enough to specify a keyword to tell the model which object to segment. That words are enough doesn’t mean any word will do, though. SAM 3’s vocabulary is visual, not commercial: it recognizes t-shirt, jeans or jacket without problems, but the names we use to tell one model from another in a catalog often mean nothing to it.
Here lies the real problem: if the model doesn’t recognize the term, it doesn’t return any error. It silently falls back to a more generic concept, still generating a mask, but of the wrong garment. That’s why we stopped querying it with the product type and moved to the body zone: upper clothing, lower clothing, shoes. It’s less specific information, but much more reliable, because where the type worked, the zone returns exactly the same cutout; where it failed, it recovers it.
The process is based on a perception encoder, which combines a transformer visual encoder (ViT) with windowed attention (SAM2-style) and a text encoder. The data processed this way is passed to a detection model, which identifies the target elements in the image and generates their mask.

A tailor-made service
SAM3 is not an LLM, so it is (much) less demanding in terms of hardware requirements for inference. It is hosted on several platforms that make it available through simple REST calls, such as fal.ai; we, however, preferred to build a solution more in line with our needs.
With RunPod, we containerized SAM3 and built a layer that could handle inference with a set of predefined keywords, both one-shot and batch. This was possible thanks to configuring a serverless endpoint, which provides access to high-performance GPUs only when inference is actually needed, resulting in a significant cost reduction.
At this point, with a custom service configured for us, we were able to use it in various ways:
Isolating worn garments: from a photo of a worn outfit, the mask extracts each garment, separated from the body and from the other garments.
Cleaning up still lifes: a still life is 57-87% studio backdrop: you index the garment, not the background.
Feeding the vector database: we can use the precisely segmented product for ingestion, creating embeddings for products from the worn images, which carry a different weight than still-life images.
Attribute extraction: by isolating the garment accurately, we can compute its dominant color and categorize it according to our taxonomy.
Live: the user uploads a worn image and clicks on the extracted garment: that cutout becomes the query.
Five different uses, one single service: that is what made SAM 3 our Swiss Army knife. It was introduced and developed for one specific task, namely removing the model and the background from a photograph, but thanks to its versatility and precision, after customizing it, we were able to integrate it into many more areas and operations.
The credit goes not to any one feature but to the shape of the model: you don’t teach it a catalog of categories once and for all, you tell it in words what to look for, and that is why the same call ended up answering questions we never had in mind when we built it. You do have to learn how to handle it, though: if you ask it for something it can’t see, it still gives you an answer, and it’s wrong.
But that’s what is said of every good tool: in the right hands it cuts anything, and for a digital tailor there is no better compliment.
Sources
SAM3: https://github.com/facebookresearch/sam3SAM3 (paper):
https://ai.meta.com/research/publications/sam-3-segment-anything-with-concepts/RunPod: https://www.runpod.io/
Enrico Antonini, Deep learning engineer @Bantoa Alberto Dosso, BSc intern @Bantoa
More articles dal panorama fashion-tech
Want to become the next case study?
Discover how Bantoa solutions can grow your brand.


