Skip to content

Generating

Save a datapoint per call: the render, passes, AOVs, masks, preview images and a JSON label, <index>.json.

The steps can be listed in any order; they always run as: label steps (BBox, Pose, OutputField, CameraData, Keypoints, Augmentations), so a datapoint skipped by BBox (max_iou, max_truncation, max_occlusion) is never rendered, then Background, then Render, then AOVs, Passes and BBoxImage, then Segmentation, then SegmentationImage. All steps share one render, except that Segmentation with EEVEE or Workbench adds a flat Workbench render, reusing the one of BBox(max_occlusion=...) when both have the same classes, and Segmentation(full_masks=True) adds the renders of the masks that ignore occlusion. Pose saves the 6D pose of every instance, and with full masks, CameraData and the Depth pass, export.bop writes a BOP dataset. Background puts a random color, noise or image behind the render and the preview images. Augmentations records what the augmentations did in every label and saves their graph, with the probability of each outcome, next to the dataset. A prefix on Compose starts every file name with it, so several runs can share one folder. Every label JSON starts with "version", the Blendmentation version that wrote it.

BBox and Segmentation take classes as {class name: [instances]}, where an instance is an object, or a sublist of objects labeled as one: {"car": [car_1, car_2], "table": [[table_top, table_legs]]}. A class can also be a dict with its own BBox skip settings, {"instances": [...], "max_truncation": 0.5}, which win over the BBox arguments; Segmentation ignores them, so both steps can share one classes dict. Instances(parent, of=...) in a class labels the instances that geometry nodes (or collection instancing) make on parent, one per instance.

Compose

Compose(
    steps: Sequence[Step],
    path: str,
    resolution: tuple[int, int],
    *,
    prefix: str = "",
)

Generates one datapoint per call from a list of steps.

Every call saves <index>.png, <index>.json with the labels, and the files of the other steps to path. The index is the next free number in the folder, so generating can be stopped and resumed. The settings of every step are checked before anything renders, and the scene's resolution and output settings are restored afterwards.

With a prefix, every file starts with it: run1_000012.png, run1_000012.json, run1_000012_mask_car_0.png, and the Augmentations files run1_augmentations.json and run1_skipped.jsonl. The index counts only the files with the same prefix, so runs with different prefixes (other machines, scenes or settings) can write to one folder, or be copied into one later, without overwriting each other. The exports read every prefix and number the images in order; export.augmentation_stats, export.skip_stats and export.augmentation_report take the prefix of one run.

Parameters:

  • steps (Sequence[Step]) –

    generating steps, in any order.

  • path (str) –

    folder to save the files to. // paths are relative to the .blend file, and "" is its folder.

  • resolution (tuple[int, int]) –

    (width, height) of the images in pixels.

  • prefix (str, default: '' ) –

    start of every file name, e.g. "run1_". It can't contain a path separator or end with a digit, which would run into the index.

Raises:

  • TypeError –

    an item of steps is not a generating step, or prefix is not a string.

  • ValueError –

    a BBoxImage without a BBox step, or a SegmentationImage without a Segmentation step, or a prefix with a path separator or a digit at its end.

Example
classes = {"car": [car_1, car_2], "table": [[table_top, table_legs]]}
generator = generating.Compose(
    [generating.Render(), generating.BBox(classes), generating.Segmentation(classes)],
    path="//dataset",
    resolution=(640, 480),
    prefix="run1_",   # run1_000000.png, run1_000000.json, ...
)
generator()

preview

preview(
    factor: float, *, extra: Optional[dict[str, Any]] = None
) -> bool

Generates one datapoint at a reduced resolution, for a quick look.

Parameters:

  • factor (float) –

    the resolution is divided by this factor.

  • extra (Optional[dict[str, Any]], default: None ) –

    extra keys and values to save in the label (not "version", which is always the Blendmentation version).

Returns:

  • bool –

    False if the datapoint was skipped, otherwise True.

Instances

