Macrodata_Labs
AboutBlogDemo
Announcing MacroHands, our SOTA model for 3D hands and camera path from egocentric video!
// Docs›
Quickstart
Running pipelines
  • In-process debugging
  • Local launcher
Reading data
  • Reader model
  • Sharding
  • LeRobot reader
  • HDF5 reader
  • Zarr reader
  • MCAP reader
  • Tabular files
  • Files and videos
  • Hugging Face
  • TensorFlow
  • Lance
  • Custom readers
Episode data
  • Episode rows
  • Frames and videos
  • Metadata, tasks, and stats
  • Converting to robot rows
Transforms
  • Row transforms
  • Async and batch transforms
  • Vectorized transforms
  • Expressions
  • Schemas and DTypes
Episode operations
  • Motion trimming
  • Subtask annotation
Inference
  • Generate text
  • Multimodal and structured output
  • Inference providers
  • Pooling
Writing data
  • Writer model
  • LeRobot writer
  • Zarr writer
  • Parquet and JSONL writers
  • Lance
  • Media assets and reducers
Examples
  • ALOHA HDF5
  • robomimic HDF5
  • Zarr replay buffer
  • MCAP Franka
  • LIBERO HDF5
  • Merge LeRobot datasets
  • Annotate subtasks
Reference
  • Path formats
  • Optional dependencies
// Docs
Quickstart
Running pipelines
  • In-process debugging
  • Local launcher
Reading data
  • Reader model
  • Sharding
  • LeRobot reader
  • HDF5 reader
  • Zarr reader
  • MCAP reader
  • Tabular files
  • Files and videos
  • Hugging Face
  • TensorFlow
  • Lance
  • Custom readers
Episode data
  • Episode rows
  • Frames and videos
  • Metadata, tasks, and stats
  • Converting to robot rows
Transforms
  • Row transforms
  • Async and batch transforms
  • Vectorized transforms
  • Expressions
  • Schemas and DTypes
Episode operations
  • Motion trimming
  • Subtask annotation
Inference
  • Generate text
  • Multimodal and structured output
  • Inference providers
  • Pooling
Writing data
  • Writer model
  • LeRobot writer
  • Zarr writer
  • Parquet and JSONL writers
  • Lance
  • Media assets and reducers
Examples
  • ALOHA HDF5
  • robomimic HDF5
  • Zarr replay buffer
  • MCAP Franka
  • LIBERO HDF5
  • Merge LeRobot datasets
  • Annotate subtasks
Reference
  • Path formats
  • Optional dependencies

Quickstart

Run a complete robotics data pipeline with Refiner

Refiner provides open-source data-processing utilities and reference implementations from our published research. Contact us directly for access to our proprietary models and pipelines.

Refiner is an open-source library for building robotics data pipelines. A pipeline describes how to read data, transform rows and episodes, and write the result. You can process a wide range of formats out of the box, use models for labeling and scoring, and inspect pipelines locally while you develop. When you want parallel execution on your machine, run the same code with local workers.

Readers and writers are sharded, so most pipelines do not need to download or materialize the entire dataset before doing useful work. Refiner streams shards through the pipeline and writes outputs as they are produced.

Install

Install the Refiner package in the Python environment where you want to build or run the pipeline:

1
pip install macrodata-refiner[hf,video]

The hf and video extras are optional, but the example below uses them for Hugging Face paths and video data. To install every optional dependency, use pip install macrodata-refiner[all].

Example

Most Refiner pipelines follow the same shape:

1
read data  →  transform  →  write result

For example:

1
2
3
4
5
6
7
import refiner as mdr

pipeline = (
    mdr.read_lerobot("hf://datasets/macrodata/aloha_static_battery_ep005_009")
    .map(lambda row: row.update(task="battery insertion"))
    .write_lerobot("hf://buckets/macrodata/test_bucket/aloha_static_with_task")
)

This example reads a small Hugging Face dataset, adds a task label to each episode, and writes the result back to a Hugging Face bucket.

Each step returns a new pipeline value:

StepWhat it does
read_lerobot(...)Reads robotics episodes with the LeRobot reader.
.map(...)Updates each row or episode with a task label.
.write_lerobot(...)Writes the transformed dataset with the LeRobot writer.

Nothing runs when you create the pipeline. Refiner executes it only when you inspect rows with methods like take() or launch local workers.

Inspect a pipeline

Start by inspecting a small amount of data in process. This block is self-contained and inspects the pipeline before the writer:

1
2
3
4
5
6
7
8
9
10
import refiner as mdr

pipeline = (
    mdr.read_lerobot("hf://datasets/macrodata/aloha_static_battery_ep005_009")
    .map(lambda row: row.update(task="battery insertion"))
)

row = pipeline.take(1)

print(row[0])

Output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
LeRobotRow
  episode_id: '0'
  num_frames: 600
  task: 'battery insertion'
  fps: 50
  robot_type: 'unknown'
  frame_data (row.to_frame_table()):
    actions (row.actions): float[600, 14]
    states (row.states): float[600, 14]
    timestamps (row.timestamps): float[600]
  videos (row.videos):
    observation.images.cam_high: video[480, 640, 3]@50fps
    observation.images.cam_left_wrist: video[480, 640, 3]@50fps
    observation.images.cam_low: video[480, 640, 3]@50fps
    observation.images.cam_right_wrist: video[480, 640, 3]@50fps
  stats: ['action', 'episode_index', 'frame_index', 'index', 'next.done', 'observation.images.cam_high', 'observation.images.cam_left_wrist', 'observation.images.cam_low', '... +4 more']

take() executes lazily and stops after the requested number of rows, so it is the fastest way to check schemas, media references, and transform outputs before launching a full job.

Run locally

Consider this pipeline:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import refiner as mdr

def log_stats(row):
    row.log_histogram("frames", row.num_frames, unit="frames", per="episode")

    mdr.logger.info(
        "episode={} task={!r} frames={} cameras={}",
        row.episode_id,
        row.task,
        row.num_frames,
        sorted(row.videos),
    )

    return row


pipeline = (
    mdr.read_lerobot("hf://datasets/macrodata/aloha_static_battery_ep005_009")
    .map(log_stats)
)

pipeline.launch_local(name="quickstart-aloha-summary")

Local launch is the standard way to run a complete Refiner pipeline. It distributes shards across worker processes on your machine.

Advanced example

Here is a more elaborate example, reading from and writing to Hugging Face buckets.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import refiner as mdr

dataset = "hf://datasets/yifengzhu-hf/LIBERO-datasets/libero_spatial"
# Replace this with your output bucket (HF, S3, GCP, etc).
output = "hf://buckets/macrodata/test_bucket/libero-spatial"

(
    mdr.read_hdf5(
        dataset,
        groups="/data/demo_*",
        datasets={
            "raw_action": "actions",
            "observation.images.image": "obs/agentview_rgb",
            "observation.images.wrist_image": "obs/eye_in_hand_rgb",
            "ee_state": "obs/ee_states",
            "gripper_state": "obs/gripper_states",
        },
        file_path_column="file_path",
        cache_remote_files=True,
    )
    .map(
        lambda row: row.update(
            task=str(row["file_path"])
            .rsplit("/", 1)[-1]
            .removesuffix(".hdf5")
            .removesuffix("_demo")
            .replace("_", " ")
        )
    )
    .to_robot_rows(
        task_key="task",
        fps=10.0,
        robot_type="libero",
        action_key="raw_action",
        state_key=("ee_state", "gripper_state"),
        video_keys={
            "observation.images.image": "observation.images.image",
            "observation.images.wrist_image": "observation.images.wrist_image",
        },
    )
    .write_lerobot(output, max_video_prepare_in_flight=2)
    .launch_local(
        name="libero-spatial-subset",
        num_workers=2,
    )
)

This example converts the public LIBERO spatial HDF5 subset to LeRobot using local workers. It reads one demo group per row, derives the task label from the filename, turns action/state/image arrays into robotics episodes, encodes the two camera streams as videos, and writes a LeRobot dataset to your output bucket.

The input dataset is public, but writing to your Hugging Face bucket requires an HF_TOKEN in the environment inherited by the local workers:

1
export HF_TOKEN="your-write-token"

For the full four-suite LIBERO conversion, see Libero HDF5.

Where to go next

  • Learn the execution options in Running Pipelines.
  • Learn readers in Reading Data.
  • Learn the episode model in Episode Data.
  • Learn common row operations in Transforms.
  • Learn LeRobot output details in Writing LeRobot.

// Table of Contents

  1. Install
  2. Example
  3. Inspect a pipeline
  4. Run locally
  5. Advanced example
  6. Where to go next
Macrodata_Labs
TermsPrivacyContact
  • GitHub
  • LinkedIn
  • X
  • HuggingFace
  • Discord