The ‘beards’ asset catalog#

!pip install datagen-tech -q

Accessing the catalog#

class datagen.api.catalog.beards#

The “beards” object gives you access to the catalog of facial hair assets. The Assets provided by this catalog are of type datagen.api.assets.Hair.

You can query the facial hair catalog using these functions:

datagen.api.catalog.beards.get(self, id: str = None, limit: int = None, **attributes) Union[Asset, List[Asset]]:#

Gets facial hair assets from the asset catalog.

Parameters:
  • id (str) – Optional. Returns a single Asset matching the chosen UUID.

  • limit (int) –

    Optional. Caps the number of Assets that will be included in the response.

    • If limit=1, returns a single Asset object.

    • If limit>1, returns an object of type List[Asset] (even if there is only one matching facial hair asset in the list).

  • attributes (Any) – Optional. A dictionary of attributes that you can use to filter the catalog. For details see Facial hair attributes below.

Returns:

The asset or assets that match your search query

Return type:

  • List[Asset] in the form of a lazy list

  • Asset when limit=1 or when an id is provided

Sample usage

  • Getting the full set of facial hair assets:

from datagen.api import catalog

catalog.beards.get()

<AssetInstancesList(50)>

  • Getting a specific facial hair asset by id:

from datagen.api import catalog

catalog.beards.get(id="4519dcbc-79c3-4b53-990c-7a73d835d0d3")

Hair(

id=’4519dcbc-79c3-4b53-990c-7a73d835d0d3’,

color_settings=HairColor(

melanin=0.2,

redness=0.2,

whiteness=0.25,

roughness=0.15,

index_of_refraction=1.4

),

attributes=BeardAttributes(style=BeardStyle.BEARD)

)

Note that the facial hair asset is labeled as “hair”, because it uses the same basic structure as a hair object - the only difference being the value of the set of attributes.

  • Using the limit parameter to cap the number of facial hair assets:

from datagen.api import catalog

catalog.beards.get(limit=4)

<AssetInstancesList(4)>

  • Using the limit parameter to get a single facial hair asset:

from datagen.api import catalog

catalog.beards.get(limit=1)

Hair(

id=’0552ea20-a62c-4f5a-bf43-d6dc59fdd617’,

color_settings=HairColor(

melanin=0.2,

redness=0.2,

whiteness=0.25,

roughness=0.15,

index_of_refraction=1.4

),

attributes=BeardAttributes(style=BeardStyle.PARTIAL_BEARD)

)

  • Using attributes to filter the catalog:

from datagen.api import catalog
from datagen.api.catalog import attributes

catalog.beards.get(style=attributes.BeardStyle.MUSTACHE)

<AssetInstancesList(10)>

datagen.api.catalog.beards.count(self, **attributes) int:#

Queries the catalog for the number of assets matching a certain request

Parameters:

attributes (Any) – Optional. A dictionary of attributes that you can use to filter the catalog. For details see Facial hair attributes below.

Returns:

The number of assets in the catalog matching your query.

Return type:

int

Sample usage

  • Counting the full set of facial hair assets:

from datagen.api import catalog

catalog.beards.count()

50

  • Using attributes to filter the catalog:

from datagen.api import catalog
from datagen.api.catalog import attributes

catalog.beards.count(style=attributes.BeardStyle.FULL_BEARD)

10

Facial hair attributes#

class datagen.api.catalog.attributes.BeardAttributes

Each beard asset contains the following read-only attribute.

When you call the datagen.api.catalog.beards.get() or datagen.api.catalog.beards.count() functions, you can use this attribute to filter the catalog.

style: Enum

The general category of facial hair, such as full beard, stubble, or mustache. Uses the BeardStyle enum.

Sample usage:

from datagen.api import catalog
from datagen.api.catalog import attributes

catalog.beards.get(style=attributes.BeardStyle.STUBBLE)

<AssetInstancesList(10)>

Here is the complete list of valid values for this attribute:

class datagen.api.catalog.attributes.BeardStyle

The list of valid beard styles.

This enum is valid for use in the following attributes:

Values:

BEARD = 'beard'
FULL_BEARD = 'full_beard'
MUSTACHE = 'mustache'
PARTIAL_BEARD = 'partial_beard'
STUBBLE = 'stubble'

Properties of facial hair objects#

These are the editable properties of facial hair objects:

id

string

The id property defines the shape, styling, and length of the actor’s facial hair, selecting it from our catalog of facial hair types. This property does not define the facial hair’s color or how it reflects light.

Tip

To download a CSV with a complete list of facial hair styles, click here

Our facial hair types are categorized by style:

Beards

To download a CSV with a complete list of the UUIDs that define beards, click here

Full beards

To download a CSV with a complete list of the UUIDs that define full beards, click here

Mustaches

To download a CSV with a complete list of the UUIDs that define mustaches, click here

Partial beards

To download a CSV with a complete list of the UUIDs that define partial beards, click here

Stubble

To download a CSV with a complete list of the UUIDs that define stubble styles, click here

color_settings

The color_settings object contains a variety of settings that determine the color and shine of the actor’s facial hair.

This code takes a facial hair asset from the catalog and changes the default hair color:

from datagen.api import catalog
from datagen.api import assets

beard=catalog.beards.get(limit=1)
beard.color_settings=assets.HairColor(melanin=0.9, redness=0.7, whiteness=0.04, roughness=0.23, index_of_refraction=1.6)

The color_settings object contains the following properties:

melanin and redness

64-bit floats

