Instructions to use v1tavitavita/lehome-residual-v4-global with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LeRobot
How to use v1tavitavita/lehome-residual-v4-global with LeRobot:
# See https://github.com/huggingface/lerobot?tab=readme-ov-file#installation for more details git clone https://github.com/huggingface/lerobot.git cd lerobot pip install -e .[smolvla]
# Launch finetuning on your dataset python lerobot/scripts/train.py \ --policy.path=v1tavitavita/lehome-residual-v4-global \ --dataset.repo_id=lerobot/svla_so101_pickplace \ --batch_size=64 \ --steps=20000 \ --output_dir=outputs/train/my_smolvla \ --job_name=my_smolvla_training \ --policy.device=cuda \ --wandb.enable=true
# Run the policy using the record function python -m lerobot.record \ --robot.type=so101_follower \ --robot.port=/dev/ttyACM0 \ # <- Use your port --robot.id=my_blue_follower_arm \ # <- Use your robot id --robot.cameras="{ front: {type: opencv, index_or_path: 8, width: 640, height: 480, fps: 30}}" \ # <- Use your cameras --dataset.single_task="Grasp a lego block and put it in the bin." \ # <- Use the same task description you used in your dataset recording --dataset.repo_id=HF_USER/dataset_name \ # <- This will be the dataset name on HF Hub --dataset.episode_time_s=50 \ --dataset.num_episodes=10 \ --policy.path=v1tavitavita/lehome-residual-v4-global - Notebooks
- Google Colab
- Kaggle
wrapper: module-level HF_HOME redirect to bundled cache
Browse files- residual_v4_global.py +35 -8
residual_v4_global.py
CHANGED
|
@@ -16,16 +16,43 @@ Optional:
|
|
| 16 |
from __future__ import annotations
|
| 17 |
|
| 18 |
import os
|
|
|
|
| 19 |
from pathlib import Path
|
| 20 |
-
from typing import Dict, Optional
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
|
| 31 |
class _ResidualActor(nn.Module):
|
|
|
|
| 16 |
from __future__ import annotations
|
| 17 |
|
| 18 |
import os
|
| 19 |
+
import sys
|
| 20 |
from pathlib import Path
|
|
|
|
| 21 |
|
| 22 |
+
# --- Module-level HF cache redirect (must run BEFORE transformers/huggingface_hub
|
| 23 |
+
# get imported transitively by lerobot_policy / smolvla). The evaluator commonly
|
| 24 |
+
# pre-sets HF_HOME to its own cache; we override unconditionally so the bundled
|
| 25 |
+
# SmolVLM2 weights at submission_models/hf_cache/ are used.
|
| 26 |
+
_backbone_env = os.environ.get("LEHOME_VLA_POLICY_PATH", "")
|
| 27 |
+
if _backbone_env:
|
| 28 |
+
_bundled_cache = Path(_backbone_env).parent / "hf_cache"
|
| 29 |
+
if _bundled_cache.exists():
|
| 30 |
+
os.environ["HF_HOME"] = str(_bundled_cache)
|
| 31 |
+
os.environ["TRANSFORMERS_CACHE"] = str(_bundled_cache / "hub")
|
| 32 |
+
os.environ["HF_HUB_CACHE"] = str(_bundled_cache / "hub")
|
| 33 |
+
# Also patch any already-imported huggingface_hub constants so cache
|
| 34 |
+
# lookups don't reuse stale values from a pre-import HF_HOME.
|
| 35 |
+
if "huggingface_hub.constants" in sys.modules:
|
| 36 |
+
_hc = sys.modules["huggingface_hub.constants"]
|
| 37 |
+
for _attr, _val in (
|
| 38 |
+
("HF_HOME", str(_bundled_cache)),
|
| 39 |
+
("HF_HUB_CACHE", str(_bundled_cache / "hub")),
|
| 40 |
+
("HUGGINGFACE_HUB_CACHE", str(_bundled_cache / "hub")),
|
| 41 |
+
):
|
| 42 |
+
if hasattr(_hc, _attr):
|
| 43 |
+
setattr(_hc, _attr, _val)
|
| 44 |
+
print(f"[residual_v4_global] HF_HOME -> {_bundled_cache}", flush=True)
|
| 45 |
+
# ----------------------------------------------------------------------------
|
| 46 |
+
|
| 47 |
+
from typing import Dict, Optional # noqa: E402
|
| 48 |
+
|
| 49 |
+
import numpy as np # noqa: E402
|
| 50 |
+
import torch # noqa: E402
|
| 51 |
+
from torch import nn # noqa: E402
|
| 52 |
+
|
| 53 |
+
from .base_policy import BasePolicy # noqa: E402
|
| 54 |
+
from .lerobot_policy import LeRobotPolicy # noqa: E402
|
| 55 |
+
from .registry import PolicyRegistry # noqa: E402
|
| 56 |
|
| 57 |
|
| 58 |
class _ResidualActor(nn.Module):
|