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

Adding save and load support #8

Open
rimvydasrub opened this issue Jun 10, 2024 · 2 comments
Open

Adding save and load support #8

rimvydasrub opened this issue Jun 10, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@rimvydasrub
Copy link
Collaborator

Currently, its not straightforward how the save and load functionality works for the environment. This functionality is valuable for:

  • replication of the results as just setting random seed (random.seed(###)) is not sufficient to fix randomness in the system
  • go generate environments and do feature prepossessing offline so that training and inference can be done in a faster manner.
@rimvydasrub rimvydasrub added the enhancement New feature or request label Jun 10, 2024
@peterdavidfagan
Copy link
Owner

peterdavidfagan commented Jun 10, 2024

Can you provide further details, what are you asking for in the API? What are you looking to save/load?

Reproducibility and random seeds is something I can look into at some point.

@rimvydasrub
Copy link
Collaborator Author

If you run the following program

import random

from PIL import Image
import numpy as np
import torch
from mujoco_robot_environments.tasks.rearrangement import RearrangementEnv

# setting random seeds
random.seed(0)

env = RearrangementEnv(viewer=True)
env.reset()

obs = env._compute_observation()['overhead_camera/rgb']
obs_img = Image.fromarray(obs)
obs_img.save('obs.png')

env.close()

you get two different results
obs
obs-1

After inspection, this is because np.random.seed is not set explicitly. I can now replicate environments with the same seed.

Generally, for the API functionality, is something like this possible?

from mujoco_robot_environments.tasks.rearrangement import RearrangementEnv

env = RearrangementEnv(viewer=True)
env.reset()

# saving the environment
env.save("save_file_name")

# loading the environment
env = RearrangementEnv.load("save_file_name")

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

No branches or pull requests

2 participants