I tired to load a model using stable-baselines3 in colab use the following code:
!pip install stable-baselines3[extra]
from stable_baselines3 import DQN
from stable_baselines3.common.vec_env import DummyVecEnv
MODEL_PATH = "/content/drive/MyDrive/Reinforcement_Learning/SpaceInvaders/model_9"
env = gym.make("SpaceInvaders-v0")
env = DummyVecEnv([lambda: env])
I received a warning after create the envirnoment:
/usr/local/lib/python3.7/dist-packages/gym/logger.py:30: UserWarning: WARN: obs_type "image" should be replaced with the image type, one of: rgb, grayscale
print("%s: %s" % ("INFO", msg % args), file=sys.stderr)
Then I tried to load my pre-trained model
model = DQN.load(MODEL_PATH,env=env)
But received the following error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-15-edceae40609f> in <module>()
----> 1 model = DQN.load(MODEL_PATH,env=env)
2 frames
/usr/local/lib/python3.7/dist-packages/gym/spaces/box.py in __eq__(self, other)
138 return sample.astype(self.dtype)
139
--> 140 def contains(self, x):
141 if not isinstance(x, np.ndarray):
142 logger.warn("Casting input x to numpy array.")
AttributeError: 'Box' object has no attribute 'shape'
I tried the same code in my local Linux, and it works fine.
I would greatly appreciate any help or advice.