Config

class text_renderer.config.GeneratorCfg(num_image: int, save_dir: pathlib.Path, render_cfg: text_renderer.config.RenderCfg)[source]
Parameters
  • num_image (int) – Number of images generated

  • save_dir (Path) – The directory where the data is stored

  • render_cfg (RenderCfg) – Configuration of Render

class text_renderer.config.RenderCfg(corpus: Union[Corpus, List[Corpus]], corpus_effects: Union[text_renderer.effect.base_effect.Effects, List[text_renderer.effect.base_effect.Effects]] = None, bg_dir: pathlib.Path = None, pre_load_bg_img: bool = True, layout: text_renderer.layout.layout.Layout = <text_renderer.layout.same_line.SameLineLayout object>, perspective_transform: text_renderer.config.PerspectiveTransformCfg = None, layout_effects: text_renderer.effect.base_effect.Effects = None, render_effects: text_renderer.effect.base_effect.Effects = None, height: int = 32, gray: bool = True, text_color_cfg: text_renderer.config.TextColorCfg = None, return_bg_and_mask: bool = False)[source]
Parameters
  • corpus (Union[Corpus, List[Corpus]]) –

  • corpus_effects (Union[Effects, List[Effects]]) – Effects apply on text mask image of each corpus. Effects used at this stage must return changed bbox of text if it modified it.

  • bg_dir (Path) – Background image directory

  • pre_load_bg_img (bool) – True: Load all image into memory

  • layout (Layout) – Layout will applied if corpus is a List

  • perspective_transform (PerspectiveTransformCfg) – Apply Perspective Transform

  • layout_effects (Effects) – Effects apply on merged text mask image output by Layout.

  • render_effects (Effects) – Effects apply on final image.

  • height (int) – Resize(keep ratio) image to height, set -1 disables resize

  • gray (bool) – Save image as gray image

  • text_color_cfg (TextColorCfg) – If not None, will overwrite text_color_cfg in CorpusCfg useful to set same text color when use multi corpus

  • return_bg_and_mask (bool) –

class text_renderer.config.PerspectiveTransformCfg(x: float = 10, y: float = 5, z: float = 1.5, scale: int = 1, fovy: int = 50)[source]

Base class for PerspectiveTransform

class text_renderer.config.UniformPerspectiveTransformCfg(x: float = 10, y: float = 5, z: float = 1.5, scale: int = 1, fovy: int = 50)[source]

x,y,z are uniform distributed

class text_renderer.config.NormPerspectiveTransformCfg(x: float = 10, y: float = 5, z: float = 1.5, scale: int = 1, fovy: int = 50)[source]

x,y,z are normally distributed

cliped_rand_norm(mu=0, sigma3: float = 1)[source]
Parameters
  • mu – mean

  • sigma3 – 99% (mu-3*sigma, mu+3*sigma)

Returns

float

class text_renderer.config.TextColorCfg[source]

Base class for TextColorCfg

class text_renderer.config.SimpleTextColorCfg(alpha: Tuple[int, int] = 110, 255)[source]

Randomly use mean value of background image