Instructions to use djduecaster/dfreq-tug with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Microduck
How to use djduecaster/dfreq-tug with Microduck:
# Replace SLOT with the slot specified in the model card (walk, stand, sitstand, ground_pick, kick_left, kick_right, roulade). sudo robotctl policy load SLOT djduecaster/dfreq-tug
- Notebooks
- Google Colab
- Kaggle
Download REPRODUCE.py from djduecaster/dfreq-tug: direct link, hf CLI and curl.
- Browser
- Download file 1.37 kB
-
https://huggingface.co/djduecaster/dfreq-tug/resolve/main/REPRODUCE.py
- Command line
-
hf download hf://djduecaster/dfreq-tug/REPRODUCE.py
-
curl -L -o REPRODUCE.py https://huggingface.co/djduecaster/dfreq-tug/resolve/main/REPRODUCE.py
1.37 kB
| """Regenerate the original controller and check exact bytes/outputs; no simulator/network.""" | |
| from pathlib import Path | |
| import hashlib,importlib.util,json,tempfile | |
| import numpy as np | |
| import onnxruntime as ort | |
| root=Path(__file__).resolve().parent | |
| spec=importlib.util.spec_from_file_location('controller_source',root/'controller_source.py');source=importlib.util.module_from_spec(spec);spec.loader.exec_module(source) | |
| params=json.loads((root/'parameters.json').read_text());manifest=json.loads((root/'manifest.json').read_text()) | |
| with tempfile.TemporaryDirectory(prefix='tug-reproduce-') as tmp: | |
| p=Path(tmp)/'policy.onnx';source.build(p,params) | |
| assert hashlib.sha256(p.read_bytes()).hexdigest()==manifest['provenance']['model_sha256'] | |
| assert p.read_bytes()==(root/'policy.onnx').read_bytes() | |
| options=ort.SessionOptions();options.intra_op_num_threads=1 | |
| session=ort.InferenceSession(str(p),options,providers=['CPUExecutionProvider']) | |
| samples=np.random.default_rng(7).normal(0,.1,(100,61)).astype(np.float32);samples[:,5]=-1;samples[:,48]=-.3 | |
| out=np.vstack([session.run(None,{session.get_inputs()[0].name:s.reshape(1,61)})[0] for s in samples]) | |
| np.testing.assert_allclose(out,source.act(samples,params),atol=1e-7,rtol=1e-6) | |
| assert np.isfinite(out).all() | |
| print('Exact ONNX bytes reproduced; 100 inference inputs match source formula. No simulation or training run.') | |