【计算机视觉 | 目标检测】Grounding DINO 深度学习环境的配置(含案例)

Grounding DINO:Marrying DINO with Grounded Pre-Training for Open-Set Object Detection”的官方 PyTorch 实现:SoTA 开放集对象检测器。

文章目录

  • 一、Helpful Tutorial
  • 二、相关的论文工作
    • 2.1 相关的论文整理
    • 2.2 论文的亮点
    • 2.3 论文介绍
    • 2.4 Marrying Grounding DINO and GLIGEN
    • 2.5 输入和输出的说明 / 提示
  • 三、环境配置过程
    • 3.1 我的环境
    • 3.2 配置过程
      • 3.2.1 Clone the GroundingDINO repository from GitHub
      • 3.2.2 Change the current directory to the GroundingDINO folder
      • 3.2.3 Install the required dependencies in the current directory
      • 3.2.4 Create a new directory called "weights" to store the model weights
  • 四、测试

一、Helpful Tutorial

论文地址:

https://arxiv.org/abs/2303.05499

在 YouTube 上观看介绍视频:

https://www.youtube.com/watch?v=wxWDt5UiwY8&feature=youtu.be

在这里插入图片描述
Try the Colab Demo:

https://colab.research.google.com/github/roboflow-ai/notebooks/blob/main/notebooks/zero-shot-object-detection-with-grounding-dino.ipynb

Try Official Huggingface Demo:

https://huggingface.co/spaces/ShilongLiu/Grounding_DINO_demo

二、相关的论文工作

2.1 相关的论文整理

在这里插入图片描述

  • Grounded-SAM: Marrying Grounding DINO with Segment Anything
  • Grounding DINO with Stable Diffusion
  • Grounding DINO with GLIGEN for Controllable Image Editing
  • OpenSeeD: A Simple and Strong Openset Segmentation Model
  • SEEM: Segment Everything Everywhere All at Once
  • X-GPT: Conversational Visual Agent supported by X-Decoder
  • GLIGEN: Open-Set Grounded Text-to-Image Generation
  • LLaVA: Large Language and Vision Assistant

2.2 论文的亮点

本工作的亮点:

  1. Open-Set Detection. Detect everything with language!
  2. High Performancce. COCO zero-shot 52.5 AP (training without COCO data!). COCO fine-tune 63.0 AP.
  3. Flexible. Collaboration with Stable Diffusion for Image Editting.

2.3 论文介绍

在这里插入图片描述

2.4 Marrying Grounding DINO and GLIGEN

在这里插入图片描述

2.5 输入和输出的说明 / 提示

  • Grounding DINO accepts an (image, text) pair as inputs.
  • It outputs 900 (by default) object boxes. Each box has similarity scores across all input words. (as shown in Figures below.)
  • We defaultly choose the boxes whose highest similarities are higher than a box_threshold.
  • We extract the words whose similarities are higher than the text_threshold as predicted labels.
  • If you want to obtain objects of specific phrases, like the dogs in the sentence two dogs with a stick., you can select the boxes with highest text similarities with dogs as final outputs.
  • Note that each word can be split to more than one tokens with differetn tokenlizers. The number of words in a sentence may not equal to the number of text tokens.
  • We suggest separating different category names with . for Grounding DINO.
    在这里插入图片描述
    在这里插入图片描述

三、环境配置过程

3.1 我的环境

系统:最新的ubuntu系统

显卡:3090

CUDA:11.3

如果您有 CUDA 环境,请确保设置了环境变量 CUDA_HOME。 如果没有可用的 CUDA,它将在 CPU-only 模式下编译。

3.2 配置过程

3.2.1 Clone the GroundingDINO repository from GitHub

git clone https://github.com/IDEA-Research/GroundingDINO.git

下载后即可找到对应的文件夹:

在这里插入图片描述

3.2.2 Change the current directory to the GroundingDINO folder

cd GroundingDINO/

3.2.3 Install the required dependencies in the current directory

pip3 install -q -e .

不知道为什么,我这个下载一直报错!换一个新的下载方式:

python setup.py install

在这里插入图片描述

但是也会飘红!

这个时候不要害怕,遇到错误的包,直接使用 pip 下载即可,耐得住性子,最后再运行上面的安装命令,即可顺利成功!

在这里插入图片描述

3.2.4 Create a new directory called “weights” to store the model weights

mkdir weights

Change the current directory to the “weights” folder:

cd weights

Download the model weights file:

wget -q https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth

四、测试

Check your GPU ID (only if you’re using a GPU):

nvidia-smi

在这里插入图片描述

Replace {GPU ID}, image_you_want_to_detect.jpg, and “dir you want to save the output” with appropriate values in the following command:

CUDA_VISIBLE_DEVICES={GPU ID} python demo/inference_on_a_image.py \
-c /GroundingDINO/groundingdino/config/GroundingDINO_SwinT_OGC.py \
-p /GroundingDINO/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

当然了,我们也可以使用 Python 进行测试:

from groundingdino.util.inference import load_model, load_image, predict, annotate
import cv2model = load_model("./GroundingDINO/groundingdino/config/GroundingDINO_SwinT_OGC.py", "./GroundingDINO/weights/groundingdino_swint_ogc.pth")
IMAGE_PATH = "./GroundingDINO/weights/1.png"
TEXT_PROMPT = "person . bike . bottle ."
BOX_TRESHOLD = 0.35
TEXT_TRESHOLD = 0.25image_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("./GroundingDINO/weights/annotated_image.jpg", annotated_frame)

我们的测试原图片为:

在这里插入图片描述
测试后的图片为:

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/219036.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

js无法请求后端接口,别的都可以?

在每个接口的控制器中加入以下代码即可: header(Access-Control-Allow-Methods:*); header("Access-Control-Allow-Origin:*"); 如果嫌麻烦可以添加在api初始函数里面

从0开始学习JavaScript--JavaScript事件:响应与交互

JavaScript的事件处理是Web开发中至关重要的一部分,通过事件,能够实现用户与页面的互动,使得网页更加生动和交互性。本文将深入探讨JavaScript事件的各个方面,包括事件的基本概念、事件类型、事件对象、事件冒泡与捕获、事件委托、…

记录华为云服务器(Linux 可视化 宝塔面板)-- Nginx篇

文章目录 配置Nginx服务器1、添加CentOS 7系统的Nginx yum资源库2、安装Nignx服务 设置Nginx安全级别(感觉可以先不设置)步骤一步骤二如有启发,可点赞收藏哟~ 配置Nginx服务器 1、添加CentOS 7系统的Nginx yum资源库 先安装rpm apt instal…

C++双指针算法:统计点对的数目

本周推荐阅读 C二分算法:得到子序列的最少操作次数 本题其它解法 C二分查找:统计点对的数目 题目 给你一个无向图,无向图由整数 n ,表示图中节点的数目,和 edges 组成,其中 edges[i] [ui, vi] 表示 u…

【人工智能】Chatgpt的训练原理

前言 前不久,在学习C语言的我写了一段三子棋的代码,但是与我对抗的电脑是没有任何思考的,你看了这段代码就理解为什么了: void computerMove(char Board[ROW][COL], int row, int col) {while (1){unsigned int i rand() % ROW, …

【全栈开发】Blitz.js与RedwoodJS

技术的不断发展是必然的。如果你仔细观察这片土地,你会注意到随着技术的成熟而出现的某些模式。特别是,开发人员一直在努力提高性能,简化开发过程,增强开发人员体验。 在本指南中,我们将分析两个帮助全栈应用程序世界…

渗透测试--Nacos系统

免责声明: 文章中涉及的漏洞均已修复,敏感信息均已做打码处理,文章仅做经验分享用途,切勿当真,未授权的攻击属于非法行为!文章中敏感信息均已做多层打马处理。传播、利用本文章所提供的信息而造成的任何直…

航天宏图——宏图1号样例数据0.5米-5米分辨率(上海部分)

简介: 作为航天宏图“女娲星座”建设计划的首发卫星,航天宏图-1号可获取0.5米-5米的分辨率影像,具备高精度地形测绘、高精度形变检测、高分辨率宽幅成像以及三维立体成像等能力,在自然资源、应急管理、水利等行业与领域具有极高的…

音频——S/PDIF

文章目录 BMC 编码字帧(sub-frame)格式帧(frame)格式参考S/PDIF 是 SONY 和 Philips 公司共同规定的数字信号传输规范,其实就是在 AES/EBU 上进行改动的家用版本。IEC60958 的标准规范囊括了以上两个规范。spdif 采用了双相符号编码(BMC),是将时钟信号和数据信号混合在一起…

5.7 Windows驱动开发:取进程模块函数地址

在笔者上一篇文章《内核取应用层模块基地址》中简单为大家介绍了如何通过遍历PLIST_ENTRY32链表的方式获取到32位应用程序中特定模块的基地址,由于是入门系列所以并没有封装实现太过于通用的获取函数,本章将继续延申这个话题,并依次实现通用版…

Matplotlib子图的创建_Python数据分析与可视化

Matplotlib子图的创建 plt.axes创建子图fig.add_axes()创建子图 plt.axes创建子图 前面已经介绍过plt.axes函数,这个函数默认配置是创建一个标准的坐标轴,填满整张图。 它还有一个可选的参数,由图形坐标系统的四个值构成。这四个值表示为坐…

栈详解(C语言)

文章目录 写在前面1 栈的定义2 栈的初始化3 数据入栈4 数据出栈5 获取栈顶元素6 获取栈元素个数7 判断栈是否为空8 栈的销毁 写在前面 本片文章详细介绍了另外两种存储逻辑关系为 “一对一” 的数据结构——栈和队列中的栈,并使用C语言实现了数组栈。 栈C语言实现源…