Instances(
    parent: Object,
    of: Union[
        Object, Sequence[Object], Collection, None
    ] = None,
)

The instances that an object's geometry nodes make, as instances of a class.

Put it in a class's list in classes (BBox, Pose, Segmentation), next to objects: every top-level instance of parent that has an object of of becomes one instance of the class. With Collection Info, Separate Children decides what one instance is: on (with Pick Instance on Instance on Points), every point gets one object of the collection, and each is its own instance; off, every point gets the whole collection, which is one instance with all its objects (a car body and its wheels). The instances are read after the augmentations, so their number can change from datapoint to datapoint. They don't need Realize Instances, and realized instances are not found: they are part of the parent's mesh.

In the labels, the objects of an instance are named <parent>/<instance path>/<object>, e.g. "Scatter/3/car", where the path is the index of the top-level instance, followed by the indices inside it for nested instances ("Scatter/3.0.1/wheel").

Parameters:

  • parent (Object) –

    the object with the geometry nodes modifier. The instances are in the render when it is.

  • of (Union[Object, Sequence[Object], Collection, None], default: None ) –

    the objects to label the instances of: an object, a list of objects or a collection (its objects, nested collections included). None labels all instances of parent.

Note

of finds the instances of an object by the object, or, when the instance is a copy of its mesh, by the mesh: Object Info without As Instance copies it, and so do nodes after Instance on Points that change the instanced meshes (Smooth by Angle, Set Shade Smooth). A mesh made in geometry nodes (a Cube node) belongs to no object; label it with of=None. When none of the instances is of of and some are such meshes, generating raises. Masks (Segmentation) and BBox(max_occlusion=...) of instances need a Cycles id render with a material override, whatever the engine: a temporary geometry nodes modifier on parent stores the id of every instance, and an emission material shows it (both removed afterwards). The override has no shader displacement and alpha, so alpha-clipped parts count. Collection instancing on an Empty works for boxes and poses, but not in masks, which need geometry nodes.

Example
classes = {
    "car": [generating.Instances(scatter, of=car)],     # every car scattered on the ground
    "rock": [generating.Instances(scatter, of=rocks)],  # rocks: a collection
    "house": [house],                                  # objects still work
}
generating.BBox(classes)

BBox

BBox(
    classes: Classes,
    *,
    max_iou: Optional[float] = None,
    max_truncation: Optional[float] = None,
    max_occlusion: Optional[float] = None,
    allow_empty: bool = False,
)

Adds the 2D bounding box of every instance to the label.

Boxes are in pixels as [x_min, y_min, x_max, y_max] from the top-left corner, computed from the evaluated geometry (modifiers included). Occlusion is not taken into account, so hidden parts are inside the box (amodal). For boxes of only the visible pixels, add Segmentation and export with bbox_from="mask" (export.coco, export.yolo, export.voc). An instance out of frame gets None. Objects hidden in the render (e.g. by Visibility, or in a collection excluded from the view layer or disabled in renders) are left out of the box, and an instance with all its objects hidden gets None and never skips the datapoint, as does one with no geometry (e.g. an object whose geometry nodes output only instances: label those with Instances).

In the label JSON: "bboxes": [{"class", "objects", "bbox"}].

