diff --git a/src/lerobot/policies/pretrained.py b/src/lerobot/policies/pretrained.py index 5e8c3613d..a69487f3f 100644 --- a/src/lerobot/policies/pretrained.py +++ b/src/lerobot/policies/pretrained.py @@ -336,6 +336,9 @@ class PreTrainedPolicy(nn.Module, HubMixin, abc.ABC): context = _build_card_context( cfg, dataset_repo_id, self.config.input_features, self.config.output_features ) + # Used by the template to pre-fill commands and the "Fine-tuned from" line. + context["policy_repo_id"] = getattr(self.config, "repo_id", None) + context["base_model"] = base_model_mapping.get(model_type) template_card = ( files("lerobot.templates").joinpath("lerobot_modelcard_template.md").read_text(encoding="utf-8") diff --git a/src/lerobot/templates/lerobot_modelcard_template.md b/src/lerobot/templates/lerobot_modelcard_template.md index 7b33bfe23..6ecda06c9 100644 --- a/src/lerobot/templates/lerobot_modelcard_template.md +++ b/src/lerobot/templates/lerobot_modelcard_template.md @@ -55,6 +55,13 @@ This is a **{{ model_name }}** policy trained with [LeRobot](https://github.com/

{% endif %} + + This policy has been trained and pushed to the Hub using [LeRobot](https://github.com/huggingface/lerobot). {% set policy_docs = { "act": "act", @@ -79,7 +86,8 @@ This policy has been trained and pushed to the Hub using [LeRobot](https://githu ## Model Details - **License:** {{ license | default("\[More Information Needed]", true) }} -{% if robot_type %}- **Robot type:** `{{ robot_type }}` +{% if base_model %}- **Fine-tuned from:** [{{ base_model }}](https://huggingface.co/{{ base_model }}) +{% endif %}{% if robot_type %}- **Robot type:** `{{ robot_type }}` {% endif %}{% if cameras %}- **Cameras:** {% for camera in cameras %}`{{ camera }}`{% if not loop.last %}, {% endif %}{% endfor %} {% endif %} {% if input_features or output_features %} @@ -136,45 +144,68 @@ New to LeRobot? These guides cover the full workflow: - **[Record data & train a policy](https://huggingface.co/docs/lerobot/en/il_robots)** — the end-to-end imitation-learning walkthrough. - **[CLI cheat-sheet](https://huggingface.co/docs/lerobot/main/en/cheat-sheet)** — quick reference for the `lerobot-*` commands. -The short version to train and run this policy: +The short version to run and train this policy: -### Train from scratch +### Run the policy on your robot + +```bash +lerobot-rollout \ + --strategy.type=base \ + --robot.type={{ robot_type | default("", true) }} \ + --robot.port= \ + --robot.cameras="{ : {type: opencv, index_or_path: , width: 640, height: 480, fps: 30}, : {type: opencv, index_or_path: , width: 640, height: 480, fps: 30}}" \ + --policy.path={{ policy_repo_id | default("/", true) }} \ + --task="{% if dataset and dataset.tasks %}{{ dataset.tasks[0] }}{% else %}{% endif %}" \ + --duration=60 +``` + +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. + +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). + +{% if base_model %}### Train your own policy + +This policy type is usually fine-tuned from the pretrained base model [{{ base_model }}](https://huggingface.co/{{ base_model }}): + +```bash +lerobot-train \ + --dataset.repo_id=${HF_USER}/ \ + --policy.path={{ base_model }} \ + --output_dir=outputs/train/ \ + --job_name=lerobot_training \ + --policy.device=cuda \ + --policy.repo_id=${HF_USER}/ \ + --wandb.enable=true +``` +{% else %}### Train your own policy ```bash lerobot-train \ --dataset.repo_id=${HF_USER}/ \ --policy.type={{ model_name }} \ - --output_dir=outputs/train/ \ + --output_dir=outputs/train/ \ --job_name=lerobot_training \ --policy.device=cuda \ - --policy.repo_id=${HF_USER}/ \ + --policy.repo_id=${HF_USER}/ \ --wandb.enable=true ``` - -_Writes checkpoints to `outputs/train//checkpoints/`._ - -### Evaluate the policy/run inference - -```bash -lerobot-rollout \ - --strategy.type=base \ - --robot.type= \ - --robot.port= \ - --robot.cameras="{ : {type: opencv, index_or_path: , width: 640, height: 480, fps: 30}, : {type: opencv, index_or_path: , width: 640, height: 480, fps: 30}}" \ - --policy.path=/ \ - --task="" \ - --duration=60 -``` - -Replace every `<...>` placeholder with your own values. The `--robot.type`, `--robot.port`, and camera names/indices must match the robot and observation keys this policy was trained on, and `--task` should describe what you want the policy to do. - -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). +{% endif %} +_Writes checkpoints to `outputs/train//checkpoints/`._ --- ## Evaluation - + _No evaluation results have been provided for this policy yet._