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, Pascal VOC or BOP.
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.
Everything the augmentations changed is set back automatically, ready for the next datapoint.
Convert the finished dataset to COCO, YOLO, Pascal VOC or BOP.
bpy module
Chain augmentations with Compose, let OneOf pick one of them at random by weight,
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, move it to a random point on a camera path, change the focal length while keeping the subject the same or a random size, and add depth of field with a random focus offset.
Randomize a material's hue, saturation, roughness and other values for color and surface variety, give an object one of the materials in its slots, or render it with another of its UV maps.
Randomize any property by its data path: light energy and color, light type, shadows, modifier settings and anything else Blender exposes. Build the variation with shader and Geometry Nodes, and Blendmentation changes their values and seeds, one input at a time or many inputs of a node group or modifier at once.
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, and full masks of every instance with its hidden parts included.
Every image gets a JSON label, and almost anything in the scene can go into it: 6D poses and 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.SimpleMaterial("CarPaint", hue=(0, 1)),
])
# 2. what to save for every datapoint
generator = generating.Compose([
generating.Render(),
generating.BBox(classes),
generating.Segmentation(classes),
], path="//dataset")
for _ in range(1000):
# 3. everything changed inside is set back afterwards
with state.restoring():
objects_aug(cars)
generator()
# 4. training-ready annotations
export.coco("//dataset")
Two pages show what your augmentations do: a preview before you generate, and a report of what the dataset got after it. Both are single HTML files that open in any browser, without internet.
See your augmentations as a flowchart before a long run: every step in order,
every OneOf fork with its weights, and how often each augmentation should run and set each
value. A wrong probability or a forgotten branch shows up before a single image is rendered.
Every label records what each augmentation did for each object. The report compares the finished dataset with the graph: how often each augmentation ran and how often it set each value, expected against observed, with differences larger than chance marked. Skipped datapoints are counted by reason and class, and a skips bar on each card shows which augmentations cause them. Here, a lying carton is cut by the frame more often than a standing one.
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.
Datapoints from the examples in the quick start guide, each made from a short script.
Check them out at: