Skip to main content
difotrain

DifoTrain

An embodiment-agnostic framework for training Vision-Language-Action (VLA) models from the real world

CI PyPI Python 3.10+ License


Overview

DifoTrain is a framework for collecting demonstrations, training Vision-Language-Action (VLA) policies on them, and deploying those policies to robots — in simulation or on real hardware, on any embodiment. It learns from both teleoperation and human video, and it can either wrap an existing VLA (OpenVLA / Octo / π0 / ACT) or train a native model.

The whole collect → train → eval → deploy loop runs out of the box on CPU using a built-in, dependency-free simulated robot — no webcam, GPU, or hardware required.

Architecture

The framework hangs off four pluggable interfaces. A custom robot, data source, or model is just an implementation of one of these, registered into the framework.

Interface Module Implementations shipped
Robot difotrain.embodiment PlanarArm (sim, dependency-free); PyBullet/MuJoCo/real plug in here
DataSource difotrain.data.sources ScriptedTeleopSource, HumanVideoSource, SyntheticSource
Policy difotrain.policy MLPVLAPolicy (native); EchoVLAPolicy (wrapper reference)
EpisodeDataset difotrain.data LeRobot/RLDS-style directory dataset
Collect ─▶ Standardize ─▶ Train/Finetune ─▶ Evaluate ─▶ Deploy ─▶ (feedback loop)
 teleop      Episode         BC trainer        sim/real    safety     log rollouts
 human-vid   dataset         + normalize       success     layer      back to dataset

Install

pip install difotrain                 # core (numpy + torch)
pip install "difotrain[capture]"      # + MediaPipe/OpenCV for webcam human-video
pip install "difotrain[sim]"          # + PyBullet for heavier sim backends
pip install "difotrain[dev]"          # + pytest

Quickstart

The reference task: a 2-link arm must reach a named target conveyed only through language — so success measures genuine language grounding, not memorized motion.

difotrain info                                   # list registered robots/sources
difotrain collect --out data/reach --episodes 200
difotrain train   --data data/reach --out runs/policy.pt --epochs 150
difotrain eval    --policy runs/policy.pt
difotrain deploy  --policy runs/policy.pt --instruction "reach to the lower left"

Typical eval output after training:

success_rate     : 87.50%
mean_final_error : 0.0259
  [OK ] up           err=0.0180
  [OK ] down         err=0.0037
  ...

Python API

from difotrain.data.dataset import EpisodeDataset
from difotrain.data.sources.scripted_teleop import ScriptedTeleopSource
from difotrain.train.trainer import train_policy, TrainConfig
from difotrain.eval.evaluator import evaluate_reaching

ds = EpisodeDataset("data/reach")
ds.extend(ScriptedTeleopSource(seed=0).collect(200))     # collect demos
policy = train_policy(ds, TrainConfig(epochs=150))       # behavior cloning
print(evaluate_reaching(policy))                          # score in sim

Adding your own robot

from difotrain.core import register_robot
from difotrain.embodiment.base import Robot, RobotSpec

@register_robot("my_arm")
class MyArm(Robot):
    def __init__(self):
        self.spec = RobotSpec(name="my_arm", dof=..., observation_space=..., action_space=...)
    def reset(self, *, instruction="", seed=None): ...
    def get_observation(self): ...
    def apply_action(self, action): ...

Sim and real robots implement the same Robot API, so policies, the evaluator, and the deploy runner drive them unchanged.

Learning from human video

HumanVideoSource estimates human pose (MediaPipe) and uses a Retargeter to map it into a robot's action space, turning cheap video into trainable demonstrations. It also runs offline from a recorded trajectory JSON:

difotrain setup     # download the MediaPipe pose model
difotrain record    # capture human motion from a webcam

Documentation

Full docs live in docs/:

Roadmap

  • Core interfaces, sim robot, dataset, native VLA, BC training, eval, deploy + safety
  • Scripted-teleop and human-video data sources, retargeting
  • PyBullet backend behind the Robot API (difotrain[sim]); MuJoCo next
  • Wrapped OpenVLA / Octo / π0 / ACT policies
  • Image observations + transformer language encoder
  • Real-hardware drivers and online DAgger feedback loop

Development

uv sync               # or: pip install -e ".[dev,capture]"
python -m unittest discover -s tests -v

License

MIT — see LICENSE.

Metadata

Release files for difotrain 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for difotrain 0.2.1
File Size Uploaded Provenance Actions
difotrain-0.2.1.tar.gz 72.3 kB Without provenance Details for difotrain-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for difotrain 0.2.1
File Interpreter ABI Platform Actions
difotrain-0.2.1-py3-none-any.whl Python 3 none any Details for difotrain-0.2.1-py3-none-any.whl

Total release size: 110.6 kB

Release files / difotrain-0.2.1.tar.gz

Download URL difotrain-0.2.1.tar.gz
Size 72.3 kB
Tags Source
SHA-256 checksum
How to use checksums
965ec207f741c8591384f54c426524c243826db46ada2636588baa8a01c7a161
BLAKE2b-256 checksum
How to use checksums
d2f0f5578f0790ea108582aae04190e5b3764c14f2ab7f5447d70979bb389473
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / difotrain-0.2.1-py3-none-any.whl

Download URL difotrain-0.2.1-py3-none-any.whl
Size 38.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
189ac34405acfce11bff8e4aef9aa2d53c0d68af698cbe783155f678b0af412f
BLAKE2b-256 checksum
How to use checksums
141ea9ec51f46fc741515212e42ae39ac24e14f4eaaf5db3362c76009263516f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for difotrain 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page