Robotics
LeRobot
Safetensors
diffusion
ebenl08 commited on
Commit
e0e1626
·
verified ·
1 Parent(s): b79b1fd

Migrate policy to PolicyProcessorPipeline system

Browse files
README.md CHANGED
@@ -1,70 +1,136 @@
1
  ---
 
 
2
  license: apache-2.0
3
- datasets:
4
- - lerobot/pusht
5
  tags:
6
- - diffusion-policy
7
- - model_hub_mixin
8
- - pytorch_model_hub_mixin
9
  - robotics
10
- pipeline_tag: robotics
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  ---
12
- # Model Card for Diffusion Policy / PushT
13
 
14
- Diffusion Policy (as per [Diffusion Policy: Visuomotor Policy
15
- Learning via Action Diffusion](https://arxiv.org/abs/2303.04137)) trained for the `PushT` environment from [gym-pusht](https://github.com/huggingface/gym-pusht).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  ## How to Get Started with the Model
18
 
19
- See the [LeRobot library](https://github.com/huggingface/lerobot) (particularly the [evaluation script](https://github.com/huggingface/lerobot/blob/main/lerobot/scripts/eval.py)) for instructions on how to load and evaluate this model.
20
 
21
- ## Training Details
 
 
 
22
 
23
- Trained with [LeRobot@3c0a209](https://github.com/huggingface/lerobot/tree/3c0a209f9fac4d2a57617e686a7f2a2309144ba2).
24
 
25
- The model was trained using [LeRobot's training script](https://github.com/huggingface/lerobot/blob/main/lerobot/scripts/train.py) and with the [pusht](https://huggingface.co/datasets/lerobot/pusht) dataset, using this command:
26
 
27
  ```bash
28
- python lerobot/scripts/train.py \
29
- --output_dir=outputs/train/diffusion_pusht \
30
- --policy.type=diffusion \
31
- --dataset.repo_id=lerobot/pusht \
32
- --seed=100000 \
33
- --env.type=pusht \
34
- --batch_size=64 \
35
- --steps=200000 \
36
- --eval_freq=25000 \
37
- --save_freq=25000 \
38
- --wandb.enable=true
39
  ```
40
 
 
 
 
41
 
42
- The training curves may be found at https://wandb.ai/aliberts/lerobot/runs/s7elvf4r.
43
- The current model corresponds to the checkpoint at 175k steps.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  ## Evaluation
46
 
47
- The model was evaluated on the `PushT` environment from [gym-pusht](https://github.com/huggingface/gym-pusht) and compared to a similar model trained with the original [Diffusion Policy code](https://github.com/real-stanford/diffusion_policy). There are two evaluation metrics on a per-episode basis:
 
48
 
49
- - Maximum overlap with target (seen as `eval/avg_max_reward` in the charts above). This ranges in [0, 1].
50
- - Success: whether or not the maximum overlap is at least 95%.
 
51
 
52
- Here are the metrics for 500 episodes worth of evaluation. The "Theirs" column is for an equivalent model trained on the original Diffusion Policy repository and evaluated on LeRobot (the model weights may be found in the [`original_dp_repo`](https://huggingface.co/lerobot/diffusion_pusht/tree/original_dp_repo) branch of this respository).
 
 
53
 
54
- <blank>|Ours|Theirs
55
- -|-|-
56
- Average max. overlap ratio | 0.955 | 0.957
57
- Success rate for 500 episodes (%) | 65.4 | 64.2
58
 
59
- The results of each of the individual rollouts may be found in [eval_info.json](eval_info.json).
60
- It was produced after training with this command:
61
- ```bash
62
- python lerobot/scripts/eval.py \
63
- --policy.path=outputs/train/diffusion_pusht/checkpoints/175000/pretrained_model \
64
- --output_dir=outputs/eval/diffusion_pusht/175000 \
65
- --env.type=pusht \
66
- --eval.n_episodes=500 \
67
- --eval.batch_size=50 \
68
- --device=cuda \
69
- --use_amp=false
 
 
70
  ```
 
1
  ---
2
+ datasets: unknown
3
+ library_name: lerobot
4
  license: apache-2.0
5
+ model_name: diffusion
6
+ pipeline_tag: robotics
7
  tags:
8
+ - lerobot
 
 
9
  - robotics
10
+ - diffusion
11
+ ---
12
+
13
+ # Model Card for diffusion
14
+
15
+ <!-- Provide a quick summary of what the model is/does. -->
16
+
17
+
18
+ [Diffusion Policy](https://huggingface.co/papers/2303.04137) treats visuomotor control as a generative diffusion process, producing smooth, multi-step action trajectories that excel at contact-rich manipulation.
19
+
20
+
21
+
22
+
23
+ <!-- A short demo is worth more than any description! Record a GIF/video of the policy
24
+ running on your robot, upload it to this repo, and embed it here:
25
+ <p align="center">
26
+ <img src="https://huggingface.co/<hf_user>/<policy_repo_id>/resolve/main/demo.gif" width="60%"/>
27
+ </p>
28
+ -->
29
+
30
+ This policy has been trained and pushed to the Hub using [LeRobot](https://github.com/huggingface/lerobot).
31
+
32
+ See the [full LeRobot documentation](https://huggingface.co/docs/lerobot/index).
33
+
34
+
35
  ---
 
36
 
37
+ ## Model Details
38
+
39
+ - **License:** apache-2.0
40
+
41
+
42
+ ## Inputs & Outputs
43
+
44
+ The policy consumes these observation features and produces these action features.
45
+
46
+ **Inputs**
47
+
48
+ | Feature | Type | Shape |
49
+ | --- | --- | --- |
50
+ | `observation.image` | VISUAL | `(3, 96, 96)` |
51
+ | `observation.state` | STATE | `(2,)` |
52
+
53
+ **Outputs**
54
+
55
+ | Feature | Type | Shape |
56
+ | --- | --- | --- |
57
+ | `action` | ACTION | `(2,)` |
58
+
59
+
60
+
61
+ ---
62
 
63
  ## How to Get Started with the Model
64
 
65
+ New to LeRobot? These guides cover the full workflow:
66
 
67
+ - **[Install LeRobot](https://huggingface.co/docs/lerobot/main/en/installation)** — set up the `lerobot` package.
68
+ - **[Hardware setup](https://huggingface.co/docs/lerobot/main/en/hardware_guide)** — assemble, wire, and calibrate your robot and cameras.
69
+ - **[Record data & train a policy](https://huggingface.co/docs/lerobot/en/il_robots)** — the end-to-end imitation-learning walkthrough.
70
+ - **[CLI cheat-sheet](https://huggingface.co/docs/lerobot/main/en/cheat-sheet)** — quick reference for the `lerobot-*` commands.
71
 
72
+ The short version to run and train this policy:
73
 
74
+ ### Run the policy on your robot
75
 
76
  ```bash
77
+ lerobot-rollout \
78
+ --strategy.type=base \
79
+ --robot.type=<your_robot_type> \
80
+ --robot.port=<your_robot_port> \
81
+ --robot.cameras="{ <camera_1>: {type: opencv, index_or_path: <index_or_path>, width: 640, height: 480, fps: 30}, <camera_2>: {type: opencv, index_or_path: <index_or_path>, width: 640, height: 480, fps: 30}}" \
82
+ --policy.path=<hf_user>/<policy_repo_id> \
83
+ --task="<your_task_description>" \
84
+ --duration=60
 
 
 
85
  ```
86
 
87
+ Replace the remaining `<...>` placeholders with your own values: `--robot.port` and the camera names/indices are specific to your machine, and the camera names must match the observation keys this policy was trained on.
88
+
89
+ When `--strategy.type=base` is used the script doesn't record the episodes. Skipping duration will make the policy run indefinitely. For more information look at [rollout documentation](https://huggingface.co/docs/lerobot/main/en/inference).
90
 
91
+ ### Train your own policy
92
+
93
+ ```bash
94
+ lerobot-train \
95
+ --dataset.repo_id=${HF_USER}/<dataset> \
96
+ --policy.type=diffusion \
97
+ --output_dir=outputs/train/<policy_repo_id> \
98
+ --job_name=lerobot_training \
99
+ --policy.device=cuda \
100
+ --policy.repo_id=${HF_USER}/<policy_repo_id> \
101
+ --wandb.enable=true
102
+ ```
103
+
104
+ _Writes checkpoints to `outputs/train/<policy_repo_id>/checkpoints/`._
105
+
106
+ ---
107
 
108
  ## Evaluation
109
 
110
+ <!-- Report real-robot results here: run the policy several times per task and count the
111
+ successes. Delete the "No evaluation results" line and fill in this table instead:
112
 
113
+ | Task | Trials | Successes | Success rate |
114
+ | ---- | ------ | --------- | ------------ |
115
+ | pick the lego brick | 10 | 8 | 80% |
116
 
117
+ Also worth noting: anything that affects difficulty (new object positions, lighting,
118
+ distractors, a different robot of the same type, ...).
119
+ -->
120
 
121
+ _No evaluation results have been provided for this policy yet._
 
 
 
122
 
123
+ ---
124
+
125
+ ## Citation
126
+
127
+ If you use this policy, please cite the method linked in the description above, along with LeRobot:
128
+
129
+ ```bibtex
130
+ @misc{cadene2024lerobot,
131
+ author = {Cadene, Remi and Alibert, Simon and Soare, Alexander and Gallouedec, Quentin and Zouitine, Adil and Palma, Steven and Kooijmans, Pepijn and Aractingi, Michel and Shukor, Mustafa and Aubakirova, Dana and Russi, Martino and Capuano, Francesco and Pascal, Caroline and Choghari, Jade and Moss, Jess and Wolf, Thomas},
132
+ title = {LeRobot: State-of-the-art Machine Learning for Real-World Robotics in Pytorch},
133
+ howpublished = "\url{https://github.com/huggingface/lerobot}",
134
+ year = {2024}
135
+ }
136
  ```
config.json CHANGED
@@ -1,76 +1,88 @@
1
  {
2
- "beta_end": 0.02,
3
- "beta_schedule": "squaredcos_cap_v2",
4
- "beta_start": 0.0001,
5
- "clip_sample": true,
6
- "clip_sample_range": 1.0,
7
- "crop_is_random": true,
8
- "crop_shape": [
9
- 84,
10
- 84
11
- ],
12
- "diffusion_step_embed_dim": 128,
13
- "do_mask_loss_for_padding": false,
14
- "down_dims": [
15
- 512,
16
- 1024,
17
- 2048
18
- ],
19
- "drop_n_last_frames": 7,
20
- "horizon": 16,
21
- "input_features": {
22
- "observation.image": {
23
- "shape": [
24
- 3,
25
- 96,
26
- 96
27
- ],
28
- "type": "VISUAL"
29
  },
30
- "observation.state": {
31
- "shape": [
32
- 2
33
- ],
34
- "type": "STATE"
35
- }
36
- },
37
- "kernel_size": 5,
38
- "n_action_steps": 8,
39
- "n_groups": 8,
40
- "n_obs_steps": 2,
41
- "device": "cuda",
42
- "use_amp": false,
43
- "noise_scheduler_type": "DDPM",
44
- "normalization_mapping": {
45
- "ACTION": "MIN_MAX",
46
- "STATE": "MIN_MAX",
47
- "VISUAL": "MEAN_STD"
48
- },
49
- "num_inference_steps": null,
50
- "num_train_timesteps": 100,
51
- "optimizer_betas": [
52
- 0.95,
53
- 0.999
54
- ],
55
- "optimizer_eps": 1e-08,
56
- "optimizer_lr": 0.0001,
57
- "optimizer_weight_decay": 1e-06,
58
- "output_features": {
59
- "action": {
60
- "shape": [
61
- 2
62
- ],
63
- "type": "ACTION"
64
- }
65
- },
66
- "prediction_type": "epsilon",
67
- "pretrained_backbone_weights": null,
68
- "scheduler_name": "cosine",
69
- "scheduler_warmup_steps": 500,
70
- "spatial_softmax_num_keypoints": 32,
71
- "type": "diffusion",
72
- "use_film_scale_modulation": true,
73
- "use_group_norm": true,
74
- "use_separate_rgb_encoder_per_camera": false,
75
- "vision_backbone": "resnet18"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  }
 
1
  {
2
+ "type": "diffusion",
3
+ "n_obs_steps": 2,
4
+ "input_features": {
5
+ "observation.image": {
6
+ "type": "VISUAL",
7
+ "shape": [
8
+ 3,
9
+ 96,
10
+ 96
11
+ ]
12
+ },
13
+ "observation.state": {
14
+ "type": "STATE",
15
+ "shape": [
16
+ 2
17
+ ]
18
+ }
 
 
 
 
 
 
 
 
 
 
19
  },
20
+ "output_features": {
21
+ "action": {
22
+ "type": "ACTION",
23
+ "shape": [
24
+ 2
25
+ ]
26
+ }
27
+ },
28
+ "device": "cuda",
29
+ "use_amp": false,
30
+ "use_peft": false,
31
+ "push_to_hub": true,
32
+ "repo_id": null,
33
+ "private": null,
34
+ "tags": null,
35
+ "license": null,
36
+ "pretrained_path": null,
37
+ "pretrained_revision": null,
38
+ "horizon": 16,
39
+ "n_action_steps": 8,
40
+ "normalization_mapping": {
41
+ "ACTION": "MIN_MAX",
42
+ "STATE": "MIN_MAX",
43
+ "VISUAL": "MEAN_STD"
44
+ },
45
+ "drop_n_last_frames": 7,
46
+ "vision_backbone": "resnet18",
47
+ "resize_shape": null,
48
+ "crop_ratio": 1.0,
49
+ "crop_shape": [
50
+ 84,
51
+ 84
52
+ ],
53
+ "crop_is_random": true,
54
+ "pretrained_backbone_weights": null,
55
+ "use_group_norm": true,
56
+ "spatial_softmax_num_keypoints": 32,
57
+ "use_separate_rgb_encoder_per_camera": false,
58
+ "down_dims": [
59
+ 512,
60
+ 1024,
61
+ 2048
62
+ ],
63
+ "kernel_size": 5,
64
+ "n_groups": 8,
65
+ "diffusion_step_embed_dim": 128,
66
+ "use_film_scale_modulation": true,
67
+ "noise_scheduler_type": "DDPM",
68
+ "num_train_timesteps": 100,
69
+ "beta_schedule": "squaredcos_cap_v2",
70
+ "beta_start": 0.0001,
71
+ "beta_end": 0.02,
72
+ "prediction_type": "epsilon",
73
+ "clip_sample": true,
74
+ "clip_sample_range": 1.0,
75
+ "num_inference_steps": null,
76
+ "compile_model": false,
77
+ "compile_mode": "reduce-overhead",
78
+ "do_mask_loss_for_padding": false,
79
+ "optimizer_lr": 0.0001,
80
+ "optimizer_betas": [
81
+ 0.95,
82
+ 0.999
83
+ ],
84
+ "optimizer_eps": 1e-08,
85
+ "optimizer_weight_decay": 1e-06,
86
+ "scheduler_name": "cosine",
87
+ "scheduler_warmup_steps": 500
88
  }
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:995d14d35db57d95c35ad9704c3d79c8612b7bc45f3877e5c46c2cdc516856a8
3
- size 1050862408
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:69ecc36b62286bd5472a0e92b64e53ee6e0cb8b96fc05c247c4b7d1be583c2b2
3
+ size 1050861448
policy_postprocessor.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "policy_postprocessor",
3
+ "steps": [
4
+ {
5
+ "registry_name": "unnormalizer_processor",
6
+ "config": {
7
+ "eps": 1e-08,
8
+ "features": {
9
+ "action": {
10
+ "type": "ACTION",
11
+ "shape": [
12
+ 2
13
+ ]
14
+ }
15
+ },
16
+ "norm_map": {
17
+ "ACTION": "MIN_MAX",
18
+ "STATE": "MIN_MAX",
19
+ "VISUAL": "MEAN_STD"
20
+ }
21
+ },
22
+ "state_file": "policy_postprocessor_step_0_unnormalizer_processor.safetensors"
23
+ },
24
+ {
25
+ "registry_name": "device_processor",
26
+ "config": {
27
+ "device": "cpu",
28
+ "float_dtype": null
29
+ }
30
+ }
31
+ ]
32
+ }
policy_postprocessor_step_0_unnormalizer_processor.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:392af8778e650720aa230904998d2c11184583d956f0b7eada100afd09bf2378
3
+ size 504
policy_preprocessor.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "policy_preprocessor",
3
+ "steps": [
4
+ {
5
+ "registry_name": "rename_observations_processor",
6
+ "config": {
7
+ "rename_map": {}
8
+ }
9
+ },
10
+ {
11
+ "registry_name": "to_batch_processor",
12
+ "config": {}
13
+ },
14
+ {
15
+ "registry_name": "device_processor",
16
+ "config": {
17
+ "device": "cuda",
18
+ "float_dtype": null
19
+ }
20
+ },
21
+ {
22
+ "registry_name": "normalizer_processor",
23
+ "config": {
24
+ "eps": 1e-08,
25
+ "features": {
26
+ "observation.image": {
27
+ "type": "VISUAL",
28
+ "shape": [
29
+ 3,
30
+ 96,
31
+ 96
32
+ ]
33
+ },
34
+ "observation.state": {
35
+ "type": "STATE",
36
+ "shape": [
37
+ 2
38
+ ]
39
+ },
40
+ "action": {
41
+ "type": "ACTION",
42
+ "shape": [
43
+ 2
44
+ ]
45
+ }
46
+ },
47
+ "norm_map": {
48
+ "ACTION": "MIN_MAX",
49
+ "STATE": "MIN_MAX",
50
+ "VISUAL": "MEAN_STD"
51
+ }
52
+ },
53
+ "state_file": "policy_preprocessor_step_3_normalizer_processor.safetensors"
54
+ }
55
+ ]
56
+ }
policy_preprocessor_step_3_normalizer_processor.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:392af8778e650720aa230904998d2c11184583d956f0b7eada100afd09bf2378
3
+ size 504