convwthn函数(convet函数)

convwthn函数(convet函数)class RandomHorizo object 随机水平翻转图像以及 bboxes def init self prob 0 5 self prob prob def call self image target if random random lt self prob height width image shape 2 image image flip 1 水平翻转图片 bbox



class RandomHorizontalFlip(object):
"""随机水平翻转图像以及bboxes"""

def __init__(self, prob=0.5):
self.prob = prob

def __call__(self, image, target):
if random.random() < self.prob:
height, width = image.shape[-2:]
image = image.flip(-1) # 水平翻转图片
bbox = target["boxes"]
# bbox: xmin, ymin, xmax, ymax
bbox[:, [0, 2]] = width - bbox[:, [2, 0]] # 翻转对应bbox坐标信息
target["boxes"] = bbox
return image, target













今天的文章 convwthn函数(convet函数)分享到此就结束了,感谢您的阅读。
编程小号
上一篇 2025-02-14 10:33
下一篇 2026-02-11 08:57

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/bian-cheng-ri-ji/42704.html