Editing
Visual Grounding
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <span style="color: #FFFFFF;">Applying</span> == '''Open-vocabulary grounding with Grounding DINO + SAM:''' <syntaxhighlight lang="python"> from PIL import Image import torch import numpy as np # Method 1: Grounding DINO for bounding box grounding from groundingdino.util.inference import load_model, load_image, predict, annotate model = load_model("groundingdino/config/GroundingDINO_SwinT_OGC.py", "weights/groundingdino_swint_ogc.pth") image_source, image = load_image("street_scene.jpg") # Ground a natural language description boxes, logits, phrases = predict( model=model, image=image, caption="the woman in the red dress . the yellow car on the left", box_threshold=0.35, text_threshold=0.25 ) annotated = annotate(image_source=image_source, boxes=boxes, logits=logits, phrases=phrases) Image.fromarray(annotated).save("grounded_output.jpg") print(f"Found {len(boxes)} objects: {phrases}") # Method 2: LangSAM (Grounding DINO + SAM combined) from lang_sam import LangSAM lang_sam = LangSAM() image = Image.open("garden.jpg").convert("RGB") # Get segmentation masks for any text description masks, boxes, phrases, logits = lang_sam.predict(image, "red flowers") # masks: list of boolean numpy arrays β precise pixel-level masks for i, (mask, phrase) in enumerate(zip(masks, phrases)): masked_image = np.array(image.copy()) masked_image[~mask] = 0 # Keep only the grounded region Image.fromarray(masked_image).save(f"grounded_mask_{i}.png") </syntaxhighlight> ; Visual grounding systems : '''Open-vocabulary detection''' β Grounding DINO, GLIP, OWL-ViT (Google) : '''Segmentation from text''' β LangSAM, SEEM, X-Decoder : '''Referring expression''' β MDETR, TransVG, SeqTR : '''Multimodal reasoning''' β Qwen2-VL, InternVL2, LLaVA-1.6 (grounded output) : '''Video grounding''' β TubeDETR, MOMA, CLIP4Clip for temporal grounding </div> <div style="background-color: #8B4500; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information