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

蓬莱网站建设公司郴州在哪里

蓬莱网站建设公司,郴州在哪里,深圳最新消息今天新增病例,学校网站建设的重要意义行人持刀检测数据集 9000张 持刀检测 带标注 voc yolo 行人持刀检测数据集 数据集描述 该数据集旨在用于行人持刀行为的检测任务#xff0c;涵盖了多种场景下的行人图像#xff0c;特别是那些携带刀具的行人。数据集包含大量的图像及其对应的标注信息#xff0c;可用于训练…行人持刀检测数据集 9000张 持刀检测 带标注 voc yolo 行人持刀检测数据集 数据集描述 该数据集旨在用于行人持刀行为的检测任务涵盖了多种场景下的行人图像特别是那些携带刀具的行人。数据集包含大量的图像及其对应的标注信息可用于训练计算机视觉模型以识别和定位行人手中的刀具。 数据规模 数据集共有9000张图像这些图像都带有详细的标注信息。 类别及数量 数据集中的主要类别为 行人持刀 (person_with_knife)标注出图像中携带刀具的行人。 标注格式 数据集中的标注信息采用了VOCVisual Object Classes格式每个图像都有一个对应的XML文件记录了每个对象的位置信息边界框坐标和类别标签。此外也可以选择YOLO格式的标注文件TXT文件方便使用YOLO系列模型进行训练。 数据集结构 典型的数据集目录结构如下 深色版本 1pedestrian_knife_detection_dataset/ 2├── Annotations/ 3│ ├── img_0001.xml 4│ ├── img_0002.xml 5│ └── ... 6├── ImageSets/ 7│ ├── Main/ 8│ │ ├── train.txt 9│ │ ├── val.txt 10│ │ └── test.txt 11├── JPEGImages/ 12│ ├── img_0001.jpg 13│ ├── img_0002.jpg 14│ └── ... 15└── labels/ 16 ├── train/ 17 │ ├── img_0001.txt 18 │ ├── img_0002.txt 19 └── val/ 20 ├── img_0001.txt 21 ├── img_0002.txt 应用场景 该数据集可以用于以下应用场景 公共安全实时监测公共场所中的行人是否携带刀具提高公共安全水平。安防监控辅助安防系统的视频监控及时发现潜在威胁。事件响应在发生紧急事件时快速识别携带刀具的人员以便采取相应措施。科研分析用于研究行人持刀行为的识别技术和算法。 示例代码 以下是一个使用Python和相关库如OpenCV、PyTorch等来加载和展示数据集的简单示例代码 python 深色版本 1import os 2import cv2 3import xml.etree.ElementTree as ET 4from PIL import Image 5import numpy as np 6 7# 数据集路径 8dataset_path path/to/pedestrian_knife_detection_dataset/ 9 10# 加载图像和标签 11def load_image_and_label(image_path, annotation_path): 12 # 读取图像 13 image Image.open(image_path).convert(RGB) 14 # 解析XML文件 15 tree ET.parse(annotation_path) 16 root tree.getroot() 17 objects [] 18 for obj in root.findall(object): 19 name obj.find(name).text 20 bbox obj.find(bndbox) 21 xmin int(bbox.find(xmin).text) 22 ymin int(bbox.find(ymin).text) 23 xmax int(bbox.find(xmax).text) 24 ymax int(bbox.find(ymax).text) 25 objects.append([xmin, ymin, xmax, ymax, name]) 26 return image, objects 27 28# 展示图像 29def show_image_with_boxes(image, boxes): 30 img np.array(image) 31 for box in boxes: 32 xmin, ymin, xmax, ymax, name box 33 cv2.rectangle(img, (xmin, ymin), (xmax, ymax), (0, 255, 0), 2) 34 cv2.putText(img, name, (xmin, ymin - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2) 35 cv2.imshow(Image with Boxes, img) 36 cv2.waitKey(0) 37 cv2.destroyAllWindows() 38 39# 主函数 40if __name__ __main__: 41 images_dir os.path.join(dataset_path, JPEGImages) 42 annotations_dir os.path.join(dataset_path, Annotations) 43 44 # 获取图像列表 45 image_files [f for f in os.listdir(images_dir) if f.endswith(.jpg)] 46 47 # 随机选择一张图像 48 selected_image np.random.choice(image_files) 49 image_path os.path.join(images_dir, selected_image) 50 annotation_path os.path.join(annotations_dir, selected_image.replace(.jpg, .xml)) 51 52 # 加载图像和标签 53 image, boxes load_image_and_label(image_path, annotation_path) 54 55 # 展示带有标注框的图像 56 show_image_with_boxes(image, boxes) 这段代码展示了如何加载图像和其对应的VOC XML标注文件并在图像上绘制边界框和类别标签。您可以根据实际需求进一步扩展和修改这段代码以适应您的具体应用场景。 示例代码从VOC格式转换为YOLO格式 以下是将VOC格式的标注文件转换为YOLO格式的标签文件的示例代码 python 深色版本 1import os 2import xml.etree.ElementTree as ET 3import shutil 4 5# 数据集路径 6dataset_path path/to/pedestrian_knife_detection_dataset/ 7 8# VOC标注文件目录 9voc_annotations_dir os.path.join(dataset_path, Annotations) 10# 输出YOLO标签文件目录 11yolo_labels_dir os.path.join(dataset_path, labels) 12 13# 创建YOLO标签目录 14os.makedirs(yolo_labels_dir, exist_okTrue) 15 16# 复制VOC图像集划分文件到YOLO目录 17for split in [train, val]: 18 shutil.copy(os.path.join(dataset_path, ImageSets/Main/{}.txt.format(split)), os.path.join(yolo_labels_dir, {}.txt.format(split))) 19 20# 从VOC格式转换为YOLO格式 21def convert_voc_to_yolo(voc_path, yolo_path, width, height): 22 with open(voc_path, r) as infile: 23 tree ET.parse(infile) 24 root tree.getroot() 25 objects [] 26 for obj in root.findall(object): 27 name obj.find(name).text 28 bbox obj.find(bndbox) 29 xmin int(bbox.find(xmin).text) 30 ymin int(bbox.find(ymin).text) 31 xmax int(bbox.find(xmax).text) 32 ymax int(bbox.find(ymax).text) 33 x_center (xmin xmax) / 2.0 34 y_center (ymin ymax) / 2.0 35 w xmax - xmin 36 h ymax - ymin 37 x_center / width 38 y_center / height 39 w / width 40 h / height 41 objects.append([name, x_center, y_center, w, h]) 42 43 with open(yolo_path, w) as outfile: 44 for obj in objects: 45 class_index {person_with_knife: 0}[obj[0]] # 假设只有一个类别 46 line f{class_index} {obj[1]} {obj[2]} {obj[3]} {obj[4]}\n 47 outfile.write(line) 48 49# 主函数 50if __name__ __main__: 51 # 获取VOC标注文件列表 52 voc_files [f for f in os.listdir(voc_annotations_dir) if f.endswith(.xml)] 53 54 # 遍历VOC文件并转换为YOLO格式 55 for voc_file in voc_files: 56 # 获取图像尺寸 57 image_file os.path.join(dataset_path, JPEGImages, voc_file.replace(.xml, .jpg)) 58 image Image.open(image_file) 59 width, height image.size 60 61 # 转换并保存YOLO标签文件 62 yolo_file os.path.join(yolo_labels_dir, voc_file.replace(.xml, .txt)) 63 convert_voc_to_yolo(os.path.join(voc_annotations_dir, voc_file), yolo_file, width, height) 这段代码展示了如何将VOC格式的标注文件转换为YOLO格式的标签文件方便使用YOLO系列模型进行训练。您可以根据实际需求进一步扩展和修改这段代码以适应您的具体应用场景。如果您的数据集中有多个类别请调整 class_index 字典中的映射关系。
http://www.hkea.cn/news/14583275/

