當前位置: 首頁>>代碼示例>>Python>>正文


Python preprocess.get_transform方法代碼示例

本文整理匯總了Python中preprocess.get_transform方法的典型用法代碼示例。如果您正苦於以下問題:Python preprocess.get_transform方法的具體用法?Python preprocess.get_transform怎麽用?Python preprocess.get_transform使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在preprocess的用法示例。


在下文中一共展示了preprocess.get_transform方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_loader

# 需要導入模塊: import preprocess [as 別名]
# 或者: from preprocess import get_transform [as 別名]
def get_loader(self, force_update=False, override_settings=None, subset_indices=None):
        if force_update or self.regime.update(self.epoch, self.steps):
            setting = self.get_setting()
            if override_settings is not None:
                setting.update(override_settings)
            self._transform = get_transform(**setting['transform'])
            setting['data'].setdefault('transform', self._transform)
            self._data = get_dataset(**setting['data'])
            if subset_indices is not None:
                self._data = Subset(self._data, subset_indices)
            if setting['other'].get('distributed', False):
                setting['loader']['sampler'] = DistributedSampler(self._data)
                setting['loader']['shuffle'] = None
                # pin-memory currently broken for distributed
                setting['loader']['pin_memory'] = False
            self._sampler = setting['loader'].get('sampler', None)
            self._loader = torch.utils.data.DataLoader(
                self._data, **setting['loader'])
        return self._loader 
開發者ID:eladhoffer,項目名稱:convNet.pytorch,代碼行數:21,代碼來源:data.py

示例2: __getitem__

# 需要導入模塊: import preprocess [as 別名]
# 或者: from preprocess import get_transform [as 別名]
def __getitem__(self, index):
        left = self.left[index]
        normal = self.normal[index]
        gt = self.gts[index]
        left_img = self.loader(left)
        w,h = left_img.size
        input1,mask1 = self.inloader(gt)
        sparse,mask = self.sloader(normal)

        th, tw = 256, 512
        x1 = random.randint(0, w - tw)
        y1 = random.randint(0, h - th)

        left_img = left_img.crop((x1, y1, x1 + tw, y1 + th))
        data_in1 = input1[y1:y1 + th, x1:x1 + tw,:]
        sparse_n = sparse[y1:y1 + th, x1:x1 + tw,:]
        mask = mask[y1:y1 + th, x1:x1 + tw,:]
        mask1 = mask1[y1:y1 + th, x1:x1 + tw, :]

        processed = preprocess.get_transform(augment=False)
        # processed = scale_crop2()
        left_img = processed(left_img)
        sparse_n = processed(sparse_n)
        return left_img,sparse_n,mask,mask1,data_in1 
開發者ID:JiaxiongQ,項目名稱:DeepLiDAR,代碼行數:26,代碼來源:trainLoaderN.py

示例3: __getitem__

# 需要導入模塊: import preprocess [as 別名]
# 或者: from preprocess import get_transform [as 別名]
def __getitem__(self, index):
        up  = self.up[index]
        down = self.down[index]
        disp_name= self.disp_name[index]
        equi_info = self.equi_infos

        up_img = self.loader(up)
        down_img = self.loader(down)
        disp = self.dploader(disp_name)
        up_img = np.concatenate([np.array(up_img), equi_info],2)
        down_img = np.concatenate([np.array(down_img), equi_info],2)

        if self.training:  
            h, w = up_img.shape[0], up_img.shape[1]
            th, tw = 512, 256

            # vertical remaining cropping 
            x1 = random.randint(0, w - tw)
            y1 = random.randint(0, h - th)
            up_img = up_img[y1:y1+th, x1:x1+tw, :]
            down_img = down_img[y1:y1+th, x1:x1+tw, :]
            disp = np.ascontiguousarray(disp,dtype=np.float32)
            disp = disp[y1:y1 + th, x1:x1 + tw]

            # preprocessing          
            processed = preprocess.get_transform(augment=False)  
            up_img   = processed(up_img)
            down_img  = processed(down_img)
          
            return up_img, down_img, disp
        else:
            disp = np.ascontiguousarray(disp,dtype=np.float32)
          
            processed = preprocess.get_transform(augment=False)  
            up_img       = processed(up_img)
            down_img      = processed(down_img)
          
            return up_img, down_img, disp 
