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

Cannot run trained v3 model #189

Open
IsraCode opened this issue Nov 7, 2024 · 4 comments
Open

Cannot run trained v3 model #189

IsraCode opened this issue Nov 7, 2024 · 4 comments

Comments

@IsraCode
Copy link

IsraCode commented Nov 7, 2024

I face this error:
➜ baselines git:(master) ✗ python3 run_pretrained_interactive.py
UserWarning: Using SDL2 binaries from pysdl2-dll 2.28.0
6697 pyboy.pyboy WARNING The emulation speed might not be accurate when speed-target is higher than 5

loading checkpoint
Wrapping the env with a Monitor wrapper
Wrapping the env in a DummyVecEnv.
Wrapping the env in a VecTransposeImage.
Traceback (most recent call last):
File "/Users/???/Programing/Fun/PokemonRedExperiments/baselines/run_pretrained_interactive.py", line 47, in
model = PPO.load(file_name, env=env, custom_objects={'lr_schedule': 0, 'clip_range': 0})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/stable_baselines3/common/base_class.py", line 716, in load
check_for_correct_spaces(env, data["observation_space"], data["action_space"])
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/stable_baselines3/common/utils.py", line 229, in check_for_correct_spaces
raise ValueError(f"Observation spaces do not match: {observation_space} != {env.observation_space}")
ValueError: Observation spaces do not match: Dict('screen': Box(0, 255, (72, 80), uint8)) != Box(0, 255, (3, 128, 40), uint8)
6820 pyboy.pyboy INFO ###########################
6820 pyboy.pyboy INFO # Emulator is turning off #
6820 pyboy.pyboy INFO ###########################

@IsraCode
Copy link
Author

IsraCode commented Nov 7, 2024

fixed it.
since i guess more people will face it, the fix i did:

(the diffs:)
baseline_fast_v3.py

  from red_gym_env_v3_minimal import PokeRedEnv
  ...
  def make_env(rank, seed=0):
      def _init():
          env = PokeRedEnv('../PokemonRed.gb', '../has_pokedex_nballs.state')
          env.reset(seed=(seed + rank))
          return env
      set_random_seed(seed)
      return _init
   ...
    env = make_env(0)() 

red_gym_env_v3_minimal.py

class PokeRedEnv(Env):
  def __init__(
          self, gb_path, init_state,
          max_steps=2048*8, headless=False

@PWhiddy
Copy link
Owner

PWhiddy commented Nov 7, 2024

Glad you were able to get it working!
I should note, the v3 script was an experiment to cut out a bunch of observations and rewards, but it did not get nearly as far as the other versions. the best / latest version in this repo is in the v2 folder at the top level.

@IsraCode
Copy link
Author

IsraCode commented Nov 7, 2024

oh sh!t

@IsraCode
Copy link
Author

IsraCode commented Nov 7, 2024

Glad you were able to get it working! I should note, the v3 script was an experiment to cut out a bunch of observations and rewards, but it did not get nearly as far as the other versions. the best / latest version in this repo is in the v2 folder at the top level.

you mean, v2/baseline_fast_v2.py is the best one, and baseline/baseline_fast_v2.py in not the best one?

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

2 participants