Parameters:

  • classes (Classes) –

    {class name: [instances]}, an instance is an object or a sublist of objects labeled as one (its box is the union of the members), and Instances(parent, of=...) adds every geometry nodes instance. A class can instead be {"instances": [instances], "max_iou": ..., "max_truncation": ..., "max_occlusion": ...} to set its own skip settings (all keys but instances optional).

  • max_iou (Optional[float], default: None ) –

    skip the datapoint, before rendering, when any two boxes overlap more than this IoU. None = never skip.

  • max_truncation (Optional[float], default: None ) –

    skip the datapoint, before rendering, when more than this fraction (0-1) of any instance's box is out of frame, measured on its unclipped box. An instance partly behind the camera or fully out of frame counts as 1, so max_truncation=0 keeps only datapoints with every instance fully in frame. None = never skip.

  • max_occlusion (Optional[float], default: None ) –

    skip the datapoint, before the beauty render, when objects in no class (clutter, distractors) cover more than this fraction (0-1) of any instance: 1 - its visible pixels / its pixels with those objects hidden. Class objects covering each other don't count (that is max_iou), and an instance with no pixels even then (out of frame, or behind another class object) counts as 0. None = never skip.

  • allow_empty (bool, default: False ) –

    max_truncation ignores instances out of view (their bbox is None), which otherwise count as 1. Datapoints with only some instances in frame, or none (negative samples), are then kept, and only the instances in frame are checked. An instance partly behind the camera is in view when its bounding box reaches the frame.

Note

The BBox arguments are the defaults for every class. A setting a class sets in its dict wins over them, even when it is None (no limit for that class). A class's max_truncation and max_occlusion apply to each of its instances. max_occlusion is measured with two flat Workbench renders, whatever the engine, which only run when some class has a limit and the cheaper checks passed; Workbench draws every object solid, so transparent and alpha-clipped objects occlude fully, shader displacement is missing, and shadows don't count. For max_iou, two boxes conflict when their IoU is over the lower of their two classes' limits, so a strict class can't overlap anything, and a pair is only free when both classes have no limit.

Example
classes = {
    "car": [car_1, car_2],                                       # uses the BBox arguments
    "table": {"instances": [[top, legs]], "max_truncation": 0.8},  # may be cut more
}
generating.BBox(classes, max_iou=0.5, max_truncation=0.3, max_occlusion=0.5)
# also keep images without some or all of them
generating.BBox(classes, max_truncation=0.3, allow_empty=True)

Pose

Pose(classes: Classes)

Adds the 6D pose of every instance relative to the camera to the label, for pose estimation.

R (3x3, row by row) and t map the instance's local coordinates to the camera's, in OpenCV axes (x right, y down, z forward), like CameraData's extrinsics_opencv: p_camera = R @ p_local + t. t is in Blender units (see unit_scale in CameraData). The object's scale is not in R; it is saved as scale, so a 3D model of the object should have it applied. An instance of several objects has the pose of its first object. An instance with all its objects hidden in the render (e.g. by Visibility) has R, t and scale None. An Instances instance has the pose its geometry nodes give it.

In the label JSON: "poses": [{"class", "objects", "R", "t", "scale"}].

Parameters:

  • classes (Classes) –

    {class name: [instances]}, the same dict as for BBox and Segmentation; skip settings in a class dict are ignored. export.bop matches poses with masks by class and objects.

Example
generating.Pose({"car": [car_1, car_2]})

OutputField

OutputField(
    name: str,
    data_path: str,
    *,
    objects: Optional[Sequence[Object]] = None,
)

Saves the value at a data path to the label.

Values are converted to JSON: datablocks become their name, menus the option name, and vectors and matrices nested lists.

In the label JSON: name: value for an absolute path, name: {object name: value} for a relative one.

Parameters:

  • name (str) –

    key in the label.

  • data_path (str) –

    path to the value. Paths starting with bpy. are absolute (right click > Copy Full Data Path) and saved once, e.g. 'bpy.data.lights["Light"].energy'. Other paths are relative to objects.

  • objects (Optional[Sequence[Object]], default: None ) –

    objects a relative path is resolved on.

Example
generating.OutputField("light_energy", 'bpy.data.lights["Light"].energy')
generating.OutputField("smile", 'data.shape_keys.key_blocks["Smile"].value', objects=[face])

Augmentations

Augmentations(
    augmentations: Any,
    *,
    graph_file: Optional[str] = "augmentations.json",
)

Records what the augmentations did in the label, and saves their graph, what they can do with which probability, next to the dataset.

