dataset.py 文件源码

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

项目:Video-Classification-Action-Recognition 作者: qijiezhao 项目源码 文件源码
def transform_rgb_test(self,img,train_size):
        mother_img=img # do not rescale in the testing process
        mother_w,mother_h=mother_img.size
        crop_ix=np.zeros([5,4],dtype=np.int16)
        w_indices=(0,mother_w-train_size)
        h_indices=(0,mother_h-train_size)
        w_center=(mother_w-train_size)/2
        h_center=(mother_h-train_size)/2
        crop_ix[4,:]=[w_center,h_center,train_size+w_center,train_size+h_center]
        cnt=0
        for i in w_indices:
            for j in h_indices:
                crop_ix[cnt,:]=[i,j,i+train_size,j+train_size]
                cnt+=1
        crop_ix=np.tile(crop_ix,(2,1))
        img_return=np.zeros([10,3,train_size,train_size])
        for i in range(10):
            cp=crop_ix[i]
            #embed()
            img_return[i]=np.array(mother_img.crop(cp),dtype=np.float32).transpose([2,0,1])  # transform w*h*channel to channel*w*h
        img_return[5:,:,:,:]=img_return[5:,:,:,::-1] #flipping
        img_return[:,:,:,:]=img_return[:,::-1,:,:]   #transform the RGB to BGR type
        img_return[:,0,:,:]-=104
        img_return[:,1,:,:]-=116
        img_return[:,2,:,:]-=122
            #embed()
        return img_return
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号