qualiaadmin commited on
Commit
2bf5a45
·
verified ·
1 Parent(s): de1254e

Fork of lerobot/smolvla_base

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ collage_small.gif filter=lfs diff=lfs merge=lfs -text
Finetune_SmolVLA_notebook.ipynb ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {
6
+ "id": "NQUk3Y0WwYZ4"
7
+ },
8
+ "source": [
9
+ "# 🤗 x 🦾: Training SmolVLA with LeRobot Notebook\n",
10
+ "\n",
11
+ "Welcome to the **LeRobot SmolVLA training notebook**! This notebook provides a ready-to-run setup for training imitation learning policies using the [🤗 LeRobot](https://github.com/huggingface/lerobot) library.\n",
12
+ "\n",
13
+ "In this example, we train an `SmolVLA` policy using a dataset hosted on the [Hugging Face Hub](https://huggingface.co/), and optionally track training metrics with [Weights & Biases (wandb)](https://wandb.ai/).\n",
14
+ "\n",
15
+ "## ⚙️ Requirements\n",
16
+ "- A Hugging Face dataset repo ID containing your training data (`--dataset.repo_id=YOUR_USERNAME/YOUR_DATASET`)\n",
17
+ "- Optional: A [wandb](https://wandb.ai/) account if you want to enable training visualization\n",
18
+ "- Recommended: GPU runtime (e.g., NVIDIA A100) for faster training\n",
19
+ "\n",
20
+ "## ⏱️ Expected Training Time\n",
21
+ "Training with the `SmolVLA` policy for 20,000 steps typically takes **about 5 hours on an NVIDIA A100** GPU. On less powerful GPUs or CPUs, training may take significantly longer!\n",
22
+ "\n",
23
+ "## Example Output\n",
24
+ "Model checkpoints, logs, and training plots will be saved to the specified `--output_dir`. If `wandb` is enabled, progress will also be visualized in your wandb project dashboard.\n"
25
+ ]
26
+ },
27
+ {
28
+ "cell_type": "markdown",
29
+ "metadata": {
30
+ "id": "MOJyX0CnwA5m"
31
+ },
32
+ "source": [
33
+ "## Install conda\n",
34
+ "This cell uses `condacolab` to bootstrap a full Conda environment inside Google Colab.\n"
35
+ ]
36
+ },
37
+ {
38
+ "cell_type": "code",
39
+ "execution_count": null,
40
+ "metadata": {
41
+ "id": "QlKjL1X5t_zM"
42
+ },
43
+ "outputs": [],
44
+ "source": [
45
+ "!pip install -q condacolab\n",
46
+ "import condacolab\n",
47
+ "condacolab.install()"
48
+ ]
49
+ },
50
+ {
51
+ "cell_type": "markdown",
52
+ "metadata": {
53
+ "id": "DxCc3CARwUjN"
54
+ },
55
+ "source": [
56
+ "## Install LeRobot\n",
57
+ "This cell clones the `lerobot` repository from Hugging Face, installs FFmpeg (version 7.1.1), and installs the package in editable mode.\n"
58
+ ]
59
+ },
60
+ {
61
+ "cell_type": "code",
62
+ "execution_count": null,
63
+ "metadata": {
64
+ "id": "dgLu7QT5tUik"
65
+ },
66
+ "outputs": [],
67
+ "source": [
68
+ "!git clone https://github.com/huggingface/lerobot.git\n",
69
+ "!conda install ffmpeg=7.1.1 -c conda-forge\n",
70
+ "!cd lerobot && pip install -e ."
71
+ ]
72
+ },
73
+ {
74
+ "cell_type": "markdown",
75
+ "metadata": {
76
+ "id": "Q8Sn2wG4wldo"
77
+ },
78
+ "source": [
79
+ "## Weights & Biases login\n",
80
+ "This cell logs you into Weights & Biases (wandb) to enable experiment tracking and logging."
81
+ ]
82
+ },
83
+ {
84
+ "cell_type": "code",
85
+ "execution_count": null,
86
+ "metadata": {
87
+ "id": "PolVM_movEvp"
88
+ },
89
+ "outputs": [],
90
+ "source": [
91
+ "!wandb login"
92
+ ]
93
+ },
94
+ {
95
+ "cell_type": "markdown",
96
+ "metadata": {
97
+ "id": "zTWQAgX9xseE"
98
+ },
99
+ "source": [
100
+ "## Install SmolVLA dependencies"
101
+ ]
102
+ },
103
+ {
104
+ "cell_type": "code",
105
+ "execution_count": null,
106
+ "metadata": {
107
+ "id": "DiHs0BKwxseE"
108
+ },
109
+ "outputs": [],
110
+ "source": [
111
+ "!cd lerobot && pip install -e \".[smolvla]\""
112
+ ]
113
+ },
114
+ {
115
+ "cell_type": "markdown",
116
+ "metadata": {
117
+ "id": "IkzTo4mNwxaC"
118
+ },
119
+ "source": [
120
+ "## Start training SmolVLA with LeRobot\n",
121
+ "\n",
122
+ "This cell runs the `train.py` script from the `lerobot` library to train a robot control policy. \n",
123
+ "\n",
124
+ "Make sure to adjust the following arguments to your setup:\n",
125
+ "\n",
126
+ "1. `--dataset.repo_id=YOUR_HF_USERNAME/YOUR_DATASET`: \n",
127
+ " Replace this with the Hugging Face Hub repo ID where your dataset is stored, e.g., `pepijn223/il_gym0`.\n",
128
+ "\n",
129
+ "2. `--batch_size=64`: means the model processes 64 training samples in parallel before doing one gradient update. Reduce this number if you have a GPU with low memory.\n",
130
+ "\n",
131
+ "3. `--output_dir=outputs/train/...`: \n",
132
+ " Directory where training logs and model checkpoints will be saved.\n",
133
+ "\n",
134
+ "4. `--job_name=...`: \n",
135
+ " A name for this training job, used for logging and Weights & Biases.\n",
136
+ "\n",
137
+ "5. `--policy.device=cuda`: \n",
138
+ " Use `cuda` if training on an NVIDIA GPU. Use `mps` for Apple Silicon, or `cpu` if no GPU is available.\n",
139
+ "\n",
140
+ "6. `--wandb.enable=true`: \n",
141
+ " Enables Weights & Biases for visualizing training progress. You must be logged in via `wandb login` before running this."
142
+ ]
143
+ },
144
+ {
145
+ "cell_type": "code",
146
+ "execution_count": null,
147
+ "metadata": {
148
+ "id": "ZO52lcQtxseE"
149
+ },
150
+ "outputs": [],
151
+ "source": [
152
+ "!cd lerobot && python lerobot/scripts/train.py \\\n",
153
+ " --policy.path=lerobot/smolvla_base \\\n",
154
+ " --dataset.repo_id=${HF_USER}/mydataset \\\n",
155
+ " --batch_size=64 \\\n",
156
+ " --steps=20000 \\\n",
157
+ " --output_dir=outputs/train/my_smolvla \\\n",
158
+ " --job_name=my_smolvla_training \\\n",
159
+ " --policy.device=cuda \\\n",
160
+ " --wandb.enable=true"
161
+ ]
162
+ },
163
+ {
164
+ "cell_type": "markdown",
165
+ "metadata": {
166
+ "id": "2PBu7izpxseF"
167
+ },
168
+ "source": [
169
+ "## Login into Hugging Face Hub\n",
170
+ "Now after training is done login into the Hugging Face hub and upload the last checkpoint"
171
+ ]
172
+ },
173
+ {
174
+ "cell_type": "code",
175
+ "execution_count": null,
176
+ "metadata": {
177
+ "id": "8yu5khQGIHi6"
178
+ },
179
+ "outputs": [],
180
+ "source": [
181
+ "!huggingface-cli login"
182
+ ]
183
+ },
184
+ {
185
+ "cell_type": "code",
186
+ "execution_count": null,
187
+ "metadata": {
188
+ "id": "zFMLGuVkH7UN"
189
+ },
190
+ "outputs": [],
191
+ "source": [
192
+ "!huggingface-cli upload ${HF_USER}/my_smolvla \\\n",
193
+ " /content/lerobot/outputs/train/my_smolvla/checkpoints/last/pretrained_model"
194
+ ]
195
+ }
196
+ ],
197
+ "metadata": {
198
+ "accelerator": "GPU",
199
+ "colab": {
200
+ "gpuType": "A100",
201
+ "machine_shape": "hm",
202
+ "provenance": []
203
+ },
204
+ "kernelspec": {
205
+ "display_name": "Python 3",
206
+ "name": "python3"
207
+ },
208
+ "language_info": {
209
+ "name": "python"
210
+ }
211
+ },
212
+ "nbformat": 4,
213
+ "nbformat_minor": 0
214
+ }
README.md ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pipeline_tag: robotics
3
+ tags:
4
+ - smolvla
5
+ library_name: lerobot
6
+ datasets:
7
+ - lerobot/svla_so101_pickplace
8
+ ---
9
+
10
+ ## SmolVLA: A vision-language-action model for affordable and efficient robotics
11
+
12
+ Resources and technical documentation:
13
+
14
+ [SmolVLA Paper](https://huggingface.co/papers/2506.01844)
15
+
16
+ [SmolVLA Blogpost](https://huggingface.co/blog/smolvla)
17
+
18
+ [Code](https://github.com/huggingface/lerobot/blob/main/lerobot/common/policies/smolvla/modeling_smolvla.py)
19
+
20
+ [Train using Google Colab Notebook](https://colab.research.google.com/github/huggingface/notebooks/blob/main/lerobot/training-smolvla.ipynb#scrollTo=ZO52lcQtxseE)
21
+
22
+ [SmolVLA HF Documentation](https://huggingface.co/docs/lerobot/smolvla)
23
+
24
+ Designed by Hugging Face.
25
+
26
+ This model has 450M parameters in total.
27
+ You can use inside the [LeRobot library](https://github.com/huggingface/lerobot).
28
+
29
+ Before proceeding to the next steps, you need to properly install the environment by following [Installation Guide](https://huggingface.co/docs/lerobot/installation) on the docs.
30
+
31
+ Install smolvla extra dependencies:
32
+ ```bash
33
+ pip install -e ".[smolvla]"
34
+ ```
35
+
36
+ Example of finetuning the smolvla pretrained model (`smolvla_base`):
37
+ ```bash
38
+ python lerobot/scripts/train.py \
39
+ --policy.path=lerobot/smolvla_base \
40
+ --dataset.repo_id=lerobot/svla_so101_pickplace \
41
+ --batch_size=64 \
42
+ --steps=20000 \
43
+ --output_dir=outputs/train/my_smolvla \
44
+ --job_name=my_smolvla_training \
45
+ --policy.device=cuda \
46
+ --wandb.enable=true
47
+ ```
48
+
49
+ Example of finetuning the smolvla neural network with pretrained VLM and action expert
50
+ intialized from scratch:
51
+ ```bash
52
+ python lerobot/scripts/train.py \
53
+ --dataset.repo_id=lerobot/svla_so101_pickplace \
54
+ --batch_size=64 \
55
+ --steps=200000 \
56
+ --output_dir=outputs/train/my_smolvla \
57
+ --job_name=my_smolvla_training \
58
+ --policy.device=cuda \
59
+ --wandb.enable=true
60
+ ```
collage_small.gif ADDED

Git LFS Details

  • SHA256: c43f022bf1fdfbac82841ef95c7a99a7ead13ea67f2a7202f2fe57148f352c83
  • Pointer size: 132 Bytes
  • Size of remote file: 8.01 MB
config.json ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "type": "smolvla",
3
+ "n_obs_steps": 1,
4
+ "input_features": {
5
+ "observation.state": {
6
+ "type": "STATE",
7
+ "shape": [
8
+ 6
9
+ ]
10
+ },
11
+ "observation.images.camera1": {
12
+ "type": "VISUAL",
13
+ "shape": [
14
+ 3,
15
+ 256,
16
+ 256
17
+ ]
18
+ },
19
+ "observation.images.camera2": {
20
+ "type": "VISUAL",
21
+ "shape": [
22
+ 3,
23
+ 256,
24
+ 256
25
+ ]
26
+ },
27
+ "observation.images.camera3": {
28
+ "type": "VISUAL",
29
+ "shape": [
30
+ 3,
31
+ 256,
32
+ 256
33
+ ]
34
+ }
35
+ },
36
+ "output_features": {
37
+ "action": {
38
+ "type": "ACTION",
39
+ "shape": [
40
+ 6
41
+ ]
42
+ }
43
+ },
44
+ "device": "cuda",
45
+ "use_amp": false,
46
+ "push_to_hub": true,
47
+ "repo_id": null,
48
+ "private": null,
49
+ "tags": null,
50
+ "license": null,
51
+ "chunk_size": 50,
52
+ "n_action_steps": 50,
53
+ "normalization_mapping": {
54
+ "VISUAL": "IDENTITY",
55
+ "STATE": "MEAN_STD",
56
+ "ACTION": "MEAN_STD"
57
+ },
58
+ "max_state_dim": 32,
59
+ "max_action_dim": 32,
60
+ "resize_imgs_with_padding": [
61
+ 512,
62
+ 512
63
+ ],
64
+ "empty_cameras": 0,
65
+ "adapt_to_pi_aloha": false,
66
+ "use_delta_joint_actions_aloha": false,
67
+ "tokenizer_max_length": 48,
68
+ "num_steps": 10,
69
+ "use_cache": true,
70
+ "freeze_vision_encoder": true,
71
+ "train_expert_only": true,
72
+ "train_state_proj": true,
73
+ "optimizer_lr": 0.0001,
74
+ "optimizer_betas": [
75
+ 0.9,
76
+ 0.95
77
+ ],
78
+ "optimizer_eps": 1e-08,
79
+ "optimizer_weight_decay": 1e-10,
80
+ "optimizer_grad_clip_norm": 10,
81
+ "scheduler_warmup_steps": 1000,
82
+ "scheduler_decay_steps": 30000,
83
+ "scheduler_decay_lr": 2.5e-06,
84
+ "vlm_model_name": "HuggingFaceTB/SmolVLM2-500M-Video-Instruct",
85
+ "load_vlm_weights": true,
86
+ "add_image_special_tokens": false,
87
+ "attention_mode": "cross_attn",
88
+ "prefix_length": 0,
89
+ "pad_language_to": "max_length",
90
+ "num_expert_layers": 0,
91
+ "num_vlm_layers": 16,
92
+ "self_attn_every_n_layers": 2,
93
+ "expert_width_multiplier": 0.75,
94
+ "min_period": 0.004,
95
+ "max_period": 4.0
96
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:979445bcff442b0e95e5187dd947db3324a14d737477fa4828323337d27e25df
3
+ size 906712520
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
+ 6
13
+ ]
14
+ }
15
+ },
16
+ "norm_map": {
17
+ "VISUAL": "IDENTITY",
18
+ "STATE": "MEAN_STD",
19
+ "ACTION": "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:490ab239d96e263687c0b2e386a0afbc235a2eceb9857c36ed32f2f162a3e7c8
3
+ size 640
policy_preprocessor.json ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": "smolvla_new_line_processor",
16
+ "config": {}
17
+ },
18
+ {
19
+ "registry_name": "tokenizer_processor",
20
+ "config": {
21
+ "max_length": 48,
22
+ "task_key": "task",
23
+ "padding_side": "right",
24
+ "padding": "max_length",
25
+ "truncation": true,
26
+ "tokenizer_name": "HuggingFaceTB/SmolVLM2-500M-Video-Instruct"
27
+ }
28
+ },
29
+ {
30
+ "registry_name": "device_processor",
31
+ "config": {
32
+ "device": "cuda",
33
+ "float_dtype": null
34
+ }
35
+ },
36
+ {
37
+ "registry_name": "normalizer_processor",
38
+ "config": {
39
+ "eps": 1e-08,
40
+ "features": {
41
+ "observation.state": {
42
+ "type": "STATE",
43
+ "shape": [
44
+ 6
45
+ ]
46
+ },
47
+ "observation.image2": {
48
+ "type": "VISUAL",
49
+ "shape": [
50
+ 3,
51
+ 256,
52
+ 256
53
+ ]
54
+ },
55
+ "observation.image": {
56
+ "type": "VISUAL",
57
+ "shape": [
58
+ 3,
59
+ 256,
60
+ 256
61
+ ]
62
+ },
63
+ "observation.image3": {
64
+ "type": "VISUAL",
65
+ "shape": [
66
+ 3,
67
+ 256,
68
+ 256
69
+ ]
70
+ },
71
+ "action": {
72
+ "type": "ACTION",
73
+ "shape": [
74
+ 6
75
+ ]
76
+ }
77
+ },
78
+ "norm_map": {
79
+ "VISUAL": "IDENTITY",
80
+ "STATE": "MEAN_STD",
81
+ "ACTION": "MEAN_STD"
82
+ }
83
+ },
84
+ "state_file": "policy_preprocessor_step_5_normalizer_processor.safetensors"
85
+ }
86
+ ]
87
+ }
policy_preprocessor_step_5_normalizer_processor.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:490ab239d96e263687c0b2e386a0afbc235a2eceb9857c36ed32f2f162a3e7c8
3
+ size 640