Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unit1-last part, need to add imports , and gymnasyum version downgrade #554

Open
antonagafonov opened this issue Jul 27, 2024 · 0 comments

Comments

@antonagafonov
Copy link

need to add
!pip install gymnasium==0.29.1 pickle5
from stable_baselines3 import PPO

before loading the model from hugging face :

from huggingface_sb3 import load_from_hub
from stable_baselines3 import PPO
repo_id = "ToonAga/ppo-LunarLander-v2" # The repo_id
filename = "ppo-LunarLander-v2.zip" # The model filename.zip

When the model was trained on Python 3.8 the pickle protocol is 5

But Python 3.6, 3.7 use protocol 4

In order to get compatibility we need to:

1. Install pickle5 (we done it at the beginning of the colab)

2. Create a custom empty object we pass as parameter to PPO.load()

custom_objects = {
"learning_rate": 0.0,
"lr_schedule": lambda _: 0.0,
"clip_range": lambda _: 0.0,
}

checkpoint = load_from_hub(repo_id, filename)
model = PPO.load(checkpoint, custom_objects=custom_objects, print_system_info=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant