Accessing the ‘humans’ asset catalog#

You can access the catalog of human assets using the datagen.api.catalog.humans class. It contains two important functions:

!pip install datagen-tech -q

get()#

The datagen.api.catalog.humans.get() function gets one or more human assets from the asset catalog. These assets come in the form of objects of the datagen.api.assets.Human class.

To get the full set of human assets:

from datagen.api import catalog

catalog.humans.get()

<AssetInstancesList(52151)>

To get a specific human asset using its id:

from datagen.api import catalog

catalog.humans.get(id="e5c4ba9b-4648-4e5b-9244-5c9373276408")

Human(

id=’e5c4ba9b-4648-4e5b-9244-5c9373276408’,

head=Head(

eyes=Eyes(

id=’ebdd956c-b763-490e-9afb-baed2c98a0ff’,

target_of_gaze=Gaze(distance=15.0, direction=Vector(x=0.0, y=-1.0, z=0.0)),

eyelid_closure=0.0,

attributes=EyesAttributes(color=EyesColor.BROWN)

),

hair=Hair(

id=’cb7f5afa-70ba-4c8c-a68b-c3bac225e3dd’,

color_settings=HairColor(

melanin=0.0948,

redness=0.9907,

whiteness=0.0679,

roughness=0.2827,

index_of_refraction=1.4086

),

attributes=HairAttributes(

age_group_match=[Age.OLD, Age.YOUNG, Age.ADULT],

ethnicity_match=[

Ethnicity.SOUTHEAST_ASIAN,

Ethnicity.SOUTH_ASIAN,

Ethnicity.EAST_ASIAN,

Ethnicity.HISPANIC,

Ethnicity.NORTH_EUROPEAN

],

gender_match=[Gender.FEMALE],

length=HairLength.UNDEFINED,

style=[HairStyle.PONYTAIL, HairStyle.PULLED_BACK]

)

),

eyebrows=Hair(

id=’7b14ee11-4128-411e-8213-9402ec6a189d’,

color_settings=HairColor(

melanin=0.0948,

redness=0.9907,

whiteness=0.0679,

roughness=0.2827,

index_of_refraction=1.4086

),

attributes=EyebrowsAttributes(gender_match=[Gender.FEMALE])

),

facial_hair=None,

location=Point(x=0.0, y=0.0, z=0.0),

rotation=Rotation(yaw=0.0, roll=0.0, pitch=0.0),

expression=Expression(name=ExpressionName.NEUTRAL, intensity=1.0)

),

attributes=HumanAttributes(

age=Age.YOUNG,

ethnicity=Ethnicity.MEDITERRANEAN,

gender=Gender.FEMALE

)

)

To cap the number of returned human assets using the limit parameter:

from datagen.api import catalog

catalog.humans.get(limit=4)

<AssetInstancesList(4)>

To get a single human asset using the limit parameter:

from datagen.api import catalog

catalog.humans.get(limit=1)

Human(

id=’00005401-8dc0-4d6c-9cf1-743f9b70beea’,

head=Head(

eyes=Eyes(

id=’a5a54dc7-53c3-41c4-bf39-ced2b794dd50’,

target_of_gaze=Gaze(distance=15.0, direction=Vector(x=0.0, y=-1.0, z=0.0)),

eyelid_closure=0.0,

attributes=EyesAttributes(color=EyesColor.BROWN)

),

hair=Hair(

id=’51cfc652-f90b-4850-aa5a-0128a07f0f89’,

color_settings=HairColor(

melanin=0.2899,

redness=0.3085,

whiteness=0.6258,

roughness=0.357,

index_of_refraction=1.4584

),

attributes=HairAttributes(

age_group_match=[Age.OLD, Age.ADULT],

ethnicity_match=[Ethnicity.HISPANIC, Ethnicity.SOUTH_ASIAN, Ethnicity.NORTH_EUROPEAN],

gender_match=[Gender.FEMALE],

length=HairLength.SHOULDER,

style=[HairStyle.CURTAIN, HairStyle.HAIR_DOWN, HairStyle.BOB]

)

),

eyebrows=Hair(

id=’880f57e4-bdc6-406e-bf9d-f76c633cbba2’,

color_settings=HairColor(

melanin=0.2899,

redness=0.3085,

whiteness=0.6258,

roughness=0.357,

index_of_refraction=1.4584

),

attributes=EyebrowsAttributes(gender_match=[Gender.FEMALE])

),

facial_hair=None,

location=Point(x=0.0, y=0.0, z=0.0),

rotation=Rotation(yaw=0.0, roll=0.0, pitch=0.0),

expression=Expression(name=ExpressionName.NEUTRAL, intensity=1.0)

),

attributes=HumanAttributes(age=Age.OLD, ethnicity=Ethnicity.NORTH_EUROPEAN, gender=Gender.FEMALE)

)

