Instructions to use NoesisLab/LITOperator with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LeRobot
How to use NoesisLab/LITOperator with LeRobot:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Download demo/tree_io.py from NoesisLab/LITOperator: direct link, hf CLI and curl.
- Browser
- Download file 1.84 kB
-
https://huggingface.co/NoesisLab/LITOperator/resolve/main/demo/tree_io.py
- Command line
-
hf download hf://NoesisLab/LITOperator/demo/tree_io.py
-
curl -L -o tree_io.py https://huggingface.co/NoesisLab/LITOperator/resolve/main/demo/tree_io.py
1.84 kB
| #!/usr/bin/env python3 | |
| """tree_io.py — read a pretrained LIT tree snapshot with numpy. | |
| The C safetensors loader rejects checkpoints that contain duplicate | |
| keys, which an open-set tree produces. The snapshot arrays are standard | |
| safetensors tensors, so the render demos read them directly. | |
| """ | |
| import json | |
| import os | |
| import struct | |
| import sys | |
| import numpy as np | |
| ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| sys.path.insert(0, os.path.join(ROOT, "sandbox", "lerobot_host")) | |
| CKPT = os.path.join(ROOT, "sandbox", "lerobot_host", | |
| "community_open_pretrain.safetensors") | |
| REPO = "lerobot/community_dataset_v3" | |
| SUB = "00ri/so100_battery" | |
| LINK = (0.10, 0.12, 0.12, 0.08) | |
| _DT = {"U32": "<u4", "U64": "<u8", "U8": "u1"} | |
| def load_snapshot(path=CKPT): | |
| with open(path, "rb") as f: | |
| hlen = struct.unpack("<Q", f.read(8))[0] | |
| hdr = json.loads(f.read(hlen)) | |
| data = f.read() | |
| def tensor(name): | |
| h = hdr[name] | |
| dt = _DT[h["dtype"]] | |
| a = h["data_offsets"][0] | |
| n = int(np.prod(h["shape"])) | |
| return np.frombuffer(data, dtype=dt, count=n, offset=a).reshape( | |
| h["shape"]) | |
| return {k: tensor(k) for k in hdr if k != "__metadata__"} | |
| def children_map(parent): | |
| children = {} | |
| for i in range(1, len(parent)): | |
| children.setdefault(int(parent[i]), []).append(i) | |
| return children | |
| def chain_from(children, g, start, limit=4000): | |
| """Follow g == 0 (data) children from a start node.""" | |
| cur = start | |
| path = [] | |
| for _ in range(limit): | |
| ch = [c for c in children.get(cur, []) if int(g[c]) == 0] | |
| if not ch: | |
| break | |
| nxt = min(ch) | |
| path.append(nxt) | |
| cur = nxt | |
| return path | |
| def data_path(parent, g, limit=4000): | |
| return chain_from(children_map(parent), g, 0, limit) | |