Give it the augmentation Composes you call before generating. For each datapoint it reads what each augmentation did for each object of the last call, nested ones included. The graph (augmentations.Compose.describe) goes to <path>/augmentations.json, rewritten when the augmentations change, so it describes the latest ones. A datapoint BBox skips has no label: its line in <path>/skipped.jsonl (both starting with the Compose's prefix) says why and what the augmentations did, so export.augmentation_stats, export.skip_stats and export.augmentation_report show what the skips took out of the dataset.

In the label JSON: "augmentations": {id: {object name: {"applied", "value"}}}, by the ids of the graph (the root's name, then the index of each augmentation down the tree, e.g. "objects.0.1"). applied is whether it ran for that object (its p), and value what it set (its results), the otherwise value when it didn't run. A Compose lists the objects it was called with, {"applied"} each. An augmentation that didn't run for any object (a OneOf didn't pick it) is left out, and one that changes the same thing for every object (an absolute data path, Seed) has a single entry under "null", its last call.

In skipped.jsonl, one JSON object per skipped datapoint: {"version", "skip": {"reason", "class", "objects", "value", "limit"}, "augmentations": {...}}, where the reason is the BBox setting ("max_truncation", "max_iou" or "max_occlusion"), value what was measured (the truncated fraction, the IoU or the occluded fraction) and limit the setting's value; for max_iou, class and objects list the two instances.

Parameters:

  • augmentations (Any) –

    augmentation Composes: one, a list (ids "0", "1"...) or a dict {name: Compose} (ids the names).

  • graph_file (Optional[str], default: 'augmentations.json' ) –

    file name of the graph in the output folder, None to not save it.

Raises:

  • TypeError –

    an item is not an augmentations.Compose.

Example
objects_aug = augmentations.Compose([augmentations.Rotation(z=180), augmentations.Visibility(p=0.8)])
camera_aug = augmentations.Compose([augmentations.LookAt(car, distance=(5, 10))])
generator = generating.Compose([
    generating.Render(),
    generating.Augmentations({"objects": objects_aug, "camera": camera_aug}),
], path="//dataset", resolution=(640, 480))
for _ in range(100):
    with state.restoring():
        objects_aug([car, truck])
        camera_aug([camera])
        generator()
# "augmentations": {"objects.0": {"car": {"applied": true, "value": [0, 0, 41.5]}, ...}, ...}

CameraData

Adds the active camera to the label.

Saves the name, type, matrix_world, extrinsics_opencv (3x4 world-to-camera [R|t] with OpenCV axes: x right, y down, z forward), clip_start, clip_end and depth_of_field (use_dof, focus_object, focus_distance, f_stop, aperture_blades, aperture_rotation in radians and aperture_ratio), and unit_scale, the scene's meters per Blender unit (Scene Properties > Units > Unit Scale), which every distance in the labels and the Depth pass is multiplied by to get meters. focus_distance is the distance to the focal plane Blender uses, so with a focus object it is the distance to that object along the view axis. A perspective camera adds the lens, sensor size and fit and intrinsics (3x3 K in pixels, with sensor fit, lens shift and pixel aspect), an orthographic one ortho_scale. K follows OpenCV (and BOP and BlenderProc): pixel centers are at whole numbers, the top-left pixel's center is (0, 0), so a camera without shift has its principal point at ((width - 1) / 2, (height - 1) / 2). Boxes and keypoint positions are measured from the image's top-left corner instead (a pixel's center is at + 0.5), as in COCO: a keypoint at (x, y) projects through K to (x - 0.5, y - 0.5).

In the label JSON: "camera": {...}.

Example
generating.CameraData()

Keypoints

Keypoints(points: dict[str, KeypointSource])

Projects 3D points to the image and adds them to the label.

Vertices include deformations from armatures and modifiers. A point is visible when it is in frame and a ray cast from the camera reaches it. Objects hidden in the render don't block the ray, and a point on one of them is not visible. Geometry nodes instances block it, even when the object they instance is not in the render.

In the label JSON: "keypoints": [{"name", "position", "depth", "in_frame", "visible"}], with position in pixels from the top-left corner and depth along the view axis.