To filter the human objects using the attributes parameter (see below for the list of valid human attributes):

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

catalog.humans.get(gender=attributes.Gender.MALE, ethnicity=attributes.Ethnicity.MEDITERRANEAN)

<AssetInstancesList(3331)>

count()#

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

To count the full set of human assets:

from datagen.api import catalog

catalog.humans.count()

52151

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

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

catalog.humans.count(age=attributes.Age.YOUNG, ethnicity=attributes.Ethnicity.AFRICAN)

853

Human attributes#

The datagen.api.catalog.attributes.HumanAttributes class defines which attributes can be used to filter the catalog of human assets:

class datagen.api.catalog.attributes.HumanAttributes(age: Enum, ethnicity: Enum, gender: Enum)

Each human asset contains the following read-only attributes.

When you call the datagen.api.catalog.humans.get() or datagen.api.catalog.humans.count() functions, you can use these attributes to filter the catalog.

age: Enum

The age category of the human asset. Uses the Age enum.

ethnicity: Enum

The ethnicity of the human asset. Uses the Ethnicity enum.

gender: Enum

The gender of the human asset. Uses the Gender enum.

Sample usage:

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

catalog.humans.get(age=attributes.Age.ADULT,ethnicity=attributes.Ethnicity.SOUTH_ASIAN,gender=attributes.Gender.FEMALE)

<AssetInstancesList(189)>

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

class datagen.api.catalog.attributes.Age(value)

The list of available genders.

This enum is valid for use in the following attributes:

Values:

ADULT = 'adult'

Approximate age range: 31-50

OLD = 'old'

Approximate age range: 51+

YOUNG = 'young'

Approximate age range: 18-30

class datagen.api.catalog.attributes.Ethnicity(value)

The list of available ethnicities.

This enum is valid for use in the following attributes:

AFRICAN = 'african'
EAST_ASIAN = 'east_asian'
HISPANIC = 'hispanic'
MEDITERRANEAN = 'mediterranean'
NORTH_EUROPEAN = 'north_european'
SOUTHEAST_ASIAN = 'southeast_asian'
SOUTH_ASIAN = 'south_asian'
class datagen.api.catalog.attributes.Gender(value)

The list of available genders.

This enum is valid for use in the following attributes:

Values:

FEMALE = 'female'
MALE = 'male'

Properties of human objects#

When you get a human object from the catalog, you can edit that human object in certain ways. These are the editable properties of human objects:

id

string

The UUID of the actor in the scene.

This property selects one of Datagen’s thousands of available identities to be the actor at the (metaphorical) center of your scene. The value of this property defines the skin tone, skin textures, and body shape of the generated human subject. It also includes default values for the hair, eyes, eyebrows, and other aspects of human identity that can be easily altered.

Tip

To download a CSV with a complete list of available identities, click here

The actors in our catalogue are grouped…

By gender

Females

To download a CSV with a complete list of available female identities, click here

Males

To download a CSV with a complete list of available male identities, click here

By age group

Younger (ages 18-30)

To download a CSV with a complete list of available identities ages 18-30, click here

Adult (ages 31-50)

To download a CSV with a complete list of available identities ages 31-50, click here

Older (ages 51+)

To download a CSV with a complete list of available identities ages 51+, click here

By ethnicity

Africans

To download a CSV with a complete list of available African identities, click here

Hispanics

To download a CSV with a complete list of available Hispanic identities, click here

Mediterraneans

To download a CSV with a complete list of available Mediterranean identities, click here

North Europeans

