{"slug": "segment-anything-with-text", "title": "Segment Anything with Text", "summary": "Meta's SAM 3 model enables zero-shot text-prompt segmentation, allowing users to segment objects like \"helmet\" or \"safety vest\" without training or clicks. A Roboflow Workflow tutorial demonstrates using SAM 3 for construction site PPE inspection, generating AI safety summaries from annotated images.", "body_md": "*You can segment anything with text using SAM 3, which takes a short prompt like \"helmet\" or \"safety vest\" and returns pixel-level masks for every matching object, zero-shot, with no training or clicks. This tutorial builds a Roboflow Workflow that uses SAM 3 to inspect construction site PPE and generate an AI safety summary from the annotated image.*\n\nSegment anything with text means giving a segmentation model a plain-language prompt, like \"helmet\" or \"safety vest\", and getting back pixel-accurate masks for every matching object in the image. No training data, no drawn boxes, no click prompts. [SAM 3](https://roboflow.com/segment-anything-with-concepts?ref=blog.roboflow.com) does this natively: Meta calls the capability promptable concept segmentation, and unlike earlier Segment Anything models, SAM 3 finds every instance of the concept you describe, not one object per prompt.\n\nIn this tutorial, we'll use it for construction site PPE inspection, a task where text-prompt segmentation earns its keep. Construction accounted for nearly one-fifth of all U.S. workplace deaths in 2023, according to CPWR's April 2025 [Data Bulletin](https://www.cpwr.com/wp-content/uploads/DataBulletin-April2025.pdf?ref=blog.roboflow.com), and PPE checks are one visible part of reducing that risk. But jobsite scenes change constantly: workers move, machines block the view, and helmets and vests appear small, folded, or partially hidden. The traditional approach means collecting images, labeling every class, and training a custom model before you see a single result.\n\nWith SAM 3, we skip straight to results. We'll build a [Roboflow Workflow](https://roboflow.com/workflows/build?ref=blog.roboflow.com) that segments PPE from text prompts such as person, helmet, safety vest, excavator, and traffic cone, visualizes the masks, and generates a short AI-powered safety summary from the annotated image.\n\n## SAM 3 vs. Grounded SAM and lang-segment-anything\n\nText-prompt segmentation isn't new as an idea; what's new is doing it in one model. The original SAM and [SAM 2](https://blog.roboflow.com/what-is-segment-anything-2/) only accepted visual prompts (clicks, boxes, or masks), so the community bridged the gap by chaining models: [Grounding DINO](https://blog.roboflow.com/grounding-dino-zero-shot-object-detection/) converts a text prompt into bounding boxes, then SAM converts those boxes into masks. Grounded SAM and lang-segment-anything are both packages of that two-model pipeline.\n\nThe chained approach works, but it inherits two models' worth of weaknesses. Errors compound: if Grounding DINO misses the box, SAM never sees the object. It returns one region per detected box rather than reasoning about the concept across the scene. And running it means hosting two models, aligning their dependencies, and paying two inference costs per image.\n\nSAM 3 collapses the pipeline into a single model trained for promptable concept segmentation. You provide a short noun phrase (or an image exemplar), and it detects and segments every instance of that concept in the image or video directly. For this tutorial that difference is practical: one prompt such as helmet masks every helmet in a crowded jobsite scene in one pass, and running it in a Roboflow Workflow means there's no pipeline to host at all.\n\n## Run SAM 3 with a Text Prompt in Python\n\nIf you want the raw capability before building the full workflow, Roboflow's serverless API runs SAM 3 on hot GPU instances, so there's nothing to download or host. One request with a text prompt returns segmentation masks:\n\n``` python\nimport requests\n\nresponse = requests.post(\n    \"https://serverless.roboflow.com/sam3/concept_segment?api_key=<YOUR_ROBOFLOW_API_KEY>\",\n    headers={\"Content-Type\": \"application/json\"},\n    json={\n        \"format\": \"polygon\",\n        \"image\": {\n            \"type\": \"url\",\n            \"value\": \"https://example.com/construction-site.jpg\"\n        },\n        \"prompts\": [\n            {\"text\": \"helmet\"},\n            {\"text\": \"safety vest\"},\n            {\"text\": \"person\"}\n        ]\n    }\n)\n\nfor prompt_result in response.json()[\"prompt_results\"]:\n    print(prompt_result[\"echo\"][\"text\"], len(prompt_result[\"predictions\"]), \"matches\")\n```\n\nEach prompt returns every matching instance with its mask polygon and confidence. You can also run SAM 3 locally with the `inference`\n\npackage (`pip install inference-gpu[sam3]`\n\n) if you have your own GPU; see the [SAM 3 Inference docs](https://inference.roboflow.com/foundation/sam3/?ref=blog.roboflow.com) for both paths. The rest of this tutorial builds the same capability into a no-code Workflow with visualization and reporting on top.\n\n## Segment Anything with Text Prompts Using SAM 3\n\n### Step 1: Create our Dataset\n\nFor this tutorial, we will use the Construction Site Safety Computer Vision [ dataset](https://universe.roboflow.com/roboflow-universe-projects/construction-site-safety?ref=blog.roboflow.com) from\n\n[as the source of test images. The dataset contains construction site scenes with workers, safety gear, vehicles, and jobsite equipment. It includes 717 images and classes such as Person, Helmet, Safety Vest, Excavator, vehicle, Ladder, and Gloves.](https://universe.roboflow.com/?ref=blog.roboflow.com)\n\n__Roboflow Universe__We are not going to train a model on this dataset. Instead, we will use its images to test how well SAM 3 can segment construction safety concepts from text prompts. This keeps the tutorial focused on Segment Anything with Text, rather than turning it into a traditional object detection training workflow.\n\nThe dataset is a good fit because the images contain common PPE and construction objects that can be described with simple prompts. For example:\n\n```\nperson\nhelmet\nsafety vest\nexcavator\nvehicle\nladder\ngloves\n```\n\nThese prompts give SAM 3 clear concepts to search for in each image. A prompt like person can identify visible workers, while a helmet and safety vest can highlight PPE items. Equipment prompts, such as an excavator or a vehicle, can also be added when the scene contains machinery.\n\nTo begin, open the dataset in Roboflow Universe and use a few example images from the Images tab. These images will be passed into the Roboflow Workflow as test inputs for SAM 3-based segmentation.\n\nHere are examples from the dataset:\n\n### Step 2: Create a Roboflow Workflow\n\nNext, create a new Workflow in Roboflow. This Workflow will take a construction site image, run SAM 3 with PPE-related text prompts, and return an annotated result. [Here's the workflow we'll build](https://app.roboflow.com/workflows/embed/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ3b3JrZmxvd0lkIjoiTXpOZlpybXBDWkxRZ3cyaFY0dmciLCJ3b3Jrc3BhY2VJZCI6Im5JRk5DOGRjbU5OOXZ4d29ybWpoWTdCNjdQZTIiLCJ1c2VySWQiOiJuSUZOQzhkY21OTjl2eHdvcm1qaFk3QjY3UGUyIiwiaWF0IjoxNzgzMzY2NDkxfQ.0CAo08csnz0oe7NT9C04TIyg-130uUwy1QeoeVH2SEA?ref=blog.roboflow.com).\n\nThe workflow has three main parts. First, SAM 3 segments objects such as workers, helmets, and safety vests from text prompts. Then, visualization blocks draw masks, boxes, and labels over the matching regions. Finally, Gemini reads the annotated image and generates a short PPE safety summary, which is displayed on the final output.\n\nThe workflow follows this structure:\n\nStart by opening Roboflow Workflows and creating a new workflow. Add an image input block as the first step. This input will receive the construction site image that you want to inspect.\n\n### Step 3: Configure SAM 3 Text Prompts\n\nThe SAM 3 block is the core of this workflow. Instead of drawing boxes, placing clicks, or manually creating masks, we provide text prompts that describe the objects we want to segment.\n\nFor the first version of the workflow, use a small prompt set:\n\n- person\n- helmet\n- safety vest\n\nThese prompts cover the main PPE inspection targets. Person helps identify visible workers, while helmet and safety vest focus the workflow on the most common protective equipment visible in construction site images.\n\nSAM 3 uses these prompts to search the image for matching concepts and return segmentation masks. Each mask represents the shape of an object that matched one of the prompts. This is different from a standard object detector, which usually returns only bounding boxes.\n\nAfter the basic workflow is working, you can expand the prompt list with additional construction-related objects:\n\n- helmet\n- person\n- safety vest\n- vehicle\n- gloves\n\nPrompt wording matters. For example, helmet, hard hat, and construction helmet may produce slightly different results depending on the image. Start with simple prompts, test the output, and then adjust the wording based on what SAM 3 segments correctly.\n\n### Step 4: Visualize the Segmentation Results\n\nSAM 3 returns segmentation predictions, but raw predictions are hard to review on their own. To make the output useful, add visualization blocks after SAM 3.\n\nThe first visualization step draws segmentation masks over the objects found by SAM 3. These masks make it easier to see the exact regions that matched each prompt. This is especially useful for PPE because helmets and vests can be small, partially hidden, or close to other objects in the scene.\n\nNext, add bounding boxes and labels. The boxes give a quick view of where each object is located, while the labels show which prompt matched each segmented region.\n\nMasks are the most important part of this step. A bounding box can show that a helmet is somewhere near a worker’s head, but a mask shows the actual helmet shape. That extra detail is useful when the scene is crowded or when PPE is only partly visible.\n\n### Step 5: Generate a PPE Safety Summary\n\nAfter the image has been annotated, send it to a vision-language block such as Google Gemini. The goal is not to use Gemini as the detector. SAM 3 has already done the segmentation. Gemini receives the annotated image and writes a short safety summary based on what is visible.\n\nUse this prompt:\n\n```\nInspect the annotated construction site image.\nWrite one short PPE safety summary.\nMention whether visible workers appear to have helmets and safety vests.\nKeep the response under 20 words.\n```\n\nThis keeps the response short enough to display on the final image. It also keeps Gemini focused on the PPE inspection task instead of producing a long description of the full scene.\n\nThe summary should be treated as an inspection aid, not a final safety decision. The useful part is that the workflow produces both visual evidence and a short written observation in one output.\n\n### Step 6: Display the Final Output\n\nThe final step is to overlay the PPE safety summary on the annotated image. Add a Text Display block and use the labeled image as the base image. Then use the Gemini response as the text that appears on the output.\n\nThis creates a single result that is easy to review. The image shows the SAM 3 segmentation masks, object labels, and the short safety summary together.\n\nAfter that, add a Roboflow Vision Events block to log each PPE review as a safety event. Use the original input image as the input image, the Text Display output as the output image, and the SAM 3 predictions as the event predictions. Set the event type to Safety Alert and use a PPE-related alert name, such as ppe_safety_review.\n\n### Step 7: Test the Workflow\n\nAfter building the workflow, test it on several images from the construction safety dataset. Do not rely on only one clean example. Text-prompt segmentation can behave differently depending on distance, lighting, occlusion, and how clearly the PPE appears in the frame.\n\nResults using the current workflow:\n\nFor each test image, review the input image, the prompts used, the SAM 3 segmentation output, and the generated safety summary. The goal is to understand where the workflow performs well and where prompt wording needs adjustment.\n\nThis step is important because SAM 3 is being used zero-shot. We are not training it on the dataset, so the test images help us evaluate how well the text prompts transfer to real construction scenes.\n\nBy the end of testing, you should have a clear sense of which prompts work best for this dataset and which scene types are more difficult for the workflow.\n\n## Extending the Workflow\n\nOnce the workflow is working on a few examples, the next step is to look at the failure cases. Some images will be easy: workers are close to the camera, PPE is visible, and the prompts return clean masks. Other images will be harder because helmets are small, vests are partly hidden, or equipment overlaps with workers.\n\nUse those cases to refine the workflow. Try alternate wording when a class is missed. For example, if helmet is inconsistent, compare it with hard hat or construction helmet. If safety vest misses examples, test high visibility vest or reflective vest. Keep the wording that gives the cleanest masks across several images, not just one result.\n\nThis workflow is also useful before building a trained model. SAM 3 can generate first-pass masks for many construction images. After reviewing and correcting those masks in Roboflow Annotate, the cleaned labels can become a training dataset for a dedicated PPE detection or segmentation model.\n\nThat dedicated model may be a better fit when you need consistent results for a known camera position, a specific jobsite, or a fixed list of PPE classes. A trained model is usually the better next step when the system needs repeatable performance at a production scale.\n\n## Segment Anything with Text with Roboflow Agent\n\nIf you'd rather not assemble the workflow yourself, describe it to Roboflow Agent instead: a prompt like \"segment helmets and safety vests in construction images with SAM 3 and summarize PPE compliance\" and it builds, configures, and tests the pipeline for you. Text prompts drive the segmentation and plain English drives the build, so the entire system, from masks to safety summary, comes from describing what you want.\n\n**What is ****promptable concept segmentation****?**\n\nIt's SAM 3's core capability: you describe a concept with a short noun phrase, like \"helmet\" or \"red car\", and the model detects, segments, and tracks all instances of that concept in an image or video, rather than segmenting one object per prompt.\n\n**Do I need to train SAM 3 before using it?**\n\nNo. SAM 3 works zero-shot from text prompts with no training data or fine-tuning. Training a dedicated model becomes worthwhile later, when you need consistent, repeatable performance on a fixed class list, and SAM 3 masks can bootstrap that dataset.\n\n**How is text-prompt segmentation different from object detection?**\n\nAn object detector returns bounding boxes for classes it was trained on. Text-prompt segmentation returns pixel-level masks for anything you can describe, without training. Masks capture exact object shapes, which matters when objects are small, overlapping, or partially hidden.\n\n## Segment Anything with Text Conclusion\n\nIn this tutorial, we built a prompt-based PPE segmentation workflow using SAM 3 in Roboflow. Instead of training a custom model, we used text prompts such as person, helmet, and safety vest to segment construction site safety equipment directly from images.\n\nThe workflow shows how Segment Anything with Text can support fast visual prototyping, [PPE inspection](https://blog.roboflow.com/ppe-detection/), and dataset pre-labeling. For production use, the same process can be extended by reviewing SAM 3-generated masks, creating a labeled dataset, and training a dedicated PPE model for deployment.\n\n**Further reading:**\n\n**Cite this Post**\n\nUse the following entry to cite this post in your research:\n\n[Mostafa Ibrahim](/author/mostafa/). (Jul 14, 2026).\nSegment Anything with Text. Roboflow Blog: https://blog.roboflow.com/segment-anything-with-text/", "url": "https://wpnews.pro/news/segment-anything-with-text", "canonical_source": "https://blog.roboflow.com/segment-anything-with-text/", "published_at": "2026-07-14 17:49:30+00:00", "updated_at": "2026-07-14 18:03:32.887532+00:00", "lang": "en", "topics": ["computer-vision", "generative-ai", "ai-tools", "ai-products"], "entities": ["Meta", "SAM 3", "Roboflow", "CPWR"], "alternates": {"html": "https://wpnews.pro/news/segment-anything-with-text", "markdown": "https://wpnews.pro/news/segment-anything-with-text.md", "text": "https://wpnews.pro/news/segment-anything-with-text.txt", "jsonld": "https://wpnews.pro/news/segment-anything-with-text.jsonld"}}