Parameters:

  • points (dict[str, KeypointSource]) –

    {name: source}, where a source is an object (its origin), (mesh object, vertex index), (mesh object, "vertex group") for the center of the group, (armature, "bone") for the bone head, or a point (x, y, z).

Example
generating.Keypoints({"car_origin": car_1, "car_corner": (car_1, 0), "hand": (rig, "hand.L")})

Background

Background(
    weights: Optional[
        dict[
            Literal[
                "color",
                "white_noise",
                "color_noise",
                "image",
            ],
            float,
        ]
    ] = None,
    *,
    noise_size: tuple[float, float] = (1, 8),
    images_path: Optional[str] = None,
)

Puts a random background behind the transparent render, in the image of Render and in the preview images (BBoxImage, SegmentationImage).

Each datapoint picks one mode by the weights:

  • "color": one random uniform color.
  • "white_noise": random gray square cells.
  • "color_noise": random colored square cells.
  • "image": a random image from images_path (and its subfolders; PNG, JPEG, BMP, TIFF or TGA), scaled to cover the frame and cropped at a random position.

The output color must be RGBA. The background is composited over the render's alpha, so it shows where the render is transparent (Render Properties > Film > Transparent, or alpha from the compositor) and an opaque render hides it: a pipeline can switch transparency per datapoint. The labels (masks, boxes), AOVs and passes don't change. The image is then saved opaque as RGB: 8-bit for PNG and JPEG, 32-bit float for EXR (the background converted from sRGB to linear). The backgrounds come from Python's random, so random.seed() makes them reproducible.

In the label JSON: "background": {"mode", ...} with "color": [r, g, b] (0-255), "noise_size" (pixels) or "image" (path relative to images_path).

Parameters:

  • weights (Optional[dict[Literal['color', 'white_noise', 'color_noise', 'image'], float]], default: None ) –

    {mode: weight}, the relative probability of each mode. A mode with weight 0 or left out is never used. None = equal weights for all modes, the image mode only with images_path.

  • noise_size (tuple[float, float], default: (1, 8) ) –

    (min, max) size of the noise cells in pixels, sampled per datapoint; 1 is per-pixel noise.

  • images_path (Optional[str], default: None ) –

    folder of background images, only needed when "image" has a weight above 0 (or weights is None and you want images). Without images, leave it None and give "image" weight 0 or leave it out. // paths are relative to the .blend file.

Raises:

  • ValueError –

    when generating, if the output color isn't RGBA, a weight or noise_size is invalid, or the image mode has no images.

Example
generating.Background(
    weights={"color": 1, "white_noise": 1, "color_noise": 1, "image": 3},
    noise_size=(1, 8),
    images_path="//backgrounds",
)
# no images: image weight 0 (or left out), no images_path needed
generating.Background(weights={"color": 1, "color_noise": 2, "image": 0})

Render

Render(
    file_format: Literal["PNG", "JPEG", "OPEN_EXR"] = "PNG",
)

Renders the image with the scene's engine to <index>.<ext>.

In the label JSON: "image": file name.

Parameters:

  • file_format (Literal['PNG', 'JPEG', 'OPEN_EXR'], default: 'PNG' ) –

    "PNG", "JPEG" or "OPEN_EXR".

Example
generating.Render("JPEG")

AOVs

AOVs(
    names: Sequence[str],
    *,
    file_format: Literal["OPEN_EXR", "PNG"] = "OPEN_EXR",
    skip_empty: bool = False,
)

Saves shader AOVs as images <index>_<aov>.<ext>.

Uses the same render as Render; without Render, the scene is still rendered once, but no image is saved. Each AOV must be added in View Layer Properties > Passes > Shader AOV, and the engine must be Cycles or EEVEE.

In the label JSON: "aovs": {name: file name}, None for an AOV skipped by skip_empty.