The melanin and redness values together define the color of the actor’s facial hair. Melanin is the amount of black color in the hairs; redness is the amount of red. Both properties can accept floating-point values between 0 and 1:

Facial hair melanin vs. redness#
../../_images/Facial_Hair_Melanin_0_Redness_01.png

melanin=0 redness=0#

../../_images/Facial_Hair_Melanin_0_Redness_0.251.png

melanin=0 redness=0.25#

../../_images/Facial_Hair_Melanin_0_Redness_0.51.png

melanin=0 redness=0.5#

../../_images/Facial_Hair_Melanin_0_Redness_0.751.png

melanin=0 redness=0.75#

../../_images/Facial_Hair_Melanin_0_Redness_11.png

melanin=0 redness=1#

../../_images/Facial_Hair_Melanin_0.25_Redness_01.png

melanin=0.25 redness=0#

../../_images/Facial_Hair_Melanin_0.25_Redness_0.251.png

melanin=0.25 redness=0.25#

../../_images/Facial_Hair_Melanin_0.25_Redness_0.51.png

melanin=0.25 redness=0.5#

../../_images/Facial_Hair_Melanin_0.25_Redness_0.751.png

melanin=0.25 redness=0.75#

../../_images/Facial_Hair_Melanin_0.25_Redness_11.png

melanin=0.25 redness=1#

../../_images/Facial_Hair_Melanin_0.5_Redness_01.png

melanin=0.5 redness=0#

../../_images/Facial_Hair_Melanin_0.5_Redness_0.251.png

melanin=0.5 redness=0.25#

../../_images/Facial_Hair_Melanin_0.5_Redness_0.51.png

melanin=0.5 redness=0.5#

../../_images/Facial_Hair_Melanin_0.5_Redness_0.751.png

melanin=0.5 redness=0.75#

../../_images/Facial_Hair_Melanin_0.5_Redness_11.png

melanin=0.5 redness=1#

../../_images/Facial_Hair_Melanin_0.75_Redness_01.png

melanin=0.75 redness=0#

../../_images/Facial_Hair_Melanin_0.75_Redness_0.251.png

melanin=0.75 redness=0.25#

../../_images/Facial_Hair_Melanin_0.75_Redness_0.51.png

melanin=0.75 redness=0.5#

../../_images/Facial_Hair_Melanin_0.75_Redness_0.751.png

melanin=0.75 redness=0.75#

../../_images/Facial_Hair_Melanin_0.75_Redness_11.png

melanin=0.75 redness=1#

../../_images/Facial_Hair_Melanin_1_Redness_01.png

melanin=1 redness=0#

../../_images/Facial_Hair_Melanin_1_Redness_0.251.png

melanin=1 redness=0.25#

../../_images/Facial_Hair_Melanin_1_Redness_0.51.png

melanin=1 redness=0.5#

../../_images/Facial_Hair_Melanin_1_Redness_0.751.png

melanin=1 redness=0.75#

../../_images/Facial_Hair_Melanin_1_Redness_11.png

melanin=1 redness=1#

As you can see in the images above, the relationship between melanin and redness is not linear. The two influence each other greatly. At very high and very low concentrations of melanin, changing the redness has little or no effect. When melanin has medium-level values, the effects of redness are more noticeable.

The values for typical hair colors are:

Blonde: melanin=0.2, redness=0

Red: melanin=0.5, redness=1

Black: melanin=1, redness=0

Dark brown: melanin=0.8, redness=0.2

Light brown: melanin=0.5, redness=0.6

whiteness

64-bit float

The whiteness property defines how much of the hair has begun to go grey or white. This property accepts floating-point values from 0 (no white hairs) to 1 (fully white).

../../_images/Facial_Hair_Whiteness_01.png

Whiteness=0#

../../_images/Facial_Hair_Whiteness_0.251.png

Whiteness=0.25#

../../_images/Facial_Hair_Whiteness_0.51.png

Whiteness=0.5#

../../_images/Facial_Hair_Whiteness_0.751.png

Whiteness=0.75#

../../_images/Facial_Hair_Whiteness_11.png

Whiteness=1#

While the increase in grey and white hairs using this property is not strictly linear, it is still useful to think of this value as whitening the hair roughly in percentage terms. As a rule, values between 0.4 and 0.7 generate greying facial hair, while values above 0.7 generate white facial hair.

roughness

64-bit float

The roughness property affects the reflectivity of the hair. The rougher the surface of the hair, the more light gets absorbed within it and gets reflected as diffuse light rather than mirror-like reflections.

This property accepts floating-point values from 0.15 to 0.5.

../../_images/Facial_Hair_Roughness_0.151.png

roughness=0.15#

../../_images/Facial_Hair_Roughness_0.2551.png

roughness=0.255#

../../_images/Facial_Hair_Roughness_0.51.png

roughness=0.5#

index_of_refraction

64-bit float

The index_of_refraction property affects how the hair bends light that is traveling through it. All hair is at least somewhat translucent, lighter hair in particular. Simulating the changes in the direction of light rays as they travel through the hair is an important part of making hair look realistic.

This property accepts floating-point values from 1.4 to 1.65.

../../_images/Facial_Hair_IOR_1.41.png

index_of_refraction=1.4#

../../_images/Facial_Hair_IOR_1.5251.png

index_of_refraction=1.525#

../../_images/Facial_Hair_IOR_1.651.png

index_of_refraction=1.65#

Although the above images may appear to be in different colors, they all have the same amount of melanin; the only change is in how light reflects inside and through the individual hairs.