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
File size: 1,211 Bytes
1ce77ac 42d53eb 1ce77ac 42d53eb 1ce77ac | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | """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,
})
|