Package: datagen-tech
The Datagen SDK Python PackageAbout DatagenDatagen is powering the AI revolution by providing high-performance synthetic data, with a focus on data for human-centric computer vision applications.Datagen provides a powerful platform that allows you to generate high-quality and high variance, domain-specific, simulated synthetic data, granting you the ability to simulate dynamic humans and objects in their context. With Datagen, CV engineers have unparalleled flexibility to control visual outcomes across a broad spectrum of 3D environments.About this packageDatagen has developed a set of Python-based user tools for accessing and loading the rendered images and metadata that you generate on our platform. This package is designed to load our synthetic data into your Python environment, whether as part of your training set or as part of your testing set.The abstraction layer we designed gives you access to all of the modalities we offer: facial landmarks, eye gaze vectors, depth and normal maps, and more.InstallationBefore installing this package, we recommend that you create a new Conda environment using the following command:conda create --name datagen-envNext, activate the environment using this command:conda activate datagen-envFinally, use this command to install the Datagen package itself:pip install datagen-techUsing This PackageThis package contains Python objects and functions that are designed to process datasets generated with the Datagen Platform. If you are a Datagen customer, you have already been given access to sample datasets and jupyter notebook tutorials. If you are not a Datagen customer, contact our support team atsupport@datagen.tech.Importing the SDKTo import the sdk, use the commandimport datagenor, if you prefer,import datagen as dg. For the rest of this tutorial we will use the latter.DatasetsA "dataset" is any collection of datapoints that were generated on the Datgen platform. Each datapoint is a single visual spectrum image accompanied by visual and textual metadata.Loading a datasetThedg.load()command stores one or more datasets into aDatasetobject. It can accept any number of target folders at once, merging them into one large dataset so you can conduct operations on all of them together.This command is fully backwards-compatible. If you use the platform's newest features in your dataset, you can still load that dataset together with older datasets that predate those features.When using this command, you should target the top-level folder of each dataset (the folder that contains one or more subfolders named "scene").  For example:dataset = dg.load("/path/to/datagen/datasets/eye-gaze-forward", "/path/to/datagen/datasets/expression-smiles")The above line of sample code loads a dataset found in a folder named "eye-gaze-forward" as well as a dataset found in a folder named "expression-smiles", merging their datapoints into a single dataset.Working with your datasetYou can iterate over your dataset in three different ways: by scene, by camera, or by datapoint.ScenesWhat is a scene?A "scene" refers to a 3D environment that contains one or more 3D objects. For example, each scene that is created in our Faces generator consists of a single human face, wearing a specific expression, and located in a static position.When generating a dataset on our Faces platform, you have the option of rendering each scene in multiple ways: through more than one camera, each with different settings; and under more than one lighting scenario, each with different backgrounds. Therefore, depending on the settings you used when you generated this dataset, each scene can be depicted in anywhere between one and over 30 rendered images.TheSceneobjectEach dataset contains an iterable set ofSceneobjects. To retrieve this set, usedataset.scenes. To refer to an individual scene in a dataset, usedataset.scenes[0].TheSceneobject contains a set of rendered images that all depict the same subject, but from different angles and under different lighting scenarios. Each of these images, along with its metadata, is called a "datapoint". You can access a scene's datapoints by subscription:scene = dataset.scenes[0]
datapoint = scene[0]Or by iterating over the scene:for datapoint in scene:
    ...Note:In older datasets generated by our platform, scenes were previously named "environments". The package supports both formats.CamerasWhat is a camera?A "camera" refers to a set of rendered images that were taken of a specific scene, from a specific angle, under specific camera settings - but each one shows the scene under a different lighting scenario. When you generated this dataset, you selected one or more lighting scenarios; that selection determines the number of rendered images per camera.TheCameraobjectEach scene contains an iterable list ofCameraobjects. To retrieve this set, use scenescene.cameras. To refer to an individual camera in a scene, usescene.cameras[0].TheCameraobject contains a set of rendered images that all depict the same subject from the same angle, but under different lighting scenarios. Each of these images, along with its metadata, is called a "datapoint". You can access a camera's datapoints by subscription:scene = dataset.scenes[0]
camera = scene.cameras[0]
datapoint = camera[0]Or by iterating over the camera:for datapoint in camera:
    ...DatapointsWhat is a datapoint?A "datapoint" refers to a single rendered image of a synthetic human subject, along with all of its metadata. That metadata includes all of Datagen's modalities: normal and depth maps, facial landmark coordinates, camera and actor metadata, and more.TheDatapointobjectADatapointobject consists of a visual spectrum image annotated by additional visual and textual data files:The visual spectrum image depicts the scene from the point of view of a specific camera under a specific lighting scenario.The annotations contain metadata that is specific to that image.For example, eachDatapointobject contains 2D coordinates for facial landmarks, identifying where those landmark can be found in the visual spectrum image.You can use tab autocompletion to view the full list of available objects in theDatapointobject. For example, you can use the following command to access the visual spectrum image of the subject:imshow(datapoint.visible_spectrum)And this one to access a normal map of the subject:imshow(datapoint.normals_map)Textual annotations are organized in a hierarchy.datapoint.actor_metadata.face_expressiongives you the description of the subject's facial expression, whiledatapoint.semantic_segmentation_metadata.nosegives you the RGB value that represents the nose in the accompanying semantic segmentation map.