相关文章:

  • 天津网站建设技术托管企业网站能个人备案吗
  • 长沙企业网站建设价格猪八戒网兼职接单
  • 百度有个学习的网站建设叫什么flash网站模板下载
  • 梅州东莞网站建设北京网络公司网站
  • 潍坊网站建设培训班手机电脑网站
  • 旅游网站的建设wordpress同步twitter
  • wordpress适合任务网站吗南京seo关键词优化服务
  • 保山 网站建设网页播放视频 网站开发
  • 公司网站封面怎么做网站分类查询
  • 网站开发入门ppt股票推荐怎么做网站
  • 做公众号的模版的网站腾讯建站平台官网
  • 上海城乡建设部网站首页嵌入式培训总结
  • 遵义原创网站江苏建设人才的网站
  • 上海网站建设 zl三北防护林体系建设网站
  • 网站建设贰金手指下拉租赁公司租赁业务
  • 网站开发工程师的工作描述网页版qq邮箱怎么发文件
  • dw网页设计制作网站的成品如何建设一个视频网站
  • 做那个的视频网站企业网站有哪些类型
  • 小学生做网站沈阳网站建设招标公司
  • 网站建设指导思想建站要多少钱
  • 苏州有哪些做网站公司好网站上传的工具
  • 网站建设加排名要多少河南省漯河建设局网站
  • 百度拉新推广平台苏州搜索引擎优化
  • 做中学学中做网站南京知名广告公司
  • 比较好用的微信社群管理软件专业seo排名优化费用
  • 上海微信网站公司哪家好怎么才能有自己的网站
  • 做网站就上微赞网网站导航背景 蓝色
  • 商洛网站建设求职简历asp连接数据库做登录网站完整下载
  • 网站前后台建设难吗三栏 wordpress
  • 企业网站模板下载尽在桂阳网站建设