[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-72719":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":23,"hasPages":23,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":34,"readmeContent":35,"aiSummary":36,"trendingCount":16,"starSnapshotCount":16,"syncStatus":37,"lastSyncTime":38,"discoverSource":39},72719,"Grounded-Segment-Anything","IDEA-Research\u002FGrounded-Segment-Anything","IDEA-Research","Grounded SAM: Marrying Grounding DINO with Segment Anything & Stable Diffusion & Recognize Anything - Automatically Detect , Segment and Generate Anything","https:\u002F\u002Farxiv.org\u002Fabs\u002F2401.14159",null,"Jupyter Notebook",17630,1593,120,304,0,15,29,65,45,44.61,"Apache License 2.0",false,"main",[26,27,28,29,30,31,32,33],"3d-whole-body-pose-estimation","automatic-labeling-system","caption","data-generation","image-editing","open-vocabulary-detection","open-vocabulary-segmentation","speech","2026-06-12 02:03:07","![](.\u002Fassets\u002FGrounded-SAM_logo.png)\n\n# Grounded-Segment-Anything\n[![YouTube](https:\u002F\u002Fbadges.aleen42.com\u002Fsrc\u002Fyoutube.svg)](https:\u002F\u002Fyoutu.be\u002FoEQYStnF2l8) [![Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Froboflow-ai\u002Fnotebooks\u002Fblob\u002Fmain\u002Fnotebooks\u002Fautomated-dataset-annotation-and-evaluation-with-grounding-dino-and-sam.ipynb) [![Open in Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fgithub.com\u002Fcamenduru\u002Fgrounded-segment-anything-colab) [![HuggingFace Space](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F🤗-HuggingFace%20Space-cyan.svg)](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FIDEA-Research\u002FGrounded-SAM) [![Replicate](https:\u002F\u002Freplicate.com\u002Fcjwbw\u002Fgrounded-recognize-anything\u002Fbadge)](https:\u002F\u002Freplicate.com\u002Fcjwbw\u002Fgrounded-recognize-anything)  [![ModelScope Official Demo](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FModelScope-Official%20Demo-important)](https:\u002F\u002Fmodelscope.cn\u002Fstudios\u002Ftuofeilunhifi\u002FGrounded-Segment-Anything\u002Fsummary) [![Huggingface Demo by Community](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FHuggingface-Demo%20by%20Community-red)](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fyizhangliu\u002FGrounded-Segment-Anything) [![Stable-Diffusion WebUI](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FStable--Diffusion-WebUI%20by%20Community-critical)](https:\u002F\u002Fgithub.com\u002Fcontinue-revolution\u002Fsd-webui-segment-anything) [![Jupyter Notebook Demo](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FDemo-Jupyter%20Notebook-informational)](.\u002Fgrounded_sam.ipynb) [![Static Badge](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FGroundingDINO-arXiv-blue)](https:\u002F\u002Farxiv.org\u002Fabs\u002F2303.05499) [![Static Badge](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FSegment_Anything-arXiv-blue)](https:\u002F\u002Farxiv.org\u002Fabs\u002F2304.02643) [![Static Badge](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FGrounded_SAM-arXiv-blue)](https:\u002F\u002Farxiv.org\u002Fabs\u002F2401.14159)\n\n\nWe plan to create a very interesting demo by combining [Grounding DINO](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGroundingDINO) and [Segment Anything](https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fsegment-anything) which aims to detect and segment anything with text inputs! And we will continue to improve it and create more interesting demos based on this foundation. And we have already released an overall technical report about our project on arXiv, please check [Grounded SAM: Assembling Open-World Models for Diverse Visual Tasks](https:\u002F\u002Farxiv.org\u002Fabs\u002F2401.14159) for more details.\n\n- 🔥 **[Grounded SAM 2](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-SAM-2)** is released now, which combines Grounding DINO with [SAM 2](https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fsegment-anything-2) for any object tracking in open-world scenarios.\n- 🔥 **[Grounding DINO 1.5](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounding-DINO-1.5-API)** is released now, which is IDEA Research's **Most Capable** Open-World Object Detection Model!\n- 🔥 **[Grounding DINO](https:\u002F\u002Farxiv.org\u002Fabs\u002F2303.05499)** and **[Grounded SAM](https:\u002F\u002Farxiv.org\u002Fabs\u002F2401.14159)** are now supported in Huggingface. For more convenient use, you can refer to [this documentation](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Ftransformers\u002Fmodel_doc\u002Fgrounding-dino)\n\nWe are very willing to **help everyone share and promote new projects** based on Segment-Anything, Please check out here for more amazing demos and works in the community: [Highlight Extension Projects](#highlighted-projects). You can submit a new issue (with `project` tag) or a new pull request to add new project's links. \n\n![](.\u002Fassets\u002Fgrounded_sam_new_demo_image.png)\n\n![](.\u002Fassets\u002Fram_grounded_sam_new.png)\n\n**🍄 Why Building this Project?**\n\nThe **core idea** behind this project is to **combine the strengths of different models in order to build a very powerful pipeline for solving complex problems**. And it's worth mentioning that this is a workflow for combining strong expert models, where **all parts can be used separately or in combination, and can be replaced with any similar but different models (like replacing Grounding DINO with GLIP or other detectors \u002F replacing Stable-Diffusion with ControlNet or GLIGEN\u002F Combining with ChatGPT)**.\n\n**🍇 Updates**\n- **`2024\u002F01\u002F26`** We have released a comprehensive technical report about our project on arXiv, please check [Grounded SAM: Assembling Open-World Models for Diverse Visual Tasks](https:\u002F\u002Farxiv.org\u002Fabs\u002F2401.14159) for more details. And we are profoundly grateful for the contributions of all the contributors in this project.\n- **`2023\u002F12\u002F17`** Support [Grounded-RepViT-SAM](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything\u002Ftree\u002Fmain\u002FEfficientSAM#run-grounded-repvit-sam-demo) demo, thanks a lot for their great work!\n- **`2023\u002F12\u002F16`** Support [Grounded-Edge-SAM](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything\u002Ftree\u002Fmain\u002FEfficientSAM#run-grounded-edge-sam-demo) demo, thanks a lot for their great work!\n- **`2023\u002F12\u002F10`** Support [Grounded-Efficient-SAM](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything\u002Ftree\u002Fmain\u002FEfficientSAM#run-grounded-efficient-sam-demo) demo, thanks a lot for their great work!\n- **`2023\u002F11\u002F24`** Release [RAM++](https:\u002F\u002Farxiv.org\u002Fabs\u002F2310.15200), which is the next generation of RAM. RAM++ can recognize any category with high accuracy, including both predefined common categories and diverse open-set categories.\n- **`2023\u002F11\u002F23`** Release our newly proposed visual prompt counting model [T-Rex](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FT-Rex). The introduction [Video](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=engIEhZogAQ) and [Demo](https:\u002F\u002Fdeepdataspace.com\u002Fplayground\u002Fivp) is available in [DDS](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002Fdeepdataspace) now.\n- **`2023\u002F07\u002F25`** Support [Light-HQ-SAM](https:\u002F\u002Fgithub.com\u002FSysCV\u002Fsam-hq) in [EfficientSAM](.\u002FEfficientSAM\u002F), credits to [Mingqiao Ye](https:\u002F\u002Fgithub.com\u002Fymq2017) and [Lei Ke](https:\u002F\u002Fgithub.com\u002Flkeab), thanks a lot for their great work!\n- **`2023\u002F07\u002F14`** Combining **Grounding-DINO-B** with [SAM-HQ](https:\u002F\u002Fgithub.com\u002FSysCV\u002Fsam-hq) achieves **49.6 mean AP** in [Segmentation in the Wild](https:\u002F\u002Feval.ai\u002Fweb\u002Fchallenges\u002Fchallenge-page\u002F1931\u002Foverview) competition zero-shot track, surpassing Grounded-SAM by **3.6 mean AP**, thanks for their great work!\n- **`2023\u002F06\u002F28`** Combining Grounding-DINO with Efficient SAM variants including [FastSAM](https:\u002F\u002Fgithub.com\u002FCASIA-IVA-Lab\u002FFastSAM) and [MobileSAM](https:\u002F\u002Fgithub.com\u002FChaoningZhang\u002FMobileSAM) in [EfficientSAM](.\u002FEfficientSAM\u002F) for faster annotating, thanks a lot for their great work!\n- **`2023\u002F06\u002F20`** By combining **Grounding-DINO-L** with **SAM-ViT-H**, Grounded-SAM achieves 46.0 mean AP in [Segmentation in the Wild](https:\u002F\u002Feval.ai\u002Fweb\u002Fchallenges\u002Fchallenge-page\u002F1931\u002Foverview) competition zero-shot track on [CVPR 2023 workshop](https:\u002F\u002Fcomputer-vision-in-the-wild.github.io\u002Fcvpr-2023\u002F), surpassing [UNINEXT (CVPR 2023)](https:\u002F\u002Fgithub.com\u002FMasterBin-IIAU\u002FUNINEXT) by about **4 mean AP**.\n- **`2023\u002F06\u002F16`** Release [RAM-Grounded-SAM Replicate Online Demo](https:\u002F\u002Freplicate.com\u002Fcjwbw\u002Fram-grounded-sam). Thanks a lot to [Chenxi](https:\u002F\u002Fchenxwh.github.io\u002F) for providing this nice demo 🌹.\n- **`2023\u002F06\u002F14`** Support [RAM-Grounded-SAM & SAM-HQ](.\u002Fautomatic_label_ram_demo.py) and update [Simple Automatic Label Demo](.\u002Fautomatic_label_ram_demo.py) to support [RAM](https:\u002F\u002Fgithub.com\u002FOPPOMKLab\u002Frecognize-anything), setting up a strong automatic annotation pipeline.\n- **`2023\u002F06\u002F13`** Checkout the [Autodistill: Train YOLOv8 with ZERO Annotations](https:\u002F\u002Fyoutu.be\u002FgKTYMfwPo4M) tutorial to learn how to use Grounded-SAM + [Autodistill](https:\u002F\u002Fgithub.com\u002Fautodistill\u002Fautodistill) for automated data labeling and real-time model training.\n- **`2023\u002F06\u002F13`** Support [SAM-HQ](https:\u002F\u002Fgithub.com\u002FSysCV\u002Fsam-hq) in [Grounded-SAM Demo](#running_man-grounded-sam-detect-and-segment-everything-with-text-prompt) for higher quality prediction.\n- **`2023\u002F06\u002F12`** Support [RAM-Grounded-SAM](#label-grounded-sam-with-ram-or-tag2text-for-automatic-labeling) for strong automatic labeling pipeline! Thanks for [Recognize-Anything](https:\u002F\u002Fgithub.com\u002FOPPOMKLab\u002Frecognize-anything).\n- **`2023\u002F06\u002F01`** Our Grounded-SAM has been accepted to present a **demo** at [ICCV 2023](https:\u002F\u002Ficcv2023.thecvf.com\u002F)! See you in Paris!\n- **`2023\u002F05\u002F23`**: Support `Image-Referring-Segment`, `Audio-Referring-Segment` and `Text-Referring-Segment` in [ImageBind-SAM](.\u002Fplayground\u002FImageBind_SAM\u002F).\n- **`2023\u002F05\u002F03`**: Checkout the [Automated Dataset Annotation and Evaluation with GroundingDINO and SAM](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Froboflow-ai\u002Fnotebooks\u002Fblob\u002Fmain\u002Fnotebooks\u002Fautomated-dataset-annotation-and-evaluation-with-grounding-dino-and-sam.ipynb) which is an amazing tutorial on automatic labeling! Thanks a lot for [Piotr Skalski](https:\u002F\u002Fgithub.com\u002FSkalskiP) and [Roboflow](https:\u002F\u002Fgithub.com\u002Froboflow\u002Fnotebooks)!\n\n\n## Table of Contents\n- [Grounded-Segment-Anything](#grounded-segment-anything)\n  - [Preliminary Works](#preliminary-works)\n  - [Highlighted Projects](#highlighted-projects)\n- [Installation](#installation)\n  - [Install with Docker](#install-with-docker)\n  - [Install locally](#install-without-docker)\n- [Grounded-SAM Playground](#grounded-sam-playground)\n  - [Step-by-Step Notebook Demo](#open_book-step-by-step-notebook-demo)\n  - [GroundingDINO: Detect Everything with Text Prompt](#running_man-groundingdino-detect-everything-with-text-prompt)\n  - [Grounded-SAM: Detect and Segment Everything with Text Prompt](#running_man-grounded-sam-detect-and-segment-everything-with-text-prompt)\n  - [Grounded-SAM with Inpainting: Detect, Segment and Generate Everything with Text Prompt](#skier-grounded-sam-with-inpainting-detect-segment-and-generate-everything-with-text-prompt)\n  - [Grounded-SAM and Inpaint Gradio APP](#golfing-grounded-sam-and-inpaint-gradio-app)\n  - [Grounded-SAM with RAM or Tag2Text for Automatic Labeling](#label-grounded-sam-with-ram-or-tag2text-for-automatic-labeling)\n  - [Grounded-SAM with BLIP & ChatGPT for Automatic Labeling](#robot-grounded-sam-with-blip-for-automatic-labeling)\n  - [Grounded-SAM with Whisper: Detect and Segment Anything with Audio](#open_mouth-grounded-sam-with-whisper-detect-and-segment-anything-with-audio)\n  - [Grounded-SAM ChatBot with Visual ChatGPT](#speech_balloon-grounded-sam-chatbot-demo)\n  - [Grounded-SAM with OSX for 3D Whole-Body Mesh Recovery](#man_dancing-run-grounded-segment-anything--osx-demo)\n  - [Grounded-SAM with VISAM for Tracking and Segment Anything](#man_dancing-run-grounded-segment-anything--visam-demo)\n  - [Interactive Fashion-Edit Playground: Click for Segmentation And Editing](#dancers-interactive-editing)\n  - [Interactive Human-face Editing Playground: Click And Editing Human Face](#dancers-interactive-editing)\n  - [3D Box Via Segment Anything](#camera-3d-box-via-segment-anything)\n  - [Playground: More Interesting and Imaginative Demos with Grounded-SAM](.\u002Fplayground\u002F)\n    - [DeepFloyd: Image Generation with Text Prompt](.\u002Fplayground\u002FDeepFloyd\u002F)\n    - [PaintByExample: Exemplar-based Image Editing with Diffusion Models](.\u002Fplayground\u002FPaintByExample\u002F)\n    - [LaMa: Resolution-robust Large Mask Inpainting with Fourier Convolutions](.\u002Fplayground\u002FLaMa\u002F)\n    - [RePaint: Inpainting using Denoising Diffusion Probabilistic Models](.\u002Fplayground\u002FRePaint\u002F)\n    - [ImageBind with SAM: Segment with Different Modalities](.\u002Fplayground\u002FImageBind_SAM\u002F)\n  - [Efficient SAM Series for Faster Annotation](.\u002FEfficientSAM\u002F)\n    - [Grounded-FastSAM Demo](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything\u002Ftree\u002Fmain\u002FEfficientSAM#run-grounded-fastsam-demo)\n    - [Grounded-MobileSAM Demo](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything\u002Ftree\u002Fmain\u002FEfficientSAM#run-grounded-mobilesam-demo)\n    - [Grounded-Light-HQSAM Demo](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything\u002Ftree\u002Fmain\u002FEfficientSAM#run-grounded-light-hqsam-demo)\n    - [Grounded-Efficient-SAM Demo](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything\u002Ftree\u002Fmain\u002FEfficientSAM#run-grounded-efficient-sam-demo)\n    - [Grounded-Edge-SAM Demo](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything\u002Ftree\u002Fmain\u002FEfficientSAM#run-grounded-edge-sam-demo)\n    - [Grounded-RepViT-SAM Demo](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything\u002Ftree\u002Fmain\u002FEfficientSAM#run-grounded-repvit-sam-demo)\n- [Citation](#citation)\n\n## Preliminary Works\n\nHere we provide some background knowledge that you may need to know before trying the demos.\n\n\u003Cdiv align=\"center\">\n\n| Title | Intro | Description | Links |\n|:----:|:----:|:----:|:----:|\n| [Segment-Anything](https:\u002F\u002Farxiv.org\u002Fabs\u002F2304.02643) | ![](https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fsegment-anything\u002Fblob\u002Fmain\u002Fassets\u002Fmodel_diagram.png?raw=true) | A strong foundation model aims to segment everything in an image, which needs prompts (as boxes\u002Fpoints\u002Ftext) to generate masks | [[Github](https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fsegment-anything)] \u003Cbr> [[Page](https:\u002F\u002Fsegment-anything.com\u002F)] \u003Cbr> [[Demo](https:\u002F\u002Fsegment-anything.com\u002Fdemo)] |\n| [Grounding DINO](https:\u002F\u002Farxiv.org\u002Fabs\u002F2303.05499) | ![](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGroundingDINO\u002Fblob\u002Fmain\u002F.asset\u002Fhero_figure.png?raw=True) | A strong zero-shot detector which is capable of to generate high quality boxes and labels with free-form text. | [[Github](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGroundingDINO)] \u003Cbr> [[Demo](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FShilongLiu\u002FGrounding_DINO_demo)] |\n| [OSX](http:\u002F\u002Farxiv.org\u002Fabs\u002F2303.16160) | ![](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FOSX\u002Fblob\u002Fmain\u002Fassets\u002Fdemo_video.gif?raw=True) | A strong and efficient one-stage motion capture method to generate high quality 3D human mesh from monucular image. OSX also releases a large-scale upper-body dataset UBody for a more accurate reconstrution in the upper-body scene. | [[Github](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FOSX)] \u003Cbr> [[Page](https:\u002F\u002Fosx-ubody.github.io\u002F)] \u003Cbr> [[Video](https:\u002F\u002Fosx-ubody.github.io\u002F)] \u003Cbr> [[Data](https:\u002F\u002Fdocs.google.com\u002Fforms\u002Fd\u002Fe\u002F1FAIpQLSehgBP7wdn_XznGAM2AiJPiPLTqXXHw5uX9l7qeQ1Dh9HoO_A\u002Fviewform)] |\n| [Stable-Diffusion](https:\u002F\u002Farxiv.org\u002Fabs\u002F2112.10752) | ![](https:\u002F\u002Fgithub.com\u002FCompVis\u002Fstable-diffusion\u002Fblob\u002Fmain\u002Fassets\u002Fstable-samples\u002Ftxt2img\u002Fmerged-0006.png?raw=True) | A super powerful open-source latent text-to-image diffusion model | [[Github](https:\u002F\u002Fgithub.com\u002FCompVis\u002Fstable-diffusion)] \u003Cbr> [[Page](https:\u002F\u002Fommer-lab.com\u002Fresearch\u002Flatent-diffusion-models\u002F)] |\n| [RAM++](https:\u002F\u002Farxiv.org\u002Fabs\u002F2310.15200) | ![](https:\u002F\u002Fgithub.com\u002Fxinyu1205\u002Frecognize-anything\u002Fblob\u002Fmain\u002Fimages\u002Fram_plus_compare.jpg) | RAM++ is the next generation of RAM, which can recognize any category with high accuracy. | [[Github](https:\u002F\u002Fgithub.com\u002FOPPOMKLab\u002Frecognize-anything)] |\n| [RAM](https:\u002F\u002Frecognize-anything.github.io\u002F) | ![](https:\u002F\u002Fgithub.com\u002Fxinyu1205\u002FTag2Text\u002Fraw\u002Fmain\u002Fimages\u002Flocalization_and_recognition.jpg) | RAM is an image tagging model, which can recognize any common category with high accuracy. | [[Github](https:\u002F\u002Fgithub.com\u002FOPPOMKLab\u002Frecognize-anything)] \u003Cbr> [[Demo](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fxinyu1205\u002FRecognize_Anything-Tag2Text)] |\n| [BLIP](https:\u002F\u002Farxiv.org\u002Fabs\u002F2201.12086) | ![](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FLAVIS\u002Fraw\u002Fmain\u002Fdocs\u002F_static\u002Flogo_final.png) | A wonderful language-vision model for image understanding. | [[GitHub](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FLAVIS)] |\n| [Visual ChatGPT](https:\u002F\u002Farxiv.org\u002Fabs\u002F2303.04671) | ![](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FTaskMatrix\u002Fraw\u002Fmain\u002Fassets\u002Ffigure.jpg) | A wonderful tool that connects ChatGPT and a series of Visual Foundation Models to enable sending and receiving images during chatting. | [[Github](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FTaskMatrix)] \u003Cbr> [[Demo](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fmicrosoft\u002Fvisual_chatgpt)] |\n| [Tag2Text](https:\u002F\u002Ftag2text.github.io\u002F) | ![](https:\u002F\u002Fgithub.com\u002Fxinyu1205\u002FTag2Text\u002Fraw\u002Fmain\u002Fimages\u002Ftag2text_framework.png) | An efficient and controllable vision-language model which can simultaneously output superior image captioning and image tagging. | [[Github](https:\u002F\u002Fgithub.com\u002FOPPOMKLab\u002Frecognize-anything)] \u003Cbr> [[Demo](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fxinyu1205\u002FTag2Text)] |\n| [VoxelNeXt](https:\u002F\u002Farxiv.org\u002Fabs\u002F2303.11301) | ![](https:\u002F\u002Fgithub.com\u002Fdvlab-research\u002FVoxelNeXt\u002Fraw\u002Fmaster\u002Fdocs\u002Fsequence-v2.gif) | A clean, simple, and fully-sparse 3D object detector, which predicts objects directly upon sparse voxel features. | [[Github](https:\u002F\u002Fgithub.com\u002Fdvlab-research\u002FVoxelNeXt)] \n\n\u003C\u002Fdiv>\n\n## Highlighted Projects\n\nHere we provide some impressive works you may find interesting:\n\n\u003Cdiv align=\"center\">\n\n| Title | Description | Links |\n|:---:|:---:|:---:|\n| [Semantic-SAM](https:\u002F\u002Fgithub.com\u002FUX-Decoder\u002FSemantic-SAM) | A universal image segmentation model to enable segment and recognize anything at any desired granularity | [[Github](https:\u002F\u002Fgithub.com\u002FUX-Decoder\u002FSemantic-SAM)] \u003Cbr> [[Demo](https:\u002F\u002Fgithub.com\u002FUX-Decoder\u002FSemantic-SAM)] |\n| [SEEM: Segment Everything Everywhere All at Once](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2304.06718.pdf) | A powerful promptable segmentation model supports segmenting with various types of prompts (text, point, scribble, referring image, etc.) and any combination of prompts. | [[Github](https:\u002F\u002Fgithub.com\u002FUX-Decoder\u002FSegment-Everything-Everywhere-All-At-Once)] \u003Cbr> [[Demo](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fxdecoder\u002FSEEM)] |\n| [OpenSeeD](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2303.08131.pdf) | A simple framework for open-vocabulary segmentation and detection which supports interactive segmentation with box input to generate mask | [[Github](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FOpenSeeD)] |\n| [LLaVA](https:\u002F\u002Farxiv.org\u002Fabs\u002F2304.08485) | Visual instruction tuning with GPT-4 | [[Github](https:\u002F\u002Fgithub.com\u002Fhaotian-liu\u002FLLaVA)] \u003Cbr> [[Page](https:\u002F\u002Fllava-vl.github.io\u002F)] \u003Cbr> [[Demo](https:\u002F\u002Fllava.hliu.cc\u002F)] \u003Cbr> [[Data](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fliuhaotian\u002FLLaVA-Instruct-150K)] \u003Cbr> [[Model](https:\u002F\u002Fhuggingface.co\u002Fliuhaotian\u002FLLaVA-13b-delta-v0)] |\n| [GenSAM](https:\u002F\u002Farxiv.org\u002Fabs\u002F2312.07374) | Relaxing the instance-specific manual prompt requirement in SAM through training-free test-time adaptation | [[Github](https:\u002F\u002Fgithub.com\u002FjyLin8100\u002FGenSAM)] \u003Cbr> [[Page](https:\u002F\u002Flwpyh.github.io\u002FGenSAM\u002F)] |\n\n\u003C\u002Fdiv>\n\nWe also list some awesome segment-anything extension projects here you may find interesting:\n- [Computer Vision in the Wild (CVinW) Readings](https:\u002F\u002Fgithub.com\u002FComputer-Vision-in-the-Wild\u002FCVinW_Readings) for those who are interested in open-set tasks in computer vision.\n- [Zero-Shot Anomaly Detection](https:\u002F\u002Fgithub.com\u002Fcaoyunkang\u002FGroundedSAM-zero-shot-anomaly-detection) by Yunkang Cao\n- [EditAnything: ControlNet + StableDiffusion based on the SAM segmentation mask](https:\u002F\u002Fgithub.com\u002Fsail-sg\u002FEditAnything) by Shanghua Gao and Pan Zhou\n- [IEA: Image Editing Anything](https:\u002F\u002Fgithub.com\u002Ffeizc\u002FIEA) by Zhengcong Fei\n- [SAM-MMRorate: Combining Rotated Object Detector and SAM](https:\u002F\u002Fgithub.com\u002FLi-Qingyun\u002Fsam-mmrotate) by Qingyun Li and Xue Yang\n- [Awesome-Anything](https:\u002F\u002Fgithub.com\u002FVainF\u002FAwesome-Anything) by Gongfan Fang\n- [Prompt-Segment-Anything](https:\u002F\u002Fgithub.com\u002FRockeyCoss\u002FPrompt-Segment-Anything) by Rockey\n- [WebUI for Segment-Anything and Grounded-SAM](https:\u002F\u002Fgithub.com\u002Fcontinue-revolution\u002Fsd-webui-segment-anything) by Chengsong Zhang\n- [Inpainting Anything: Inpaint Anything with SAM + Inpainting models](https:\u002F\u002Fgithub.com\u002Fgeekyutao\u002FInpaint-Anything) by Tao Yu\n- [Grounded Segment Anything From Objects to Parts: Combining Segment-Anything with VLPart & GLIP & Visual ChatGPT](https:\u002F\u002Fgithub.com\u002FCheems-Seminar\u002Fsegment-anything-and-name-it) by Peize Sun and Shoufa Chen\n- [Narapi-SAM: Integration of Segment Anything into Narapi (A nice viewer for SAM)](https:\u002F\u002Fgithub.com\u002FMIC-DKFZ\u002Fnapari-sam) by MIC-DKFZ\n- [Grounded Segment Anything Colab](https:\u002F\u002Fgithub.com\u002Fcamenduru\u002Fgrounded-segment-anything-colab) by camenduru\n- [Optical Character Recognition with Segment Anything](https:\u002F\u002Fgithub.com\u002Fyeungchenwa\u002FOCR-SAM) by Zhenhua Yang\n- [Transform Image into Unique Paragraph with ChatGPT, BLIP2, OFA, GRIT, Segment Anything, ControlNet](https:\u002F\u002Fgithub.com\u002Fshowlab\u002FImage2Paragraph) by showlab\n- [Lang-Segment-Anything: Another awesome demo for combining GroundingDINO with Segment-Anything](https:\u002F\u002Fgithub.com\u002Fluca-medeiros\u002Flang-segment-anything) by Luca Medeiros\n- [🥳 🚀 **Playground: Integrate SAM and OpenMMLab!**](https:\u002F\u002Fgithub.com\u002Fopen-mmlab\u002Fplayground)\n- [3D-object via Segment Anything](https:\u002F\u002Fgithub.com\u002Fdvlab-research\u002F3D-Box-Segment-Anything) by Yukang Chen\n- [Image2Paragraph: Transform Image Into Unique Paragraph](https:\u002F\u002Fgithub.com\u002Fshowlab\u002FImage2Paragraph) by Show Lab\n- [Zero-shot Scene Graph Generate with Grounded-SAM](https:\u002F\u002Fgithub.com\u002Fshowlab\u002FImage2Paragraph) by JackWhite-rwx\n- [CLIP Surgery for Better Explainability with Enhancement in Open-Vocabulary Tasks](https:\u002F\u002Fgithub.com\u002Fxmed-lab\u002FCLIP_Surgery) by Eli-YiLi\n- [Panoptic-Segment-Anything: Zero-shot panoptic segmentation using SAM](https:\u002F\u002Fgithub.com\u002Fsegments-ai\u002Fpanoptic-segment-anything) by segments-ai\n- [Caption-Anything: Generates Descriptive Captions for Any Object within an Image](https:\u002F\u002Fgithub.com\u002Fttengwang\u002FCaption-Anything) by Teng Wang\n- [Segment-Anything-3D: Transferring Segmentation Information of 2D Images to 3D Space](https:\u002F\u002Fgithub.com\u002FPointcept\u002FSegmentAnything3D) by Yunhan Yang\n- [Expediting SAM without Fine-tuning](https:\u002F\u002Fgithub.com\u002FExpedit-LargeScale-Vision-Transformer\u002FExpedit-SAM) by Weicong Liang and Yuhui Yuan\n- [Semantic Segment Anything: Providing Rich Semantic Category Annotations for SAM](https:\u002F\u002Fgithub.com\u002Ffudan-zvg\u002FSemantic-Segment-Anything) by Jiaqi Chen and Zeyu Yang and Li Zhang\n- [Enhance Everything: Combining SAM with Image Restoration and Enhancement Tasks](https:\u002F\u002Fgithub.com\u002Flixinustc\u002FEnhance-Anything) by Xin Li\n- [DragGAN](https:\u002F\u002Fgithub.com\u002FZeqiang-Lai\u002FDragGAN) by Shanghai AI Lab.\n- [Tabletop HandyBot: Robotic arm assistant that performs tabletop tasks using Grounded-SAM](https:\u002F\u002Fgithub.com\u002Fycheng517\u002Ftabletop-handybot) by Yifei Cheng\n\n## Installation\nThe code requires `python>=3.8`, as well as `pytorch>=1.7` and `torchvision>=0.8`. Please follow the instructions [here](https:\u002F\u002Fpytorch.org\u002Fget-started\u002Flocally\u002F) to install both PyTorch and TorchVision dependencies. Installing both PyTorch and TorchVision with CUDA support is strongly recommended.\n\n### Install with Docker\n\nOpen one terminal:\n\n```\nmake build-image\n```\n\n```\nmake run\n```\n\nThat's it.\n\nIf you would like to allow visualization across docker container, open another terminal and type:\n\n```\nxhost +\n```\n\n\n### Install without Docker\nYou should set the environment variable manually as follows if you want to build a local GPU environment for Grounded-SAM:\n```bash\nexport AM_I_DOCKER=False\nexport BUILD_WITH_CUDA=True\nexport CUDA_HOME=\u002Fpath\u002Fto\u002Fcuda-11.3\u002F\n```\n\nInstall Segment Anything:\n\n```bash\npython -m pip install -e segment_anything\n```\n\nInstall Grounding DINO:\n\n```bash\npip install --no-build-isolation -e GroundingDINO\n```\n\n\nInstall diffusers:\n\n```bash\npip install --upgrade diffusers[torch]\n```\n\nInstall osx:\n\n```bash\ngit submodule update --init --recursive\ncd grounded-sam-osx && bash install.sh\n```\n\nInstall RAM & Tag2Text:\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fxinyu1205\u002Frecognize-anything.git\npip install -r .\u002Frecognize-anything\u002Frequirements.txt\npip install -e .\u002Frecognize-anything\u002F\n```\n\nThe following optional dependencies are necessary for mask post-processing, saving masks in COCO format, the example notebooks, and exporting the model in ONNX format. `jupyter` is also required to run the example notebooks.\n\n```\npip install opencv-python pycocotools matplotlib onnxruntime onnx ipykernel\n```\n\nMore details can be found in [install segment anything](https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fsegment-anything#installation) and [install GroundingDINO](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGroundingDINO#install) and [install OSX](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FOSX)\n\n\n## Grounded-SAM Playground\nLet's start exploring our Grounding-SAM Playground and we will release more interesting demos in the future, stay tuned!\n\n## :open_book: Step-by-Step Notebook Demo\nHere we list some notebook demo provided in this project:\n- [grounded_sam.ipynb](grounded_sam.ipynb)\n- [grounded_sam_colab_demo.ipynb](grounded_sam_colab_demo.ipynb)\n- [grounded_sam_3d_box.ipynb](grounded_sam_3d_box)\n\n\n### :running_man: GroundingDINO: Detect Everything with Text Prompt\n\n:grapes: [[arXiv Paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2303.05499)] &nbsp; :rose:[[Try the Colab Demo](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Froboflow-ai\u002Fnotebooks\u002Fblob\u002Fmain\u002Fnotebooks\u002Fzero-shot-object-detection-with-grounding-dino.ipynb)] &nbsp; :sunflower: [[Try Huggingface Demo](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FShilongLiu\u002FGrounding_DINO_demo)] &nbsp; :mushroom: [[Automated Dataset Annotation and Evaluation](https:\u002F\u002Fyoutu.be\u002FC4NqaRBz_Kw)]\n\nHere's the step-by-step tutorial on running `GroundingDINO` demo:\n\n**Step 1: Download the pretrained weights**\n\n```bash\ncd Grounded-Segment-Anything\n\n# download the pretrained groundingdino-swin-tiny model\nwget https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGroundingDINO\u002Freleases\u002Fdownload\u002Fv0.1.0-alpha\u002Fgroundingdino_swint_ogc.pth\n```\n\n**Step 2: Running the demo**\n\n```bash\npython grounding_dino_demo.py\n```\n\n\u003Cdetails>\n\u003Csummary> \u003Cb> Running with Python (same as demo but you can run it anywhere after installing GroundingDINO) \u003C\u002Fb> \u003C\u002Fsummary>\n\n```python\nfrom groundingdino.util.inference import load_model, load_image, predict, annotate\nimport cv2\n\nmodel = load_model(\"GroundingDINO\u002Fgroundingdino\u002Fconfig\u002FGroundingDINO_SwinT_OGC.py\", \".\u002Fgroundingdino_swint_ogc.pth\")\nIMAGE_PATH = \"assets\u002Fdemo1.jpg\"\nTEXT_PROMPT = \"bear.\"\nBOX_THRESHOLD = 0.35\nTEXT_THRESHOLD = 0.25\n\nimage_source, image = load_image(IMAGE_PATH)\n\nboxes, logits, phrases = predict(\n    model=model,\n    image=image,\n    caption=TEXT_PROMPT,\n    box_threshold=BOX_THRESHOLD,\n    text_threshold=TEXT_THRESHOLD\n)\n\nannotated_frame = annotate(image_source=image_source, boxes=boxes, logits=logits, phrases=phrases)\ncv2.imwrite(\"annotated_image.jpg\", annotated_frame)\n```\n\n\u003C\u002Fdetails>\n\u003Cbr>\n\n**Tips**\n- If you want to detect multiple objects in one sentence with [Grounding DINO](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGroundingDINO), we suggest separating each name with `.` . An example: `cat . dog . chair .`\n\n**Step 3: Check the annotated image**\n\nThe annotated image will be saved as `.\u002Fannotated_image.jpg`.\n\n\u003Cdiv align=\"center\">\n\n| Text Prompt | Demo Image | Annotated Image |\n|:----:|:----:|:----:|\n| `Bear.` | ![](.\u002Fassets\u002Fdemo1.jpg)  | ![](.\u002Fassets\u002Fannotated_image.jpg) |\n| `Horse. Clouds. Grasses. Sky. Hill` | ![](.\u002Fassets\u002Fdemo7.jpg)  | ![](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002Fdetrex-storage\u002Fblob\u002Fmain\u002Fassets\u002Fgrounded_sam\u002Fgrounding_dino\u002Fgroundingdino_demo7.jpg?raw=true)\n\n\u003C\u002Fdiv>\n\n\n### :running_man: Grounded-SAM: Detect and Segment Everything with Text Prompt\n\nHere's the step-by-step tutorial on running `Grounded-SAM` demo:\n\n**Step 1: Download the pretrained weights**\n\n```bash\ncd Grounded-Segment-Anything\n\nwget https:\u002F\u002Fdl.fbaipublicfiles.com\u002Fsegment_anything\u002Fsam_vit_h_4b8939.pth\nwget https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGroundingDINO\u002Freleases\u002Fdownload\u002Fv0.1.0-alpha\u002Fgroundingdino_swint_ogc.pth\n```\n\nWe provide two versions of Grounded-SAM demo here:\n- [grounded_sam_demo.py](.\u002Fgrounded_sam_demo.py): our original implementation for Grounded-SAM.\n- [grounded_sam_simple_demo.py](.\u002Fgrounded_sam_simple_demo.py) our updated more elegant version for Grounded-SAM.\n\n**Step 2: Running original grounded-sam demo**\n```bash\n# depends on your device \nexport CUDA_VISIBLE_DEVICES=0\n```\n\n```python\n\npython grounded_sam_demo.py \\\n  --config GroundingDINO\u002Fgroundingdino\u002Fconfig\u002FGroundingDINO_SwinT_OGC.py \\\n  --grounded_checkpoint groundingdino_swint_ogc.pth \\\n  --sam_checkpoint sam_vit_h_4b8939.pth \\\n  --input_image assets\u002Fdemo1.jpg \\\n  --output_dir \"outputs\" \\\n  --box_threshold 0.3 \\\n  --text_threshold 0.25 \\\n  --text_prompt \"bear\" \\\n  --device \"cuda\"\n```\n\nThe annotated results will be saved in `.\u002Foutputs` as follows\n\n\u003Cdiv align=\"center\">\n\n| Input Image | Annotated Image | Generated Mask |\n|:----:|:----:|:----:|\n| ![](.\u002Fassets\u002Fdemo1.jpg) | ![](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002Fdetrex-storage\u002Fblob\u002Fmain\u002Fassets\u002Fgrounded_sam\u002Fgrounded_sam\u002Foriginal_grounded_sam_demo1.jpg?raw=true) | ![](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002Fdetrex-storage\u002Fblob\u002Fmain\u002Fassets\u002Fgrounded_sam\u002Fgrounded_sam\u002Fmask.jpg?raw=true) |\n\n\u003C\u002Fdiv>\n\n**Step 3: Running grounded-sam demo with sam-hq**\n- Download the demo image\n```bash\nwget https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002Fdetrex-storage\u002Freleases\u002Fdownload\u002Fgrounded-sam-storage\u002Fsam_hq_demo_image.png\n```\n\n- Download SAM-HQ checkpoint [here](https:\u002F\u002Fgithub.com\u002FSysCV\u002Fsam-hq#model-checkpoints)\n\n- Running grounded-sam-hq demo as follows:\n```python\nexport CUDA_VISIBLE_DEVICES=0\npython grounded_sam_demo.py \\\n  --config GroundingDINO\u002Fgroundingdino\u002Fconfig\u002FGroundingDINO_SwinT_OGC.py \\\n  --grounded_checkpoint groundingdino_swint_ogc.pth \\\n  --sam_hq_checkpoint .\u002Fsam_hq_vit_h.pth \\  # path to sam-hq checkpoint\n  --use_sam_hq \\  # set to use sam-hq model\n  --input_image sam_hq_demo_image.png \\\n  --output_dir \"outputs\" \\\n  --box_threshold 0.3 \\\n  --text_threshold 0.25 \\\n  --text_prompt \"chair.\" \\\n  --device \"cuda\"\n```\n\nThe annotated results will be saved in `.\u002Foutputs` as follows\n\n\u003Cdiv align=\"center\">\n\n| Input Image | SAM Output | SAM-HQ Output |\n|:----:|:----:|:----:|\n| ![](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002Fdetrex-storage\u002Fblob\u002Fmain\u002Fassets\u002Fgrounded_sam\u002Fsam_hq\u002Fsam_hq_demo.png?raw=true) | ![](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002Fdetrex-storage\u002Fblob\u002Fmain\u002Fassets\u002Fgrounded_sam\u002Fsam_hq\u002Fsam_output.jpg?raw=true) | ![](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002Fdetrex-storage\u002Fblob\u002Fmain\u002Fassets\u002Fgrounded_sam\u002Fsam_hq\u002Fsam_hq_output.jpg?raw=true) |\n\n\u003C\u002Fdiv>\n\n**Step 4: Running the updated grounded-sam demo (optional)**\n\nNote that this demo is almost same as the original demo, but **with more elegant code**.\n\n```python\npython grounded_sam_simple_demo.py\n```\n\nThe annotated results will be saved as `.\u002Fgroundingdino_annotated_image.jpg` and `.\u002Fgrounded_sam_annotated_image.jpg`\n\n\u003Cdiv align=\"center\">\n\n| Text Prompt | Input Image | GroundingDINO Annotated Image | Grounded-SAM Annotated Image |\n|:----:|:----:|:----:|:----:|\n| `The running dog` | ![](.\u002Fassets\u002Fdemo2.jpg) | ![](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002Fdetrex-storage\u002Fblob\u002Fmain\u002Fassets\u002Fgrounded_sam\u002Fgrounded_sam\u002Fgroundingdino_annotated_image_demo2.jpg?raw=true) | ![](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002Fdetrex-storage\u002Fblob\u002Fmain\u002Fassets\u002Fgrounded_sam\u002Fgrounded_sam\u002Fgrounded_sam_annotated_image_demo2.jpg?raw=true) |\n| `Horse. Clouds. Grasses. Sky. Hill` | ![](.\u002Fassets\u002Fdemo7.jpg) | ![](assets\u002Fgroundingdino_annotated_image.jpg) | ![](assets\u002Fgrounded_sam_annotated_image.jpg) |\n\n\u003C\u002Fdiv>\n\n**Step 5: Running the Sam model with multi-gpu**\n```bash\nexport CUDA_VISIBLE_DEVICES=0,1\n```\n```python\n\npython grounded_sam_multi_gpu_demo.py \\\n  --config GroundingDINO\u002Fgroundingdino\u002Fconfig\u002FGroundingDINO_SwinT_OGC.py \\\n  --grounded_checkpoint groundingdino_swint_ogc.pth \\\n  --sam_checkpoint sam_vit_h_4b8939.pth \\\n  --input_path assets\u002Fcar \\\n  --output_dir \"outputs\" \\\n  --box_threshold 0.3 \\\n  --text_threshold 0.25 \\\n  --text_prompt \"car\" \\\n  --device \"cuda\"\n```\nYou will see that the model is loaded once per GPU ![](assets\u002Fmulti-gpu.png) \n\n### :skier: Grounded-SAM with Inpainting: Detect, Segment and Generate Everything with Text Prompt\n\n**Step 1: Download the pretrained weights**\n\n```bash\ncd Grounded-Segment-Anything\n\nwget https:\u002F\u002Fdl.fbaipublicfiles.com\u002Fsegment_anything\u002Fsam_vit_h_4b8939.pth\nwget https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGroundingDINO\u002Freleases\u002Fdownload\u002Fv0.1.0-alpha\u002Fgroundingdino_swint_ogc.pth\n```\n\n**Step 2: Running grounded-sam inpainting demo**\n\n```bash\nCUDA_VISIBLE_DEVICES=0\npython grounded_sam_inpainting_demo.py \\\n  --config GroundingDINO\u002Fgroundingdino\u002Fconfig\u002FGroundingDINO_SwinT_OGC.py \\\n  --grounded_checkpoint groundingdino_swint_ogc.pth \\\n  --sam_checkpoint sam_vit_h_4b8939.pth \\\n  --input_image assets\u002Finpaint_demo.jpg \\\n  --output_dir \"outputs\" \\\n  --box_threshold 0.3 \\\n  --text_threshold 0.25 \\\n  --det_prompt \"bench\" \\\n  --inpaint_prompt \"A sofa, high quality, detailed\" \\\n  --device \"cuda\"\n```\n\nThe annotated and inpaint image will be saved in `.\u002Foutputs`\n\n**Step 3: Check the results**\n\n\n\u003Cdiv align=\"center\">\n\n| Input Image | Det Prompt | Annotated Image | Inpaint Prompt | Inpaint Image |\n|:---:|:---:|:---:|:---:|:---:|\n|![](.\u002Fassets\u002Finpaint_demo.jpg) | `Bench` | ![](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002Fdetrex-storage\u002Fblob\u002Fmain\u002Fassets\u002Fgrounded_sam\u002Fgrounded_sam_inpaint\u002Fgrounded_sam_output.jpg?raw=true) | `A sofa, high quality, detailed` | ![](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002Fdetrex-storage\u002Fblob\u002Fmain\u002Fassets\u002Fgrounded_sam\u002Fgrounded_sam_inpaint\u002Fgrounded_sam_inpainting_output.jpg?raw=true) |\n\n\u003C\u002Fdiv>\n\n### :golfing: Grounded-SAM and Inpaint Gradio APP\n\nWe support 6 tasks in the local Gradio APP：\n\n1. **scribble**: Segmentation is achieved through Segment Anything and mouse click interaction (you need to click on the object with the mouse, no need to specify the prompt).\n2. **automask**: Segment the entire image at once through Segment Anything (no need to specify a prompt).\n3. **det**: Realize detection through Grounding DINO and text interaction (text prompt needs to be specified).\n4. **seg**: Realize text interaction by combining Grounding DINO and Segment Anything to realize detection + segmentation (need to specify text prompt).\n5. **inpainting**: By combining Grounding DINO + Segment Anything + Stable Diffusion to achieve text exchange and replace the target object (need to specify text prompt and inpaint prompt) .\n6. **automatic**: By combining BLIP + Grounding DINO + Segment Anything to achieve non-interactive detection + segmentation (no need to specify prompt).\n\n```bash\npython gradio_app.py\n```\n\n- The gradio_app visualization as follows:\n\n![](.\u002Fassets\u002Fgradio_demo.png)\n\n\n### :label: Grounded-SAM with RAM or Tag2Text for Automatic Labeling\n[**The Recognize Anything Models**](https:\u002F\u002Fgithub.com\u002FOPPOMKLab\u002Frecognize-anything) are a series of open-source and strong fundamental image recognition models, including [RAM++](https:\u002F\u002Farxiv.org\u002Fabs\u002F2310.15200), [RAM](https:\u002F\u002Farxiv.org\u002Fabs\u002F2306.03514) and [Tag2text](https:\u002F\u002Farxiv.org\u002Fabs\u002F2303.05657).\n\n\nIt is seamlessly linked to generate pseudo labels automatically as follows:\n1. Use RAM\u002FTag2Text to generate tags.\n2. Use Grounded-Segment-Anything to generate the boxes and masks.\n\n\n**Step 1: Init submodule and download the pretrained checkpoint**\n\n- Init submodule:\n\n```bash\ncd Grounded-Segment-Anything\ngit submodule init\ngit submodule update\n```\n\n- Download pretrained weights for `GroundingDINO`, `SAM` and `RAM\u002FTag2Text`:\n\n```bash\nwget https:\u002F\u002Fdl.fbaipublicfiles.com\u002Fsegment_anything\u002Fsam_vit_h_4b8939.pth\nwget https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGroundingDINO\u002Freleases\u002Fdownload\u002Fv0.1.0-alpha\u002Fgroundingdino_swint_ogc.pth\n\n\nwget https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fxinyu1205\u002FTag2Text\u002Fresolve\u002Fmain\u002Fram_swin_large_14m.pth\nwget https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fxinyu1205\u002FTag2Text\u002Fresolve\u002Fmain\u002Ftag2text_swin_14m.pth\n```\n\n**Step 2: Running the demo with RAM**\n```bash\nexport CUDA_VISIBLE_DEVICES=0\npython automatic_label_ram_demo.py \\\n  --config GroundingDINO\u002Fgroundingdino\u002Fconfig\u002FGroundingDINO_SwinT_OGC.py \\\n  --ram_checkpoint ram_swin_large_14m.pth \\\n  --grounded_checkpoint groundingdino_swint_ogc.pth \\\n  --sam_checkpoint sam_vit_h_4b8939.pth \\\n  --input_image assets\u002Fdemo9.jpg \\\n  --output_dir \"outputs\" \\\n  --box_threshold 0.25 \\\n  --text_threshold 0.2 \\\n  --iou_threshold 0.5 \\\n  --device \"cuda\"\n```\n\n\n**Step 2: Or Running the demo with Tag2Text**\n```bash\nexport CUDA_VISIBLE_DEVICES=0\npython automatic_label_tag2text_demo.py \\\n  --config GroundingDINO\u002Fgroundingdino\u002Fconfig\u002FGroundingDINO_SwinT_OGC.py \\\n  --tag2text_checkpoint tag2text_swin_14m.pth \\\n  --grounded_checkpoint groundingdino_swint_ogc.pth \\\n  --sam_checkpoint sam_vit_h_4b8939.pth \\\n  --input_image assets\u002Fdemo9.jpg \\\n  --output_dir \"outputs\" \\\n  --box_threshold 0.25 \\\n  --text_threshold 0.2 \\\n  --iou_threshold 0.5 \\\n  --device \"cuda\"\n```\n\n- RAM++ significantly improves the open-set capability of RAM, for [RAM++ inference on unseen categoreis](https:\u002F\u002Fgithub.com\u002Fxinyu1205\u002Frecognize-anything#ram-inference-on-unseen-categories-open-set).\n- Tag2Text also provides powerful captioning capabilities, and the process with captions can refer to [BLIP](#robot-run-grounded-segment-anything--blip-demo).\n- The pseudo labels and model prediction visualization will be saved in `output_dir` as follows (right figure):\n\n![](.\u002Fassets\u002Fautomatic_label_output\u002Fdemo9_tag2text_ram.jpg)\n\n\n### :robot: Grounded-SAM with BLIP for Automatic Labeling\nIt is easy to generate pseudo labels automatically as follows:\n1. Use BLIP (or other caption models) to generate a caption.\n2. Extract tags from the caption. We use ChatGPT to handle the potential complicated sentences. \n3. Use Grounded-Segment-Anything to generate the boxes and masks.\n\n- Run Demo\n```bash\nexport OPENAI_API_KEY=your_openai_key\nexport OPENAI_API_BASE=https:\u002F\u002Fcloseai.deno.dev\u002Fv1\nexport CUDA_VISIBLE_DEVICES=0\npython automatic_label_demo.py \\\n  --config GroundingDINO\u002Fgroundingdino\u002Fconfig\u002FGroundingDINO_SwinT_OGC.py \\\n  --grounded_checkpoint groundingdino_swint_ogc.pth \\\n  --sam_checkpoint sam_vit_h_4b8939.pth \\\n  --input_image assets\u002Fdemo3.jpg \\\n  --output_dir \"outputs\" \\\n  --openai_key $OPENAI_API_KEY \\\n  --box_threshold 0.25 \\\n  --text_threshold 0.2 \\\n  --iou_threshold 0.5 \\\n  --device \"cuda\"\n```\n\n- When you don't have a paid Account for ChatGPT is also possible to use NLTK instead. Just don't include the ```openai_key``` Parameter when starting the Demo.\n  - The Script will automatically download the necessary NLTK Data.\n- The pseudo labels and model prediction visualization will be saved in `output_dir` as follows:\n\n![](.\u002Fassets\u002Fautomatic_label_output_demo3.jpg)\n\n\n### :open_mouth: Grounded-SAM with Whisper: Detect and Segment Anything with Audio\nDetect and segment anything with speech!\n\n![](assets\u002Facoustics\u002Fgsam_whisper_inpainting_demo.png)\n\n**Install Whisper**\n```bash\npip install -U openai-whisper\n```\nSee the [whisper official page](https:\u002F\u002Fgithub.com\u002Fopenai\u002Fwhisper#setup) if you have other questions for the installation.\n\n**Run Voice-to-Label Demo**\n\nOptional: Download the demo audio file\n\n```bash\nwget https:\u002F\u002Fhuggingface.co\u002FShilongLiu\u002FGroundingDINO\u002Fresolve\u002Fmain\u002Fdemo_audio.mp3\n```\n\n\n```bash\nexport CUDA_VISIBLE_DEVICES=0\npython grounded_sam_whisper_demo.py \\\n  --config GroundingDINO\u002Fgroundingdino\u002Fconfig\u002FGroundingDINO_SwinT_OGC.py \\\n  --grounded_checkpoint groundingdino_swint_ogc.pth \\\n  --sam_checkpoint sam_vit_h_4b8939.pth \\\n  --input_image assets\u002Fdemo4.jpg \\\n  --output_dir \"outputs\" \\\n  --box_threshold 0.3 \\\n  --text_threshold 0.25 \\\n  --speech_file \"demo_audio.mp3\" \\\n  --device \"cuda\"\n```\n\n![](.\u002Fassets\u002Fgrounded_sam_whisper_output.jpg)\n\n**Run Voice-to-inpaint Demo**\n\nYou can enable chatgpt to help you automatically detect the object and inpainting order with `--enable_chatgpt`. \n\nOr you can specify the object you want to inpaint [stored in `args.det_speech_file`] and the text you want to inpaint with [stored in `args.inpaint_speech_file`].\n\n```bash\nexport OPENAI_API_KEY=your_openai_key\nexport OPENAI_API_BASE=https:\u002F\u002Fcloseai.deno.dev\u002Fv1\n# Example: enable chatgpt\nexport CUDA_VISIBLE_DEVICES=0\npython grounded_sam_whisper_inpainting_demo.py \\\n  --config GroundingDINO\u002Fgroundingdino\u002Fconfig\u002FGroundingDINO_SwinT_OGC.py \\\n  --grounded_checkpoint groundingdino_swint_ogc.pth \\\n  --sam_checkpoint sam_vit_h_4b8939.pth \\\n  --input_image assets\u002Finpaint_demo.jpg \\\n  --output_dir \"outputs\" \\\n  --box_threshold 0.3 \\\n  --text_threshold 0.25 \\\n  --prompt_speech_file assets\u002Facoustics\u002Fprompt_speech_file.mp3 \\\n  --enable_chatgpt \\\n  --openai_key $OPENAI_API_KEY\\\n  --device \"cuda\"\n```\n\n```bash\n# Example: without chatgpt\nexport CUDA_VISIBLE_DEVICES=0\npython grounded_sam_whisper_inpainting_demo.py \\\n  --config GroundingDINO\u002Fgroundingdino\u002Fconfig\u002FGroundingDINO_SwinT_OGC.py \\\n  --grounded_checkpoint groundingdino_swint_ogc.pth \\\n  --sam_checkpoint sam_vit_h_4b8939.pth \\\n  --input_image assets\u002Finpaint_demo.jpg \\\n  --output_dir \"outputs\" \\\n  --box_threshold 0.3 \\\n  --text_threshold 0.25 \\\n  --det_speech_file \"assets\u002Facoustics\u002Fdet_voice.mp3\" \\\n  --inpaint_speech_file \"assets\u002Facoustics\u002Finpaint_voice.mp3\" \\\n  --device \"cuda\"\n```\n\n![](.\u002Fassets\u002Facoustics\u002Fgsam_whisper_inpainting_pipeline.png)\n\n### :speech_balloon: Grounded-SAM ChatBot Demo\n\nhttps:\u002F\u002Fuser-images.githubusercontent.com\u002F24236723\u002F231955561-2ae4ec1a-c75f-4cc5-9b7b-517aa1432123.mp4\n\nFollowing [Visual ChatGPT](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fvisual-chatgpt), we add a ChatBot for our project. Currently, it supports:\n1. \"Describe the image.\"\n2. \"Detect the dog (and the cat) in the image.\"\n3. \"Segment anything in the image.\"\n4. \"Segment the dog (and the cat) in the image.\"\n5. \"Help me label the image.\"\n6. \"Replace the dog with a cat in the image.\"\n\nTo use the ChatBot:\n- Install whisper if you want to use audio as input.\n- Set the default model setting in the tool `Grounded_dino_sam_inpainting`.\n- Run Demo\n```bash\nexport OPENAI_API_KEY=your_openai_key\nexport OPENAI_API_BASE=https:\u002F\u002Fcloseai.deno.dev\u002Fv1\nexport CUDA_VISIBLE_DEVICES=0\npython chatbot.py \n```\n\n### :man_dancing: Run Grounded-Segment-Anything + OSX Demo\n\n\u003Cp align=\"middle\">\n\u003Cimg src=\"assets\u002Fosx\u002Fgrouned_sam_osx_demo.gif\">\n\u003Cbr>\n\u003C\u002Fp>\n\n\n- Download the checkpoint `osx_l_wo_decoder.pth.tar` from [here](https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1x7MZbB6eAlrq5PKC9MaeIm4GqkBpokow?usp=share_link) for OSX:\n- Download the human model files and place it into `grounded-sam-osx\u002Futils\u002Fhuman_model_files` following the instruction of [OSX](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FOSX).\n\n- Run Demo\n\n```shell\nexport CUDA_VISIBLE_DEVICES=0\npython grounded_sam_osx_demo.py \\\n  --config GroundingDINO\u002Fgroundingdino\u002Fconfig\u002FGroundingDINO_SwinT_OGC.py \\\n  --grounded_checkpoint groundingdino_swint_ogc.pth \\\n  --sam_checkpoint sam_vit_h_4b8939.pth \\\n  --osx_checkpoint osx_l_wo_decoder.pth.tar \\\n  --input_image assets\u002Fosx\u002Fgrounded_sam_osx_demo.png \\\n  --output_dir \"outputs\" \\\n  --box_threshold 0.3 \\\n  --text_threshold 0.25 \\\n  --text_prompt \"humans, chairs\" \\\n  --device \"cuda\"\n```\n\n- The model prediction visualization will be saved in `output_dir` as follows:\n\n\u003Cimg src=\"assets\u002Fosx\u002Fgrounded_sam_osx_output.jpg\" style=\"zoom: 49%;\" \u002F>\n\n- We also support promptable 3D whole-body mesh recovery. For example, you can track someone with a text prompt  and estimate his 3D pose and shape :\n\n| ![space-1.jpg](assets\u002Fosx\u002Fgrounded_sam_osx_output1.jpg) |\n| :---------------------------------------------------: |\n|             *A person with pink clothes*              |\n\n| ![space-1.jpg](assets\u002Fosx\u002Fgrounded_sam_osx_output2.jpg) |\n| :---------------------------------------------------: |\n|               *A man with a sunglasses*               |\n\n\n## :man_dancing: Run Grounded-Segment-Anything + VISAM Demo\n\n- Download the checkpoint `motrv2_dancetrack.pth` from [here](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1EA4lndu2yQcVgBKR09KfMe5efbf631Th\u002Fview?usp=share_link) for MOTRv2:\n- See the more thing if you have other questions for the installation.\n\n- Run Demo\n\n```shell\nexport CUDA_VISIBLE_DEVICES=0\npython grounded_sam_visam.py \\\n  --meta_arch motr \\\n  --dataset_file e2e_dance \\\n  --with_box_refine \\\n  --query_interaction_layer QIMv2 \\\n  --num_queries 10 \\\n  --det_db det_db_motrv2.json \\\n  --use_checkpoint \\\n  --mot_path your_data_path \\\n  --resume motrv2_dancetrack.pth \\\n  --sam_checkpoint sam_vit_h_4b8939.pth \\\n  --video_path DanceTrack\u002Ftest\u002Fdancetrack0003 \n```\n|![](https:\u002F\u002Fraw.githubusercontent.com\u002FBingfengYan\u002FMOTSAM\u002Fmain\u002Fvisam.gif)|\n\n\n### :dancers: Interactive Editing\n- Release the interactive fashion-edit playground in [here](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything\u002Ftree\u002FhumanFace). Run in the notebook, just click for annotating points for further segmentation. Enjoy it! \n\n\n- Release human-face-edit branch [here](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything\u002Ftree\u002FhumanFace). We'll keep updating this branch with more interesting features. Here are some examples:\n\n  ![](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything\u002Fblob\u002FhumanFace\u002Fassets\u002F231-hair-edit.png)\n\n## :camera: 3D-Box via Segment Anything\nWe extend the scope to 3D world by combining Segment Anything and [VoxelNeXt](https:\u002F\u002Fgithub.com\u002Fdvlab-research\u002FVoxelNeXt). When we provide a prompt (e.g., a point \u002F box), the result is not only 2D segmentation mask, but also 3D boxes. Please check [voxelnext_3d_box](.\u002Fvoxelnext_3d_box\u002F) for more details.\n  ![](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything\u002Fblob\u002Fmain\u002Fvoxelnext_3d_box\u002Fimages\u002Fsam-voxelnext.png)\n  ![](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything\u002Fblob\u002Fmain\u002Fvoxelnext_3d_box\u002Fimages\u002Fimage_boxes2.png)\n\n\n\n\n## :cupid: Acknowledgements\n\n- [Segment Anything](https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fsegment-anything)\n- [Grounding DINO](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGroundingDINO)\n\n\n## Contributors\n\nOur project wouldn't be possible without the contributions of these amazing people! Thank you all for making this project better.\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything\u002Fgraphs\u002Fcontributors\">\n  \u003Cimg src=\"https:\u002F\u002Fcontrib.rocks\u002Fimage?repo=IDEA-Research\u002FGrounded-Segment-Anything\" \u002F>\n\u003C\u002Fa>\n\n\n## Citation\nIf you find this project helpful for your research, please consider citing the following BibTeX entry.\n```BibTex\n@article{kirillov2023segany,\n  title={Segment Anything}, \n  author={Kirillov, Alexander and Mintun, Eric and Ravi, Nikhila and Mao, Hanzi and Rolland, Chloe and Gustafson, Laura and Xiao, Tete and Whitehead, Spencer and Berg, Alexander C. and Lo, Wan-Yen and Doll{\\'a}r, Piotr and Girshick, Ross},\n  journal={arXiv:2304.02643},\n  year={2023}\n}\n\n@article{liu2023grounding,\n  title={Grounding dino: Marrying dino with grounded pre-training for open-set object detection},\n  author={Liu, Shilong and Zeng, Zhaoyang and Ren, Tianhe and Li, Feng and Zhang, Hao and Yang, Jie and Li, Chunyuan and Yang, Jianwei and Su, Hang and Zhu, Jun and others},\n  journal={arXiv preprint arXiv:2303.05499},\n  year={2023}\n}\n\n@misc{ren2024grounded,\n      title={Grounded SAM: Assembling Open-World Models for Diverse Visual Tasks}, \n      author={Tianhe Ren and Shilong Liu and Ailing Zeng and Jing Lin and Kunchang Li and He Cao and Jiayu Chen and Xinyu Huang and Yukang Chen and Feng Yan and Zhaoyang Zeng and Hao Zhang and Feng Li and Jie Yang and Hongyang Li and Qing Jiang and Lei Zhang},\n      year={2024},\n      eprint={2401.14159},\n      archivePrefix={arXiv},\n      primaryClass={cs.CV}\n}\n```\n","Grounded-Segment-Anything 是一个结合了 Grounding DINO 与 Segment Anything 的项目，旨在通过文本输入自动检测和分割图像中的任何对象。其核心功能包括开放词汇检测、开放词汇分割以及基于文本的图像编辑，利用了先进的深度学习技术如Transformer架构。该项目特别适合需要对复杂场景下的图像进行精确标注和处理的应用场景，例如自动驾驶、医疗影像分析以及创意内容生成等。此外，它还支持多种部署方式，包括Colab笔记本、HuggingFace Space及Stable Diffusion WebUI，便于开发者快速上手和集成到现有工作流中。",2,"2026-06-11 03:43:21","high_star"]