MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / Normalize

Class Normalize

detrsmpl/data/datasets/pipelines/transforms.py:681–709  ·  view source on GitHub ↗

Normalize the image. Args: mean (sequence): Mean values of 3 channels. std (sequence): Std values of 3 channels. to_rgb (bool): Whether to convert the image from BGR to RGB, default is true.

Source from the content-addressed store, hash-verified

679
680@PIPELINES.register_module()
681class Normalize(object):
682 """Normalize the image.
683
684 Args:
685 mean (sequence): Mean values of 3 channels.
686 std (sequence): Std values of 3 channels.
687 to_rgb (bool): Whether to convert the image from BGR to RGB,
688 default is true.
689 """
690 def __init__(self, mean, std, to_rgb=True):
691 self.mean = np.array(mean, dtype=np.float32)
692 self.std = np.array(std, dtype=np.float32)
693 self.to_rgb = to_rgb
694
695 def __call__(self, results):
696 for key in results.get('img_fields', ['img']):
697 results[key] = mmcv.imnormalize(results[key], self.mean, self.std,
698 self.to_rgb)
699 results['img_norm_cfg'] = dict(mean=self.mean,
700 std=self.std,
701 to_rgb=self.to_rgb)
702 return results
703
704 def __repr__(self):
705 repr_str = self.__class__.__name__
706 repr_str += f'(mean={list(self.mean)}, '
707 repr_str += f'std={list(self.std)}, '
708 repr_str += f'to_rgb={self.to_rgb})'
709 return repr_str
710
711
712@PIPELINES.register_module()

Callers 5

__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected