IDEA-CVR,思想研究
Shilong Liu,Zhaoyang Zeng,Tianhe Ren,Feng Li,Hao Zhang,Jie Yang,Chunyuan Li,Jianwei Yang,Hang Su,Jun Zhu,Jun Zhu,Lei Zhang ? 。
[ Paper
] [ Demo
] [ BibTex
]
Pytorch实施和验证模型用于接地恐龙。有关详细信息,请参阅纸接地Dino:将Dino与接地预培训结婚以进行开放式对象检测。
2023/07/18
:我们释放语义SAM,这是一种通用图像分割模型,可实现段并识别任何所需粒度的任何内容。代码和检查点可用!2023/06/17
:我们提供了一个示例,以评估Coco Zero-Shot性能的恐龙。2023/04/15
:对于那些对开放式识别感兴趣的人,请参阅野外阅读中的简历!2023/04/08
:我们发布演示,将接地恐龙与Gligen结合起来,以进行更可控制的图像编辑。2023/04/08
:我们发布演示,将接地恐龙与稳定的扩散相结合以进行图像编辑。2023/04/06
:我们通过将“地面”与任何名为“接地段”的部分结合在一起,建立了一个新的演示,目的是支持地面的细分。2023/03/28
:YouTube视频有关接地恐龙和基本对象检测及时工程。 [Skalskip]2023/03/28
:在拥抱脸部空间时添加一个演示!2023/03/27
:支持仅CPU-模式。现在,该模型可以在没有GPU的机器上运行。2023/03/25
:COLAB可用地接地Dino的演示。 [Skalskip]2023/03/22
:现在可以使用代码!(image, text)
对作为输入。900
(默认情况下)对象框。每个框在所有输入单词上都有相似性分数。 (如下图所示。)box_threshold
的框。text_threshold
。dogs
two dogs with a stick.
,您可以选择具有最高文本dogs
性的盒子作为最终输出。.
用于接地恐龙。 笔记:
CUDA_HOME
。如果没有CUDA,它将以仅CPU模式进行编译。请确保严格遵循安装步骤,否则该程序可能会产生:
NameError: name ' _C ' is not defined
如果发生这种情况,请通过seclone git重新安装地面迪诺,然后再次完成所有安装步骤。
echo $CUDA_HOME
如果什么都没打印,则意味着您没有设置路径/
运行此操作,以便将环境变量设置为当前外壳。
export CUDA_HOME=/path/to/cuda-11.3
请注意,CUDA的版本应与您的CUDA运行时对齐,因为可能同时存在多个CUDA。
如果要永久设置CUDA_HOME,请使用:
echo ' export CUDA_HOME=/path/to/cuda ' >> ~ /.bashrc
之后,来源bashrc文件并检查cuda_home:
source ~ /.bashrc
echo $CUDA_HOME
在此示例中,/path/to/cuda-11.3应替换为安装CUDA工具包的路径。您可以通过在您的终端中输入哪个NVCC来找到它:
例如,如果输出为/usr/local/cuda/bin/nvcc,则:
export CUDA_HOME=/usr/local/cuda
安装:
1.从github插入地面仓库。
git clone https://github.com/IDEA-Research/GroundingDINO.git
cd GroundingDINO/
pip install -e .
mkdir weights
cd weights
wget -q https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth
cd ..
检查您的GPU ID(仅当您使用GPU时)
nvidia-smi
替换{GPU ID}
, image_you_want_to_detect.jpg
和"dir you want to save the output"
并在以下命令中使用适当的值
CUDA_VISIBLE_DEVICES={GPU ID} python demo/inference_on_a_image.py
-c groundingdino/config/GroundingDINO_SwinT_OGC.py
-p weights/groundingdino_swint_ogc.pth
-i image_you_want_to_detect.jpg
-o " dir you want to save the output "
-t " chair "
[--cpu-only] # open it for cpu mode
如果您想指定要检测到的短语,这里是一个演示:
CUDA_VISIBLE_DEVICES={GPU ID} python demo/inference_on_a_image.py
-c groundingdino/config/GroundingDINO_SwinT_OGC.py
-p ./groundingdino_swint_ogc.pth
-i .asset/cat_dog.jpeg
-o logs/1111
-t " There is a cat and a dog in the image . "
--token_spans " [[[9, 10], [11, 14]], [[19, 20], [21, 24]]] "
[--cpu-only] # open it for cpu mode
token_spans指定短语的开始和结束位置。例如,第一个短语是[[9, 10], [11, 14]]
。 "There is a cat and a dog in the image ."[9:10] = 'a'
, "There is a cat and a dog in the image ."[11:14] = 'cat'
。因此,它是指a cat
短语。同样, [[19, 20], [21, 24]]
是指a dog
短语。
有关更多详细信息,请参见demo/inference_on_a_image.py
。
与Python一起跑步:
from groundingdino . util . inference import load_model , load_image , predict , annotate
import cv2
model = load_model ( "groundingdino/config/GroundingDINO_SwinT_OGC.py" , "weights/groundingdino_swint_ogc.pth" )
IMAGE_PATH = "weights/dog-3.jpeg"
TEXT_PROMPT = "chair . person . dog ."
BOX_TRESHOLD = 0.35
TEXT_TRESHOLD = 0.25
image_source , image = load_image ( IMAGE_PATH )
boxes , logits , phrases = predict (
model = model ,
image = image ,
caption = TEXT_PROMPT ,
box_threshold = BOX_TRESHOLD ,
text_threshold = TEXT_TRESHOLD
)
annotated_frame = annotate ( image_source = image_source , boxes = boxes , logits = logits , phrases = phrases )
cv2 . imwrite ( "annotated_image.jpg" , annotated_frame )
Web UI
我们还提供了一个演示代码,将接地Dino与Gradio Web UI集成。有关更多详细信息,请参见文件demo/gradio_app.py
。
笔记本
我们提供了一个示例,以评估可可对地面的Dino Zero-Sho-Shot性能。结果应为48.5 。
CUDA_VISIBLE_DEVICES=0
python demo/test_ap_on_coco.py
-c groundingdino/config/GroundingDINO_SwinT_OGC.py
-p weights/groundingdino_swint_ogc.pth
--anno_path /path/to/annoataions/ie/instances_val2017.json
--image_dir /path/to/imagedir/ie/val2017
姓名 | 骨干 | 数据 | 可可的盒子AP | 检查点 | config | |
---|---|---|---|---|---|---|
1 | 接地tino-t | SWIN-T | O365,Goldg,CAP4M | 48.4(零射) / 57.2(微调) | github链接| HF链接 | 关联 |
2 | 接地迪诺-B | SWIN-B | 可可,O365,GoldG,CAP4M,OpenImage,Odinw-35,Refcoco | 56.7 | github链接| HF链接 | 关联 |
包括:文本骨干,图像骨干,功能增强器,语言引导的查询选择和交叉模式解码器。
我们的模型与Dino和Glip有关。感谢他们的出色工作!
我们还要感谢以前的出色工作,包括Detr,可变形的DETR,SMCA,有条件的DETR,锚点DETR,Dynamic Detr,Dab-Dert,DAB-DETR,DN-DET。也可以使用新的工具箱detrex。
感谢Stable扩散和Gligen的出色模型。
如果您发现我们的工作对您的研究有帮助,请考虑引用以下Bibtex条目。
@article { liu2023grounding ,
title = { Grounding dino: Marrying dino with grounded pre-training for open-set object detection } ,
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 } ,
journal = { arXiv preprint arXiv:2303.05499 } ,
year = { 2023 }
}