百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
L

lang-segment-anything

> 编程语言
开源

带有文本提示的 SAM

2.6K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

带有文本提示的 SAM

Language Segment-Anything

Language Segment-Anything is an open-source project that combines the power of instance segmentation and text prompts to generate masks for specific objects in images. Built on the recently released Meta model, Segment Anything Model 2, and the GroundingDINO detection model, it's an easy-to-use and effective tool for object detection and image segmentation.

Features

  • Zero-shot text-to-bbox approach for object detection.
  • GroundingDINO detection model integration.
  • SAM 2.1
  • Batch inference support.
  • Easy endpoint deployment using the Lightning AI litserve platform.
  • Customizable text prompts for precise object segmentation.

Getting Started

Prerequisites

  • Python 3.10 or higher

Installation

Installing PyTorch Dependencies

Before installing lang-sam, please install PyTorch using the following command:


pip install torch==2.4.1 torchvision==0.19.1 --extra-index-url https://download.pytorch.org/whl/cu124

pip install -U git+https://github.com/luca-medeiros/lang-segment-anything.git

Or Clone the repository and install the required packages:


git clone https://github.com/luca-medeiros/lang-segment-anything && cd lang-segment-anything
pip install -e .

Docker Installation

Build and run the image.


git clone https://github.com/luca-medeiros/lang-segment-anything && cd lang-segment-anything
docker build --tag lang-segment-anything:latest .
docker run --gpus all -p 8000:8000 lang-segment-anything:latest

Usage

To run the gradio APP:

python app.py And open http://0.0.0.0:8000/gradio

Use as a library:

from PIL import Image
from lang_sam import LangSAM

model = LangSAM()
image_pil = Image.open("./assets/car.jpeg").convert("RGB")
text_prompt = "wheel."
results = model.predict([image_pil], [text_prompt])

If desired, arguments below can be passed for offline operations:

LangSAM(sam_ckpt_path,              # path for segment anything model
        gdino_model_ckpt_path,      # path for grounding dino's model checkpoint
        gdino_processor_ckpt_path   # path for grounding dino's processor checkpoint
)

Examples

Acknowledgments

This project is based on/used the following repositories:

  • GroundingDINO
  • Segment-Anything
  • LitServe
  • Supervision

License

This project is licensed under the Apache 2.0 License

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Python

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言