pe.api.image.avatar_api module

class pe.api.image.avatar_api.Avatar(res, variation_degrees, crop=(40, 40, 224, 224), num_processes=50, chunksize=100)[source]

Bases: API

The API that uses the python_avatars library to generate synthetic avatar images.

__init__(res, variation_degrees, crop=(40, 40, 224, 224), num_processes=50, chunksize=100)[source]

Constructor.

Parameters:
  • res (int) – The resolution of the generated images

  • variation_degrees (float or list[float]) – The variation degrees utilized at each PE iteration. If a single value is provided, the same variation degree will be used for all iterations. The value means the probability of changing a parameter to a random value.

  • crop (tuple, optional) – The crop of the generated images from the python_avatars library, defaults to (40, 40, 264 - 40, 280 - 56)

  • num_processes (int, optional) – The number of processes to use for parallel generation, defaults to 50

  • chunksize (int, optional) – The chunksize for parallel generation, defaults to 100

_get_params_from_avatar(avatar)[source]

Get the parameters of an avatar.

Parameters:

avatar (python_avatars.Avatar) – The avatar

Returns:

The parameters of the avatar

Return type:

dict

_get_random_image(_)[source]

Get a random image and its parameters.

Parameters:

_ (int) – The index of the sample

Returns:

The image and its parameters

Return type:

tuple[np.ndarray, dict]

_get_variation_image(params, variation_degree)[source]

Get a variation image and its parameters.

Parameters:
  • params (dict) – The parameters of the avatar

  • variation_degree (float) – The degree of variation

Returns:

The image of the avatar and its parameters

Return type:

tuple[np.ndarray, dict]

_svg_to_numpy(svg)[source]

Converts an SVG string to an image in numpy array format.

Parameters:

svg (str) – The SVG string

Returns:

The image in numpy array format

Return type:

np.ndarray

random_api(label_info, num_samples)[source]

Generating random synthetic data.

Parameters:
  • label_info (omegaconf.dictconfig.DictConfig) – The info of the label

  • num_samples (int) – The number of random samples to generate

Returns:

The data object of the generated synthetic data

Return type:

pe.data.Data

variation_api(syn_data)[source]

Creating variations of the synthetic data.

Parameters:

syn_data (pe.data.Data) – The data object of the synthetic data

Returns:

The data object of the variation of the input synthetic data

Return type:

pe.data.Data