Instructions to use devkumarhf/ur7e-sac-line-following with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- stable-baselines3
How to use devkumarhf/ur7e-sac-line-following with stable-baselines3:
from huggingface_sb3 import load_from_hub checkpoint = load_from_hub( repo_id="devkumarhf/ur7e-sac-line-following", filename="{MODEL FILENAME}.zip", ) - Notebooks
- Google Colab
- Kaggle
Download checkpoint.py from devkumarhf/ur7e-sac-line-following: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/devkumarhf/ur7e-sac-line-following/resolve/main/checkpoint.py
- Command line
-
hf download hf://devkumarhf/ur7e-sac-line-following/checkpoint.py
-
curl -L -o checkpoint.py https://huggingface.co/devkumarhf/ur7e-sac-line-following/resolve/main/checkpoint.py
1.21 kB
| """Load the upstream SAC checkpoint on CPU, discarding saved training state. | |
| The original archive includes NumPy-2 pickled observations. Override these | |
| unused training buffers and reconstruct the documented Gymnasium spaces to | |
| support NumPy 1.26 as well. Learned tensors and architecture are unchanged. | |
| Only load trusted original checkpoints. For portable inference use policy.py. | |
| """ | |
| from pathlib import Path | |
| import numpy as np | |
| from gymnasium import spaces | |
| from stable_baselines3 import SAC | |
| def checkpoint_path(path=None): | |
| if path is not None: | |
| return Path(path) | |
| default = Path(__file__).with_name('best_model.zip') | |
| if not default.exists(): | |
| default = Path(__file__).resolve().parents[2]/'line-follower-simulation-simple/models_traj/best_model.zip' | |
| return default | |
| def load_model(path=None): | |
| return SAC.load(checkpoint_path(path),device='cpu',custom_objects={ | |
| 'observation_space':spaces.Box(low=-np.inf,high=np.inf,shape=(29,),dtype=np.float32), | |
| 'action_space':spaces.Box(low=-1,high=1,shape=(6,),dtype=np.float32), | |
| '_last_obs':None,'_last_episode_starts':None,'_last_original_obs':None, | |
| 'ep_info_buffer':None,'ep_success_buffer':None, | |
| }) | |