首页 > 编程知识 正文

opencv 图像数据增广,python最优化算法实战pdf

时间:2023-05-04 01:43:29 阅读:167192 作者:2043

cutout :仅在CNN第1层的输入中使用剪切框Mask。

importtorchimportnumpyasnpclasscutout (object ) : ' ' randomlymaskoutoneormorepatchesfromanimage.args 3360 n _ holes 3360 ength(int ) :thelength ) inpixels ) ofeachsquarepatch.' ' def _ init length (3360 self.n _ holes=n _ holes self.) img ) :''args3360img w ).returns 3360 tensor : image withn _ holesofdimensionlengthxlengthcutoutofit.' ' h=img.simg np.float32 ) forninrange(self.n_holes ) : y=np.random.randint(h ) h ) #随机数/数组(整数) x=NP.random.random h ) )剪切数组中小于或大于某个值的部分,x1=NP.clip (x-self.length/2,0,w ) #然后剪切的部分是固定值x2=NP.clip (x self.length/2,0,w ) #以及剪切的部分x 13360 x2 ]=0. mask=torch.from _ nuum。例如,如果通过修改结实的单元并重新分配一个值,原始阵列也会相应地改变mask=mask.expand_as(img )

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。