Embodiment-agnostic framework for training Vision-Language-Action (VLA) models from real-world and simulated demonstrations
Project description
DifoTrain
An embodiment-agnostic framework for training Vision-Language-Action (VLA) models from the real world
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/:
- Installation
- Quickstart
- Concepts & architecture
- How it works — full architecture deep-dive
- CLI reference
- Python API
- Extending DifoTrain — add your own robot, data source, or model
- Learning from human video
- Examples
- FAQ & troubleshooting
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
RobotAPI (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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file difotrain-0.2.1.tar.gz.
File metadata
- Download URL: difotrain-0.2.1.tar.gz
- Upload date:
- Size: 72.3 kB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
965ec207f741c8591384f54c426524c243826db46ada2636588baa8a01c7a161
|
|
| MD5 |
808764ff2c772392b43bf798661b5a08
|
|
| BLAKE2b-256 |
d2f0f5578f0790ea108582aae04190e5b3764c14f2ab7f5447d70979bb389473
|
File details
Details for the file difotrain-0.2.1-py3-none-any.whl.
File metadata
- Download URL: difotrain-0.2.1-py3-none-any.whl
- Upload date:
- Size: 38.3 kB
- Tags: Python 3
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
189ac34405acfce11bff8e4aef9aa2d53c0d68af698cbe783155f678b0af412f
|
|
| MD5 |
bcd573f66312682a0195ae4aaec30fb6
|
|
| BLAKE2b-256 |
141ea9ec51f46fc741515212e42ae39ac24e14f4eaaf5db3362c76009263516f
|