Accessing the ‘beards’ asset catalog#

You can access the catalog of facial hair assets using the datagen.api.catalog.beards class. It contains two important functions:

!pip install datagen-tech -q

get()#

The datagen.api.catalog.beards.get() function gets one or more facial hair assets from the asset catalog. These assets come in the form of objects of the datagen.api.assets.Hair class.

To get the full set of facial hair assets:

from datagen.api import catalog

catalog.beards.get()

<AssetInstancesList(50)>

To get a specific facial hair asset using its 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

The facial hair asset is labeled as “hair” because it uses the same basic structure as a hair object. The only difference between head hair, eyebrow hair, and facial hair is the set of attributes.

To cap the number of returned facial hair assets using the limit parameter:

from datagen.api import catalog

catalog.beards.get(limit=4)

<AssetInstancesList(4)>

To get a single facial hair asset using the limit parameter:

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)

)

To filter the facial hair assets using the attributes parameter (see below for the list of valid facial hair attributes):

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

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

<AssetInstancesList(10)>

count()#

The datagen.api.catalog.beards.count() function tells you how many facial hair assets match your query. You can count how many facial hair assets there are in total, or filter the catalog using facial hair attributes.

To count the full set of facial hair assets:

from datagen.api import catalog

catalog.beards.count()

50

To count the number of facial hair assets that match certain attributes (see below for the list of valid facial hair attributes):

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

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

10

Facial hair attributes#

The datagen.api.catalog.attributes.BeardAttributes class defines which attributes can be used to filter the catalog of facial hair assets:

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#

When you get a facial hair object from the catalog, you can edit that object in certain ways. 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.