Safemotion Lib
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
fastreid.data.transforms.autoaugment.AugmentOp Class Reference

Public Member Functions

 __init__ (self, name, prob=0.5, magnitude=10, hparams=None)
 
 __call__ (self, img)
 

Public Attributes

 aug_fn
 
 level_fn
 
 prob
 
 magnitude
 
 hparams
 
 kwargs
 
 magnitude_std
 

Detailed Description

Definition at line 317 of file autoaugment.py.

Constructor & Destructor Documentation

◆ __init__()

fastreid.data.transforms.autoaugment.AugmentOp.__init__ ( self,
name,
prob = 0.5,
magnitude = 10,
hparams = None )

Definition at line 319 of file autoaugment.py.

319 def __init__(self, name, prob=0.5, magnitude=10, hparams=None):
320 hparams = hparams or _HPARAMS_DEFAULT
321 self.aug_fn = NAME_TO_OP[name]
322 self.level_fn = LEVEL_TO_ARG[name]
323 self.prob = prob
324 self.magnitude = magnitude
325 self.hparams = hparams.copy()
326 self.kwargs = dict(
327 fillcolor=hparams['img_mean'] if 'img_mean' in hparams else _FILL,
328 resample=hparams['interpolation'] if 'interpolation' in hparams else _RANDOM_INTERPOLATION,
329 )
330
331 # If magnitude_std is > 0, we introduce some randomness
332 # in the usually fixed policy and sample magnitude from a normal distribution
333 # with mean `magnitude` and std-dev of `magnitude_std`.
334 # NOTE This is my own hack, being tested, not in papers or reference impls.
335 self.magnitude_std = self.hparams.get('magnitude_std', 0)
336

Member Function Documentation

◆ __call__()

fastreid.data.transforms.autoaugment.AugmentOp.__call__ ( self,
img )

Definition at line 337 of file autoaugment.py.

337 def __call__(self, img):
338 if self.prob < 1.0 and random.random() > self.prob:
339 return img
340 magnitude = self.magnitude
341 if self.magnitude_std and self.magnitude_std > 0:
342 magnitude = random.gauss(magnitude, self.magnitude_std)
343 magnitude = min(_MAX_LEVEL, max(0, magnitude)) # clip to valid range
344 level_args = self.level_fn(magnitude, self.hparams) if self.level_fn is not None else tuple()
345 return self.aug_fn(img, *level_args, **self.kwargs)
346
347

Member Data Documentation

◆ aug_fn

fastreid.data.transforms.autoaugment.AugmentOp.aug_fn

Definition at line 321 of file autoaugment.py.

◆ hparams

fastreid.data.transforms.autoaugment.AugmentOp.hparams

Definition at line 325 of file autoaugment.py.

◆ kwargs

fastreid.data.transforms.autoaugment.AugmentOp.kwargs

Definition at line 326 of file autoaugment.py.

◆ level_fn

fastreid.data.transforms.autoaugment.AugmentOp.level_fn

Definition at line 322 of file autoaugment.py.

◆ magnitude

fastreid.data.transforms.autoaugment.AugmentOp.magnitude

Definition at line 324 of file autoaugment.py.

◆ magnitude_std

fastreid.data.transforms.autoaugment.AugmentOp.magnitude_std

Definition at line 335 of file autoaugment.py.

◆ prob

fastreid.data.transforms.autoaugment.AugmentOp.prob

Definition at line 323 of file autoaugment.py.


The documentation for this class was generated from the following file: