Effect

class text_renderer.effect.Effect(p=0.5)[source]

Apply different augmentations to image.

E.g. add noise, add dropout, add padding…

Parameters

p (float) – Probability of apply this effect

abstract apply(img: PIL.Image.Image, text_bbox: text_renderer.utils.bbox.BBox)[source]
Parameters
  • img (PILImage) – Image to apply effect

  • text_bbox (BBox) – bbox of text on input Image

Returns

  • PILImage – Image changed

  • BBox – Text bbox on image after apply effect. Some effects (such as Padding) may modify the relative position of the text in the image.

static rand_pick(pim, col, row)[source]

Randomly reset pixel value at [col, row]

new_pixel_value = random.randint(0, pixel_value)

Parameters
  • pim (PyAccess) – Get from pil_img.load()

  • col (int) –

  • row (int) –

class text_renderer.effect.Effects(effects: Union[text_renderer.effect.base_effect.Effect, List[text_renderer.effect.base_effect.Effect], text_renderer.effect.selector.Selector, List[text_renderer.effect.selector.Selector]])[source]

Apply multiple effects

Parameters

effects (Effect or List[Effect]) –

apply_effects(img: PIL.Image.Image, bbox: text_renderer.utils.bbox.BBox) → Tuple[PIL.Image.Image, text_renderer.utils.bbox.BBox][source]
Parameters
  • img

  • bbox – bbox of text on input Image

Returns:

class text_renderer.effect.NoEffects[source]

Placeholder when you don’t want to apply effects for multi corpus

class text_renderer.effect.OneOf(effects: List[Effect])[source]
Parameters

effects (list of Effect) –