Parameters:

  • names (Sequence[str]) –

    names of the AOVs.

  • file_format (Literal['OPEN_EXR', 'PNG'], default: 'OPEN_EXR' ) –

    "OPEN_EXR" (32-bit float) or "PNG" (8-bit, clamped to 0-1).

  • skip_empty (bool, default: False ) –

    don't write an AOV that is empty, every pixel 0 (black) in the render, alpha ignored; its file name in the label is None. The datapoint is still generated.

Example
generating.AOVs(["Albedo"])

Passes

Passes(
    names: Sequence[str],
    *,
    file_format: Literal["OPEN_EXR", "PNG"] = "OPEN_EXR",
    skip_empty: bool = False,
)

Saves built-in render passes as images <index>_<pass>.<ext>.

Uses the same render as Render and AOVs. Each pass is enabled in the view layer for that render only. Cycles has all passes, EEVEE no UV or index passes, and Workbench only Depth; in Cycles, Vector also needs motion blur off. With a Segmentation step in Cycles, ObjectIndex holds its instance ids (1, 2, ...) and 0 for other objects, instead of the objects' pass indices.

In the label JSON: "passes": {name: file name}, None for a pass skipped by skip_empty.

Parameters:

  • names (Sequence[str]) –

    any of "Depth", "Mist", "Normal", "Position", "Vector", "UV", "ObjectIndex" and "MaterialIndex".

  • file_format (Literal['OPEN_EXR', 'PNG'], default: 'OPEN_EXR' ) –

    "OPEN_EXR" (32-bit float) or "PNG" (8-bit, clamped to 0-1, so only useful for some passes like Normal).

  • skip_empty (bool, default: False ) –

    don't write a pass that is empty, every pixel 0 (black) in the render, alpha ignored; its file name in the label is None. The datapoint is still generated. Depth is never empty, its background is far away.

Example
generating.Passes(["Depth", "Normal"])

BBoxImage

BBoxImage(
    file_format: Literal["PNG", "JPEG"] = "PNG",
    *,
    line_width: int = 2,
    show_class: bool = True,
)

Saves a copy of the rendered image with the boxes of the BBox step drawn on it, to <index>_bboxes.<ext>, for checking the labels.

Uses the same render as Render, and the main image stays clean. Each class has its own color, and its name is written above each box in capitals. Needs a BBox step in the same Compose.

In the label JSON: "bbox_image": file name.

Parameters:

  • file_format (Literal['PNG', 'JPEG'], default: 'PNG' ) –

    "PNG" or "JPEG".

  • line_width (int, default: 2 ) –

    outline width in pixels, at least 1.

  • show_class (bool, default: True ) –

    write the class name above each box.

Example
generating.BBoxImage(line_width=3)

Segmentation

Segmentation(
    classes: Classes,
    *,
    per: Literal["instance", "class", "both"] = "instance",
    skip_empty: bool = False,
    full_masks: bool = False,
)

Saves black-and-white masks of the visible pixels of every instance or class.

Objects that are not in classes still hide what is behind them. Files are <index>_mask_<class>_<n>.png per instance, e.g. 000012_mask_car_3.png, where n counts instances across all classes (and across Segmentation steps of the same Compose), and <index>_class_<class>.png per class. Characters not allowed in file names become _, and _2, _3, ... is added when a name is already taken (two class names that differ only in such characters, or the same class in two steps). Masks are not anti-aliased.

With full_masks=True, every instance also gets a full mask <index>_mask_<class>_<n>_full.png: its whole silhouette, as if no other object were in the scene (BOP's mask, next to the visible mask_visib). They need extra renders with every other object hidden; instances whose boxes don't overlap share one, so a scene of separate objects needs one.

How the masks are made depends on the render engine:

  • Cycles: from the Object Index pass of the beauty render, so they match it and cost no extra render. Each instance gets its number as pass index for that render (restored afterwards). A surface counts when its alpha is at least the view layer's Alpha Threshold (Passes > Data, default 0.5), so alpha-clipped materials (leaf cards, decals, fences) and shader displacement are right. Volumes are not in the pass, so they neither get a mask nor hide anything. With depth of field or motion blur on, the masks come from one extra 1 sample Cycles render without them instead (see the note on blur below).
  • EEVEE and Workbench: one extra, fast Workbench render, which draws every object solid: alpha-clipped and transparent parts are in the mask and hide what is behind them, and shader displacement is missing. EEVEE has no Object Index pass.
  • Classes with Instances: one Cycles render with a material override, whatever the engine, since instances share their object's index and color: every instance's number is written as an instance attribute by a temporary geometry nodes modifier and shown by an emission material. Like Workbench, it has no alpha and no shader displacement.

In the label JSON: "masks": [{"class", "objects", "mask", "per"}], with per "instance" or "class", and mask None for a mask skipped by skip_empty; with full_masks, also "full_masks": [{"class", "objects", "mask"}].

Parameters:

  • classes (Classes) –

    {class name: [instances]}, an instance is an object or a sublist of objects labeled as one (one mask), or an Instances. A class given as a dict with "instances" (see BBox) works too; its skip settings are ignored here.

  • per (Literal['instance', 'class', 'both'], default: 'instance' ) –

    "instance", "class" or "both".

  • skip_empty (bool, default: False ) –

    don't write empty masks (an instance or class with no visible pixel: out of frame or fully hidden); its mask in the label is None. The datapoint is still generated, and export skips these instances like empty masks. Applies to the full masks too.

  • full_masks (bool, default: False ) –

    also save the full mask of every instance, ignoring occlusion.

Note

Masks are sharp, also when the image is blurred by depth of field (the camera's Depth of Field, e.g. from augmentations.DepthOfField) or motion blur (Render Properties > Motion Blur): they show each object where it is at the frame, with the outline it has in focus, like the boxes of BBox, the poses and the keypoints. Most datasets label it that way (COCO, BOP), and the box of a blurred object's mask (bbox_from="mask" in the export) then fits the object, not the blur. In Cycles the Object Index pass keeps one sample per pixel, at a random point of the lens or of the shutter, which would give speckled masks as wide as the blur; so with blur, Blendmentation renders the masks again without it (depth of field and motion blur off for that render only). The image keeps its blur.

In Cycles, a second Segmentation with other classes in the same Compose, or more than 32767 instances, uses the Workbench render. The full masks are rendered like the visible ones: in Cycles from the Object Index pass of a 1 sample render, otherwise with Workbench. Instances share a full mask render when their boxes projected from the mesh vertices are apart, so with Cycles shader displacement that pushes a surface far out of its mesh, a full mask may miss where another instance covers it.

Example
generating.Segmentation({"car": [car_1, car_2]}, per="both", skip_empty=True)
generating.Segmentation({"car": [car_1, car_2]}, full_masks=True)  # for export.bop

SegmentationImage

SegmentationImage(
    file_format: Literal["PNG", "JPEG"] = "PNG",
    *,
    opacity: float = 0.5,
    line_width: int = 2,
    show_class: bool = True,
)

Saves a copy of the rendered image with the masks of the Segmentation step drawn over it, to <index>_segmentation.<ext>, for checking the labels.

Uses the same render as Render, and the main image stays clean. Each mask is laid over in its class color (the same as in BBoxImage), each instance outlined, and its class name written above. Instance masks are used when there are any, otherwise the class masks. Needs a Segmentation step in the same Compose.

In the label JSON: "segmentation_image": file name.

Parameters:

  • file_format (Literal['PNG', 'JPEG'], default: 'PNG' ) –

    "PNG" or "JPEG".

  • opacity (float, default: 0.5 ) –

    how much the class color covers the image, 0-1.

  • line_width (int, default: 2 ) –

    outline width in pixels, 0 = no outline.

  • show_class (bool, default: True ) –

    write the class name above each mask.

Example
generating.SegmentationImage(opacity=0.4)