看pytorch入门教程
# 元祖
a = (1, 2)
# 字典
b = {'username': 'peipeiwang', 'code': '111'}
# 数组
c = [1, 2, 3]
print(a[0])
print(c[0])
print(b["username"])
输出:

import torchvision
from PIL import ImageDraw
# 导入coco 2017 验证集和对应annotations
coco_dataset = torchvision.datasets.CocoDetection(root="COCO_dataset_val_2017/val2017",
annFile="COCO_dataset_val_2017/annotations_trainval2017/annotations/instances_val2017.json")
# 图像和annotation分开读取
image, info = coco_dataset[0]
# ImageDraw 画图工具
image_handler = ImageDraw.ImageDraw(image)
for annotation in info:
# bbox为检测框的位置坐标
x_min, y_min, width, height = annotation['bbox']
# ((), ())分别为左上角的坐标对和右上角的坐标对,image_handler.rectangle是指在图片是绘制方框
image_handler.rectangle(((x_min, y_min), (x_min + width, y_min + height)))
image.show()
结果:

使用cvat工具创建自己的数据集标注,导出为coco格式并读取
结果:

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
长按识别二维码并关注微信
更方便到期提醒、手机管理