To download a CSV with a complete list of available North European identities, click here

South Asians

To download a CSV with a complete list of available South Asian identities, click here

Southeast Asians

To download a CSV with a complete list of available Southeast Asian identities, click here

head

The head object defines aspects of the human’s appearance that relate to the head. It contains the following objects:

eyes

An eyes asset from the asset catalog. Each human identity comes with default eyes, which you can edit or replace.

This code takes a human from the catalog and changes the default eyes:

from datagen.api import catalog

human=catalog.human.get(limit=1)
human.head.eyes=catalog.eyes.get(limit=1)

See eyes for more.

hair

A hair asset from the asset catalog. Each human identity comes with default hair, which you can edit, remove, or replace.

This code takes a human from the catalog and changes the default hair:

from datagen.api import catalog

human=catalog.human.get(limit=1)
human.head.hair=catalog.hair.get(limit=1)

See hair.

eyebrows

An eyebrows asset from the asset catalog. Each human identity comes with default eyebrows, which you can edit, remove, or replace.

This code takes a human from the catalog and changes the default eyebrows:

from datagen.api import catalog

human=catalog.human.get(limit=1)
human.head.eyebrows=catalog.eyebrows.get(limit=1)

See eyebrows.

facial_hair

A facial_hair asset from the asset catalog. Each human identity comes with default facial hair (in many cases this default is “none”). You can add, remove, or change this default.

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

from datagen.api import catalog

human=catalog.human.get(limit=1)
human.head.facial_hair=catalog.beards.get(limit=1)

See facial_hair.

location

The location object defines where the actor’s head - specifically, a point at the front of the neck - is located in the scene.

Location is defined using x, y, and z global coordinates, measured in meters. Each value is a floating-point variable that can range from -5 to 5 meters.

Important

The location of the actor is the most critical setting in your data request. If the actor is in the wrong place, they might not be in the camera frame and you will render nothing but the background.

Tip

Use this visualization tool to experiment with positioning the actor’s head in the frame.

This code takes a human from the catalog and changes the default head location:

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

human=catalog.humans.get(limit=1)
human.head.location=assets.Point(x=0.8, y=-0.04, z=0.3)

For an in-depth look at these axes, as well as which part of the head is actually placed at the coordinates you set, see About our coordinate systems.

rotation

The rotation object defines how the actor’s head will be rotated about the neck, while the neck remains upright. When we generate your datapoint, the coordinates of the neck are set first using the location setting; afterwards, we rotate the head about the neck using pitch, yaw, and roll settings that you define here.

The pitch, yaw, and roll properties are floating-point values measured in degrees. Pitch can range from -90 to 90, while yaw and roll can range from -45 to 45.

Tip

Use this visualization tool to experiment with rotating the actor’s head in the scene. Note that the visualizer rotates the head and neck together; when you create your datapoints, the neck will be held still while the head is tilted around it in a realistic fashion.

This code takes a human from the catalog and changes the default head rotation:

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

human=catalog.humans.get(limit=1)
human.head.rotation=assets.HeadRotation(yaw=23.5, roll=25.8, pitch=36.4)

expression

The expression object defines the type and the intensity of your actor’s facial expression. The expression type is defined using an Enum, while the intensity is a float that ranges from 0 (neutral expression) to 1 (maximum intensity).

Examples of expressions:#
../../_images/expression_surprise_51.png

Surprise (intensity 1)#

../../_images/expression_disgust_41.png

Disgust (intensity 0.75)#

../../_images/expression_happiness_41.png

Happiness (intensity 0.75)#

../../_images/expression_anger_51.png

Anger (intensity 1)#

../../_images/expression_neutral1.png

Neutral expression#

../../_images/expression_fear_41.png

Fear (intensity 0.75)#

../../_images/expression_mouth_open_21.png

Mouth open (intensity 0.25)#

../../_images/expression_sadness_31.png

Sadness (intensity 0.5)#

../../_images/expression_contempt_21.png

Contempt (intensity 0.25)#

This code takes a human from the catalog and changes the default expression:

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

human=catalog.humans.get(limit=1)
human.head.expression=assets.Expression(name=assets.ExpressionName.HAPPINESS,intensity=0.65)