dataaugmentation.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:deeptracking 作者: lvsn 项目源码 文件源码
def add_hsv_noise(rgb, hue_offset, saturation_offset, value_offset, proba=0.5):
        mask = np.all(rgb != 0, axis=2)
        hsv = rgb2hsv(rgb)
        if random.uniform(0, 1) > proba:
            hsv[:, :, 0] = (hsv[:, :, 0] + random.uniform(-hue_offset, hue_offset)) % 1
        if random.uniform(0, 1) > proba-0.1:
            hsv[:, :, 1] = (hsv[:, :, 1] + random.uniform(-saturation_offset, saturation_offset)) % 1
        if random.uniform(0, 1) > proba-0.1:
            hsv[:, :, 2] = (hsv[:, :, 2] + random.uniform(-value_offset, value_offset)) % 1
        rgb = hsv2rgb(hsv) * 255
        return rgb.astype(np.uint8) * mask[:, :, np.newaxis]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号