crumpets.rng module

class crumpets.rng.MixtureRNG(prob=1, scale_range=None, shift_range=None, noise_range=None, brightness_range=None, color_range=None, contrast_range=None, blur_range=None, rotation_sigma=0, aspect_sigma=0, interpolations=None, hmirror=0, vmirror=0, shear_range=None)[source]

Bases: crumpets.rng.RNG

Old crumpets 2-style RNG that uses a mix of base probability, Gaussian and uniform distributions to generate parameters. See randomize_image() for more details on allowed values.

..note:

*_range parameters must be 2 numbers (a,b). They define a uniform distribution U[a,b]

..note:

*_sigma parameters define the standard deviation of a Gaussian distribution.

Parameters
  • prob – probability that pixel-based augmentations are applied; each augmentation rolls separately; does not apply to spatial transforms like scale, rotation, etc.

  • scale_range – influences the ‘scale’ value

  • shift_range – influences the ‘shift’ values

  • noise_range – influences the ‘noise’ value

  • brightness_range – influences the ‘gamma_gray’ value; brightness is converted to gamma by convert_gamma()

  • color_range – influences the ‘gamma_color’ values; color values are converted to gamma by convert_gamma()

  • contrast_range – influences the ‘contrast’ value

  • blur_range – influences the ‘blur’ value; effective sigma for Gaussian blur is blur*image_width

  • rotation_sigma – influences the ‘angle’ value

  • aspect_sigma – influences the ‘aspect’ value

  • interpolations – list of possible interpolation methods to use; influences the ‘interp_method’ value

  • hmirror – probability that horizontal mirror is applied; influences the ‘hmirror’ value

  • vmirror – probability that vertical mirror is applied; influences the ‘vmirror’ value

  • shear_range – influences the ‘shear’ values

class crumpets.rng.NoRNG[source]

Bases: crumpets.rng.RNG

Decidedly non-random RNG that simply returns an empty dict. Useful for validation runs.

class crumpets.rng.RNG[source]

Bases: object

Abstract base class for augmentation random number generators (RNG). For further information about the semantics of individual parameters, have a look at randomize_image().

crumpets.rng.human2gamma(human)[source]

Convert some human-understandable value to a value that is suitable for use in gamma correction.

Values outside of [-1,1] are clipped.

Parameters

human – value to convert to gamma

Returns

value suitable for gamma correction