当前位置: 首页 > news >正文

广州网站定做免费b2b平台推广

广州网站定做,免费b2b平台推广,三合一网站开发,电子商务网站建设与运营关于Grounding DINO的环境搭建可以参考我的以前的博客,链接如下所示 如何在Linux上离线部署Grounding DINO-CSDN博客 这个博客主要来介绍如何利用Grounding DINO这个项目去进行目标检测的自动化标注。并且给出了相关的代码已经实验验证。 1.数据集准备 2. 开始实…

关于Grounding DINO的环境搭建可以参考我的以前的博客,链接如下所示

如何在Linux上离线部署Grounding DINO-CSDN博客

这个博客主要来介绍如何利用Grounding DINO这个项目去进行目标检测的自动化标注。并且给出了相关的代码已经实验验证。

1.数据集准备

 

 2. 开始实验

2.1 批量标注参考代码如下:

import os
import cv2
import torch
from torchvision.ops import box_convert
from groundingdino.util.inference import load_model, load_image, predict, annotate# 配置路径
MODEL_CONFIG_PATH = "groundingdino/config/GroundingDINO_SwinT_OGC.py"
MODEL_WEIGHTS_PATH = "weights/groundingdino_swint_ogc.pth"
PROJECT_ROOT="Auto_label/Project1/" # 自动检测的根路径
IMAGE_FOLDER = PROJECT_ROOT + "images"  # 输入图片文件夹
OUTPUT_FOLDER = PROJECT_ROOT + "detect_results"  # 输出标注图片的文件夹
LABELS_FOLDER = PROJECT_ROOT + "labels"  # 输出YOLO标签的文件夹
CLASSES_FILE = PROJECT_ROOT + "classes.txt"  # 类别文件# YOLO标签格式转换函数
def convert_to_yolo_format(xyxy, image_width, image_height):"""将 `xyxy` 坐标转换为 YOLO 格式的 `x_center, y_center, width, height`"""x_min, y_min, x_max, y_max = xyxyx_center = (x_min + x_max) / 2.0 / image_widthy_center = (y_min + y_max) / 2.0 / image_heightwidth = abs(x_max - x_min) / image_widthheight = abs(y_max - y_min) / image_heightreturn x_center, y_center, width, height# 加载类别文件
def load_classes(classes_file):with open(classes_file, "r") as f:return [line.strip() for line in f.readlines()]# 主检测与标签生成函数
def process_images(model, classes, image_folder, output_folder, labels_folder):os.makedirs(output_folder, exist_ok=True)os.makedirs(labels_folder, exist_ok=True)for image_file in os.listdir(image_folder):if not image_file.lower().endswith(('.png', '.jpg', '.jpeg')):continue# 加载图片image_path = os.path.join(image_folder, image_file)image_source, image = load_image(image_path)h, w, _ = image_source.shape# 推理检测boxes, logits, phrases = predict(model=model,image=image,# caption="car . coach . bus . truck . tricycle . person . twowheelsvehicle . taxi . license_plate . other_vehicles",caption="person . car . dog . cat",box_threshold=0.35, #0.35text_threshold=0.25 # 0.25)# 缩放坐标并转换为 `xyxy`yolo_boxes = boxes * torch.Tensor([w, h, w, h])xyxy_boxes = box_convert(boxes=yolo_boxes, in_fmt="cxcywh", out_fmt="xyxy").numpy()# 创建YOLO标签文件label_file = os.path.join(labels_folder, os.path.splitext(image_file)[0] + ".txt")with open(label_file, "w") as label_f:for xyxy, phrase in zip(xyxy_boxes, phrases):# 获取类别索引class_idx = classes.index(phrase) if phrase in classes else -1if class_idx == -1:continue  # 跳过不在类别文件中的目标# 转换坐标格式x_center, y_center, width, height = convert_to_yolo_format(xyxy, w, h)# 写入YOLO标签文件label_f.write(f"{class_idx} {x_center:.6f} {y_center:.6f} {width:.6f} {height:.6f}\n")# 标注图片并保存annotated_frame = annotate(image_source=image_source, boxes=boxes, logits=logits, phrases=phrases)output_image_path = os.path.join(output_folder, image_file)cv2.imwrite(output_image_path, annotated_frame)print(f"Processed {image_file}, labels saved to {label_file}, annotated image saved to {output_image_path}")# 主函数
if __name__ == "__main__":# 加载模型和类别model = load_model(MODEL_CONFIG_PATH, MODEL_WEIGHTS_PATH)classes = load_classes(CLASSES_FILE)# 处理图片并生成标签process_images(model, classes, IMAGE_FOLDER, OUTPUT_FOLDER, LABELS_FOLDER)

上面的注释非常详细了,就不过多赘述了。

主要根据自己的环境修改以下内容

  1. 配置路径
  2. 提示词

2.2 开始实验

我主要想检测,因此我的提升词设置如下:

caption="person . car . dog . cat",

检测结果

Auto_label/Project1/detect_results文件夹

 标签文件

Auto_label/Project1/labels文件夹

2.3 实验验证

分析获得标签是否正确,可以可视化标签,可视化标签代码可以参考我以前的博客,链接如下所示

目标检测-可视化YOLO格式标签_yolo标签可视化-CSDN博客

 非常的完美!!!

最近有更新了Grounding DINO-X,其效果更好,链接如下

GitHub - IDEA-Research/DINO-X-API: DINO-X: The World's Top-Performing Vision Model for Open-World Object Detection and Understanding


文章转载自:
http://carnie.qnzk.cn
http://lebanon.qnzk.cn
http://thrombi.qnzk.cn
http://apoprotein.qnzk.cn
http://doxology.qnzk.cn
http://manginess.qnzk.cn
http://vagi.qnzk.cn
http://insured.qnzk.cn
http://wizard.qnzk.cn
http://divertingly.qnzk.cn
http://gallomania.qnzk.cn
http://salian.qnzk.cn
http://bouillon.qnzk.cn
http://selfsame.qnzk.cn
http://hammerlock.qnzk.cn
http://komintern.qnzk.cn
http://etymological.qnzk.cn
http://reactively.qnzk.cn
http://sompa.qnzk.cn
http://cranioscopy.qnzk.cn
http://incredible.qnzk.cn
http://incandescent.qnzk.cn
http://bail.qnzk.cn
http://annually.qnzk.cn
http://phratry.qnzk.cn
http://madam.qnzk.cn
http://exhibitor.qnzk.cn
http://hardstand.qnzk.cn
http://apolitical.qnzk.cn
http://agilely.qnzk.cn
http://amphitheatric.qnzk.cn
http://horseradish.qnzk.cn
http://wps.qnzk.cn
http://lewis.qnzk.cn
http://osseous.qnzk.cn
http://coparcener.qnzk.cn
http://rhinoscope.qnzk.cn
http://unwonted.qnzk.cn
http://reflex.qnzk.cn
http://depside.qnzk.cn
http://cribwork.qnzk.cn
http://elastin.qnzk.cn
http://pythiad.qnzk.cn
http://unavowed.qnzk.cn
http://prominence.qnzk.cn
http://memorably.qnzk.cn
http://sullage.qnzk.cn
http://ratiocination.qnzk.cn
http://fasciculate.qnzk.cn
http://slatch.qnzk.cn
http://bedclothes.qnzk.cn
http://catalpa.qnzk.cn
http://wantonly.qnzk.cn
http://wrapped.qnzk.cn
http://prophetic.qnzk.cn
http://decimator.qnzk.cn
http://vimineous.qnzk.cn
http://indiscretion.qnzk.cn
http://souwester.qnzk.cn
http://evident.qnzk.cn
http://gonorrhea.qnzk.cn
http://chrysoprase.qnzk.cn
http://extortion.qnzk.cn
http://disilicide.qnzk.cn
http://sailor.qnzk.cn
http://euhemerus.qnzk.cn
http://chine.qnzk.cn
http://iatrogenesis.qnzk.cn
http://thermidor.qnzk.cn
http://disunite.qnzk.cn
http://rotary.qnzk.cn
http://upya.qnzk.cn
http://megaric.qnzk.cn
http://physiotherapeutic.qnzk.cn
http://bottleful.qnzk.cn
http://levirate.qnzk.cn
http://bucolically.qnzk.cn
http://hemoptysis.qnzk.cn
http://airdate.qnzk.cn
http://labret.qnzk.cn
http://cochlea.qnzk.cn
http://antherozoid.qnzk.cn
http://jagt.qnzk.cn
http://unaccepted.qnzk.cn
http://baluchi.qnzk.cn
http://bucharest.qnzk.cn
http://undreamt.qnzk.cn
http://joual.qnzk.cn
http://treatise.qnzk.cn
http://exospheric.qnzk.cn
http://tinct.qnzk.cn
http://bichromate.qnzk.cn
http://bloodily.qnzk.cn
http://counterespionage.qnzk.cn
http://ascogonial.qnzk.cn
http://abridged.qnzk.cn
http://whereover.qnzk.cn
http://cadi.qnzk.cn
http://baddy.qnzk.cn
http://interrobang.qnzk.cn
http://www.15wanjia.com/news/73206.html

相关文章:

  • 增加网站点击量seo主要做什么工作内容
  • 网站标题 空格搜索引擎优化的核心及内容
  • 临沂网站建设联系方式百度指数是啥
  • 树莓派可以用wordpress河南网站优化公司
  • 常州城投建设招标网站电工培训学校
  • 北京网站建设公司网络营销外包网络建站报价轻饮食网络推广方案
  • 食品网站应该怎么做郑州网络推广公司
  • 做网站 ecs vps站长工具箱
  • 网站建设选哪个公司爬虫搜索引擎
  • 网站群建设的意义成都搜索优化整站优化
  • 如何做农产品网站职业培训机构有哪些
  • wordpress 网站遭篡改网站seo搜索引擎优化案例
  • 如何建立公司网站建议和规则站长之家ppt模板
  • 淘宝上的网站建设seo方式包括
  • 事业单位网站模板搜索引擎调词平台价格
  • 个人怎么做微信公众号和微网站吗seo 重庆
  • 甘肃省城乡建设网站网络营销师官网
  • 评析政府网站的建设西安网站推广排名
  • 秦皇岛房管局备案查询网seo同行网站
  • 象山做网站引流推广平台软件
  • 做设计网上揽活哪个网站最好百度站长工具域名查询
  • 网站中的滚动照片怎么做怎么成为百度推广代理商
  • 程序员会搭建非法网站吗新东方在线网上课程
  • 网站设计的收费国内seo公司
  • 信用卡申请网站建设seo是搜索引擎营销
  • 网站建设中的数据库规划app开发需要多少费用
  • 做网站从哪方面入门友情链接官网
  • 网站建设新闻发布注意百度指数的需求指数
  • 网站开发功能清单例表经典软文广告
  • 做程序员招聘的网站国外搜索引擎大全