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


Python mmcv.impad方法代碼示例

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


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

示例1: __call__

# 需要導入模塊: import mmcv [as 別名]
# 或者: from mmcv import impad [as 別名]
def __call__(self, results):
        if results['keep_ratio']:
            gt_seg = mmcv.imrescale(
                results['gt_semantic_seg'],
                results['scale'],
                interpolation='nearest')
        else:
            gt_seg = mmcv.imresize(
                results['gt_semantic_seg'],
                results['scale'],
                interpolation='nearest')
        if results['flip']:
            gt_seg = mmcv.imflip(gt_seg)
        if gt_seg.shape != results['pad_shape']:
            gt_seg = mmcv.impad(gt_seg, results['pad_shape'][:2])
        if self.scale_factor != 1:
            gt_seg = mmcv.imrescale(
                gt_seg, self.scale_factor, interpolation='nearest')
        results['gt_semantic_seg'] = gt_seg
        return results 
開發者ID:tascj,項目名稱:kaggle-kuzushiji-recognition,代碼行數:22,代碼來源:transforms.py

示例2: _pad_img

# 需要導入模塊: import mmcv [as 別名]
# 或者: from mmcv import impad [as 別名]
def _pad_img(self, results):
        """Pad images according to ``self.size``."""
        for key in results.get('img_fields', ['img']):
            if self.size is not None:
                padded_img = mmcv.impad(
                    results[key], shape=self.size, pad_val=self.pad_val)
            elif self.size_divisor is not None:
                padded_img = mmcv.impad_to_multiple(
                    results[key], self.size_divisor, pad_val=self.pad_val)
            results[key] = padded_img
        results['pad_shape'] = padded_img.shape
        results['pad_fixed_size'] = self.size
        results['pad_size_divisor'] = self.size_divisor 
開發者ID:open-mmlab,項目名稱:mmdetection,代碼行數:15,代碼來源:transforms.py

示例3: _pad_seg

# 需要導入模塊: import mmcv [as 別名]
# 或者: from mmcv import impad [as 別名]
def _pad_seg(self, results):
        """Pad semantic segmentation map according to
        ``results['pad_shape']``."""
        for key in results.get('seg_fields', []):
            results[key] = mmcv.impad(
                results[key], shape=results['pad_shape'][:2]) 
開發者ID:open-mmlab,項目名稱:mmdetection,代碼行數:8,代碼來源:transforms.py

示例4: pad

# 需要導入模塊: import mmcv [as 別名]
# 或者: from mmcv import impad [as 別名]
def pad(self, out_shape, pad_val=0):
        """See :func:`BaseInstanceMasks.pad`."""
        if len(self.masks) == 0:
            padded_masks = np.empty((0, *out_shape), dtype=np.uint8)
        else:
            padded_masks = np.stack([
                mmcv.impad(mask, shape=out_shape, pad_val=pad_val)
                for mask in self.masks
            ])
        return BitmapMasks(padded_masks, *out_shape) 
開發者ID:open-mmlab,項目名稱:mmdetection,代碼行數:12,代碼來源:structures.py

示例5: __call__

# 需要導入模塊: import mmcv [as 別名]
# 或者: from mmcv import impad [as 別名]
def __call__(self, masks, pad_shape, scale_factor, flip=False):
        masks = [
            mmcv.imrescale(mask, scale_factor, interpolation='nearest')
            for mask in masks
        ]
        if flip:
            masks = [mask[:, ::-1] for mask in masks]
        padded_masks = [
            mmcv.impad(mask, pad_shape[:2], pad_val=0) for mask in masks
        ]
        padded_masks = np.stack(padded_masks, axis=0)
        return padded_masks 
開發者ID:dingjiansw101,項目名稱:AerialDetection,代碼行數:14,代碼來源:transforms.py

示例6: __call__

# 需要導入模塊: import mmcv [as 別名]
# 或者: from mmcv import impad [as 別名]
def __call__(self, masks, pad_shape, scale_factor, flip=False):
        # aspect ratio unchanged
        if isinstance(scale_factor, float):
            masks = [
                mmcv.imrescale(mask, scale_factor, interpolation='nearest')
                for mask in masks
            ]
        # aspect ratio changed
        else:
            w_ratio, h_ratio = scale_factor[:2]
            if masks:
                h, w = masks[0].shape[:2]
                new_h = int(np.round(h * h_ratio))
                new_w = int(np.round(w * w_ratio))
                new_size = (new_w, new_h)
                masks = [
                    mmcv.imresize(mask, new_size, interpolation='nearest')
                    for mask in masks
                ]
        if flip:
            masks = [mask[:, ::-1] for mask in masks]
        padded_masks = [
            mmcv.impad(mask, pad_shape[:2], pad_val=0) for mask in masks
        ]
        padded_masks = np.stack(padded_masks, axis=0)
        return padded_masks 
開發者ID:xieenze,項目名稱:PolarMask,代碼行數:28,代碼來源:transforms.py

示例7: _pad_img

# 需要導入模塊: import mmcv [as 別名]
# 或者: from mmcv import impad [as 別名]
def _pad_img(self, results):
        if self.size is not None:
            padded_img = mmcv.impad(results['img'], self.size)
        elif self.size_divisor is not None:
            padded_img = mmcv.impad_to_multiple(
                results['img'], self.size_divisor, pad_val=self.pad_val)
        results['img'] = padded_img
        results['pad_shape'] = padded_img.shape
        results['pad_fixed_size'] = self.size
        results['pad_size_divisor'] = self.size_divisor 
開發者ID:tascj,項目名稱:kaggle-kuzushiji-recognition,代碼行數:12,代碼來源:transforms.py

示例8: _pad_masks

# 需要導入模塊: import mmcv [as 別名]
# 或者: from mmcv import impad [as 別名]
def _pad_masks(self, results):
        pad_shape = results['pad_shape'][:2]
        for key in results.get('mask_fields', []):
            padded_masks = [
                mmcv.impad(mask, pad_shape, pad_val=self.pad_val)
                for mask in results[key]
            ]
            results[key] = np.stack(padded_masks, axis=0) 
開發者ID:tascj,項目名稱:kaggle-kuzushiji-recognition,代碼行數:10,代碼來源:transforms.py


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