Generate synthetic, augmented training datasets from Blender scenes.
Blendmentation is our open source Python library for computer vision datasets. You describe your dataset as composed steps, in the style of torchvision and albumentations: randomize the scene, render it with automatic annotations, restore it, and repeat. When it is done, export the labels to COCO, YOLO or Pascal VOC.
Every datapoint goes through the same four steps, written as plain Python in your Blender scene.
Randomize objects, materials, the camera and any other value in the scene.
Render the image, passes, AOVs and masks, and write a JSON label for it.
Put the scene back as it was, ready for the next datapoint.
Convert the finished dataset to COCO, YOLO or Pascal VOC.
bpy module
Chain augmentations with Compose, and give any of them, or a whole chain, a probability
p so it only runs part of the time.
Random translation, rotation and scale on any axis, applied to every object in a list.
Orbit the camera around targets by distance, elevation and azimuth, change the focal length while keeping the subject the same size, and add depth of field.
Randomize a material's hue, saturation, roughness and other values for color and surface variety.
Randomize any property by its data path: light energy and color, light type, shadows, modifier settings and anything else Blender exposes.
Combine all of them in one Compose and every datapoint is a new mix of object poses, camera views,
materials and scene settings.
Pick what to save for every datapoint. Annotations come straight from the scene, so they always match the image. You can also save a preview copy of every image with its boxes or masks drawn on top, to check the labels at a glance.
The rendered image, render passes such as depth and normals, and shader AOVs, with Cycles or EEVEE.
A 2D box for every instance of every class, computed from the geometry with modifiers included.
Masks per class, per instance, or both.
Every image gets a JSON label, and almost anything in the scene can go into it: rotation matrices of objects relative to the camera, camera intrinsics and extrinsics (with OpenCV axes), focal length and depth of field settings, and 3D keypoints projected to the image with their visibility. Any other Blender value can be saved too, by its data path, such as light energy, a material color or a modifier setting.
Datapoints can optionally be checked for faulty ones and skipped before rendering: when class instances overlap each other too much, when too large a part of an instance is out of frame, or when too much of it is hidden behind other objects. The limits can be set for all classes or for each one.
Blendmentation runs in Blender's bundled Python and needs nothing else. It can also run as a Python module
with bpy, without the Blender app.
# 1. augment
objects_aug = augmentations.Compose([
augmentations.Translation(x=0.5, y=0.5),
augmentations.Rotation(z=180),
augmentations.Material("CarPaint", hue=(0, 1)),
])
# 2. what to save for every datapoint
generator = generating.Compose([
generating.Render(),
generating.BBox(classes),
generating.Segmentation(classes),
], path="//dataset")
# 3. the scene state to go back to
initial = state.State(cars, fields=objects_aug.augmentations)
for _ in range(1000):
objects_aug(cars)
generator()
initial.restore()
# 4. training-ready annotations
export.coco("//dataset")
Blendmentation is made by CSMX. We also build synthetic datasets as a service, from 3D models made from CAD files or photos to thousands of annotated images ready for training.