開發者ID:albert100121,項目名稱:360SD-Net,代碼行數:40,代碼來源:RGB_Loader.py

示例4: __getitem__

# 需要導入模塊: import preprocess [as 別名]
# 或者: from preprocess import get_transform [as 別名]
def __getitem__(self, index):
        left = self.left[index]
        input = self.input[index]
        sparse = self.sparse[index]
        left_img = self.loader(left)

        index_str = self.left[index].split('/')[-4][0:10]
        params_t = INSTICS[index_str]
        params = np.ones((256,512,3),dtype=np.float32)
        params[:, :, 0] = params[:,:,0] * params_t[0]
        params[:, :, 1] = params[:, :, 1] * params_t[1]
        params[:, :, 2] = params[:, :, 2] * params_t[2]

        h,w,c= left_img.shape
        input1 = self.inloader(input)
        sparse,mask = self.sloader(sparse)

        th, tw = 256,512
        x1 = random.randint(0, w - tw)
        y1 = random.randint(0, h - th)
        mask = np.reshape(mask, [sparse.shape[0], sparse.shape[1], 1]).astype(np.float32)
        params = np.reshape(params, [256, 512, 3]).astype(np.float32)

        left_img = left_img[y1:y1 + th, x1:x1 + tw, :]
        data_in1 = input1[y1:y1 + th, x1:x1 + tw,:]
        sparse = sparse[y1:y1 + th, x1:x1 + tw, :]
        mask = mask[y1:y1 + th, x1:x1 + tw,:]
        processed = preprocess.get_transform(augment=False)

        left_img = processed(left_img)
        sparse = processed(sparse)
        mask = processed(mask)

        return left_img,data_in1,sparse,mask,params 
開發者ID:JiaxiongQ,項目名稱:DeepLiDAR,代碼行數:36,代碼來源:trainLoader.py

示例5: __getitem__

# 需要導入模塊: import preprocess [as 別名]
# 或者: from preprocess import get_transform [as 別名]
def __getitem__(self, index):
        left  = self.left[index]
        right = self.right[index]
        disp_L= self.disp_L[index]

        left_img = self.loader(left)
        right_img = self.loader(right)
        dataL = self.dploader(disp_L)


        if self.training:  
           w, h = left_img.size
           th, tw = 256, 512
 
           x1 = random.randint(0, w - tw)
           y1 = random.randint(0, h - th)

           left_img = left_img.crop((x1, y1, x1 + tw, y1 + th))
           right_img = right_img.crop((x1, y1, x1 + tw, y1 + th))

           dataL = np.ascontiguousarray(dataL,dtype=np.float32)/256
           dataL = dataL[y1:y1 + th, x1:x1 + tw]

           processed = preprocess.get_transform(augment=False)  
           left_img   = processed(left_img)
           right_img  = processed(right_img)

           return left_img, right_img, dataL
        else:
           w, h = left_img.size

           left_img = left_img.crop((w-1232, h-368, w, h))
           right_img = right_img.crop((w-1232, h-368, w, h))
           w1, h1 = left_img.size

           dataL = dataL.crop((w-1232, h-368, w, h))
           dataL = np.ascontiguousarray(dataL,dtype=np.float32)/256

           processed = preprocess.get_transform(augment=False)  
           left_img       = processed(left_img)
           right_img      = processed(right_img)

           return left_img, right_img, dataL 
開發者ID:JiaRenChang,項目名稱:PSMNet,代碼行數:45,代碼來源:KITTILoader.py


注:本文中的preprocess.get_transform方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。