IDEA-Research / Grounded-Segment-Anything

Grounded SAM: Marrying Grounding DINO with Segment Anything & Stable Diffusion & Recognize Anything - Automatically Detect , Segment and Generate Anything
https://arxiv.org/abs/2401.14159
Apache License 2.0
14.85k stars 1.37k forks source link

Try to use SAM_HQ, the segment seem fail ! #343

Closed Saoyu99 closed 1 year ago

Saoyu99 commented 1 year ago

when i try to use sam_hq, the segment make some mistake. i use the domo chair pic, and the sam_output is : grounded_sam_output the mask is : mask

my .sh file is : export CUDA_VISIBLE_DEVICES=0 python grounded_sam_demo.py \ --config GroundingDINO/groundingdino/config/GroundingDINO_SwinT_OGC.py \ --grounded_checkpoint groundingdino_swint_ogc.pth \ --sam_checkpoint sam_hq_vit_b.pth \ --use_sam_hq \ --input_image assets/sam_hq_demo_image.png \ --output_dir "outputs" \ --box_threshold 0.3 \ --text_threshold 0.25 \ --text_prompt "chair." \ --device "cuda"

and when i use the ori SAM, all things going to be right, is there any mistake?

yuanxin1995 commented 1 year ago

Is your problem solved? I also encountered the same problem. The picture I used was the default parameter, and the test picture was also provided by the official data. image command: python3 grounded_sam_demo.py --config GroundingDINO/groundingdino/config/GroundingDINO_SwinT_OGC.py --grounded_checkpoint groundingdino_swint_ogc.pth --sam_checkpoint sam_vit_h_4b8939.pth --input_image ./assets/demo1.jpg --output_dir "outputs/bear" --box_threshold 0.3 --text_threshold 0.25 --text_prompt "bear" --device "cuda"

ymq2017 commented 1 year ago

Hi, this is a checkpoint loading problem. For hq-sam, we need to use this argument --sam_hq_checkpoint instead of --sam_checkpoint. In the demo file, they use vit_h backbone, so the example argument for loading the hq-sam checkpoint is --sam_hq_checkpoint ./sam_hq_vit_h.pth. The corresponding checkpoint can be downloaded here.

Saoyu99 commented 1 year ago

@ymq2017 thanks for the help! it works now.

wen-yuan-zhang commented 1 month ago

thanks a lot!