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

Update run_hw1.ipynb #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

goodboychan
Copy link

@goodboychan goodboychan commented Dec 10, 2021

Current mujoco_py supports mujoco 2.1.0, not 2.0.0.
Workaround is #4
So it needs to change file paths to modify.

Current `mujoco_py` supports mujoco 2.1.0, not 2.0.0.
So it needs to change file paths to modify.
@Paprikaiec
Copy link

I change the file paths as you suggested, but when I do dagger, I couldn't log video, I suppose it is the difference between 2.1.0 and 2.0.0. So, I think what we need is mujoco 2.0.0.
This is what my error message:

TypeError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/tensorboardX/summary.py in make_video(tensor, fps)
303 try: # older version of moviepy does not support progress_bar argument.
--> 304 clip.write_gif(filename, verbose=False, progress_bar=False)
305 except TypeError:

TypeError: write_gif() got an unexpected keyword argument 'progress_bar'

During handling of the above exception, another exception occurred:

AttributeError Traceback (most recent call last)
21 frames
in ()
2 print(args.logdir)
3 trainer = BC_Trainer(args)
----> 4 trainer.run_training_loop()

in run_training_loop(self)
40 eval_policy=self.rl_trainer.agent.actor,
41 relabel_with_expert=self.params['do_dagger'],
---> 42 expert_policy=self.loaded_expert_policy,
43 )

/content/gdrive/My Drive/cs285_f2021/homework_fall2021/hw1/cs285/infrastructure/rl_trainer.py in run_training_loop(self, n_iter, collect_policy, eval_policy, initial_expertdata, relabel_with_expert, start_relabel_with_expert, expert_policy)
132 print('\nBeginning logging procedure...')
133 self.perform_logging(
--> 134 itr, paths, eval_policy, train_video_paths, training_logs)
135
136 if self.params['save_params']:

/content/gdrive/My Drive/cs285_f2021/homework_fall2021/hw1/cs285/infrastructure/rl_trainer.py in perform_logging(self, itr, paths, eval_policy, train_video_paths, training_logs)
232 print('\nSaving train rollouts as videos...')
233 self.logger.log_paths_as_videos(train_video_paths, itr, fps=self.fps, max_videos_to_save=MAX_NVIDEO,
--> 234 video_title='train_rollouts')
235 self.logger.log_paths_as_videos(eval_video_paths, itr, fps=self.fps,max_videos_to_save=MAX_NVIDEO,
236 video_title='eval_rollouts')

/content/gdrive/My Drive/cs285_f2021/homework_fall2021/hw1/cs285/infrastructure/logger.py in log_paths_as_videos(self, paths, step, max_videos_to_save, fps, video_title)
47 # log videos to tensorboard event file
48 videos = np.stack(videos[:max_videos_to_save], 0)
---> 49 self.log_video(videos, video_title, step, fps=fps)
50
51 def log_figures(self, figure, name, step, phase):

/content/gdrive/My Drive/cs285_f2021/homework_fall2021/hw1/cs285/infrastructure/logger.py in log_video(self, video_frames, name, step, fps)
25 def log_video(self, video_frames, name, step, fps=10):
26 assert len(video_frames.shape) == 5, "Need [N, T, C, H, W] input tensor for video logging!"
---> 27 self._summ_writer.add_video('{}'.format(name), video_frames, step, fps=fps)
28
29 def log_paths_as_videos(self, paths, step, max_videos_to_save=2, fps=10, video_title='video'):

/usr/local/lib/python3.7/dist-packages/tensorboardX/writer.py in add_video(self, tag, vid_tensor, global_step, fps, walltime)
669 """
670 self._get_file_writer().add_summary(
--> 671 video(tag, vid_tensor, fps), global_step, walltime)
672
673 def add_audio(self, tag, snd_tensor, global_step=None, sample_rate=44100, walltime=None):

/usr/local/lib/python3.7/dist-packages/tensorboardX/summary.py in video(tag, tensor, fps)
277 tensor = (tensor * 255.0).astype(np.uint8)
278
--> 279 video = make_video(tensor, fps)
280 return Summary(value=[Summary.Value(tag=tag, image=video)])
281

/usr/local/lib/python3.7/dist-packages/tensorboardX/summary.py in make_video(tensor, fps)
304 clip.write_gif(filename, verbose=False, progress_bar=False)
305 except TypeError:
--> 306 clip.write_gif(filename, verbose=False)
307
308 with open(filename, 'rb') as f:

in write_gif(self, filename, fps, program, opt, fuzz, verbose, loop, dispose, colors, tempfiles, logger)

/usr/local/lib/python3.7/dist-packages/moviepy/decorators.py in requires_duration(f, clip, *a, **k)
52 raise ValueError("Attribute 'duration' not set")
53 else:
---> 54 return f(clip, *a, **k)
55
56

in write_gif(self, filename, fps, program, opt, fuzz, verbose, loop, dispose, colors, tempfiles, logger)

/usr/local/lib/python3.7/dist-packages/moviepy/decorators.py in convert_masks_to_RGB(f, clip, *a, **k)
20 if clip.ismask:
21 clip = clip.to_RGB()
---> 22 return f(clip, *a, **k)
23
24 @decorator.decorator

/usr/local/lib/python3.7/dist-packages/moviepy/video/VideoClip.py in write_gif(self, filename, fps, program, opt, fuzz, verbose, loop, dispose, colors, tempfiles, logger)
451 write_gif_with_image_io(self, filename, fps=fps, opt=opt, loop=loop,
452 verbose=verbose, colors=colors,
--> 453 logger=logger)
454 elif tempfiles:
455 # convert imageio opt variable to something that can be used with

/usr/local/lib/python3.7/dist-packages/moviepy/video/io/gif_writers.py in write_gif_with_image_io(clip, filename, fps, opt, loop, colors, verbose, logger)
276 quantizer=quantizer,
277 palettesize=colors,
--> 278 loop=loop
279 )
280 logger(message='MoviePy - Building file %s with imageio.' % filename)

/usr/local/lib/python3.7/dist-packages/imageio/core/functions.py in get_writer(uri, format, mode, **kwargs)
178 kwargs : ...
179 Further keyword arguments are passed to the writer. See :func:.help
--> 180 to see what arguments are available for a particular format.
181 """
182

/usr/local/lib/python3.7/dist-packages/imageio/core/format.py in search_write_format(self, request)
712 # but the legacy API doesn't raise
713 return None
--> 714
715 def get_format_names(self):
716 """Get the names of all registered formats."""

/usr/local/lib/python3.7/dist-packages/imageio/core/format.py in can_write(self, request)
200 def _can_write(self, request): # pragma: no cover
201 return None # Plugins must implement this
--> 202
203 # -----
204

/usr/local/lib/python3.7/dist-packages/imageio/plugins/pillow.py in _can_write(self, request)
106 return EXIF_ORIENTATION[orientation]
107
--> 108
109 class PillowPlugin(object):
110 def init(self, request: Request):

/usr/local/lib/python3.7/dist-packages/imageio/plugins/pillow.py in _init_pillow(self)
91
92 # -1 if the mode has color channel, 0 otherwise
---> 93 axis = -2 if _is_multichannel(mode) else -1
94
95 EXIF_ORIENTATION = {

/usr/local/lib/python3.7/dist-packages/PIL/Image.py in preinit()
364 except ImportError:
365 pass
--> 366 try:
367 from . import PpmImagePlugin
368

/usr/local/lib/python3.7/dist-packages/PIL/JpegImagePlugin.py in ()
42 import warnings
43
---> 44 from . import Image, ImageFile, TiffImagePlugin
45 from ._binary import i16be as i16
46 from ._binary import i32be as i32

/usr/local/lib/python3.7/dist-packages/PIL/TiffImagePlugin.py in ()
416
417
--> 418 class ImageFileDirectory_v2(MutableMapping):
419 """This class represents a TIFF tag directory. To speed things up, we
420 don't decode tags unless they're asked for.

/usr/local/lib/python3.7/dist-packages/PIL/TiffImagePlugin.py in ImageFileDirectory_v2()
693 (TiffTags.FLOAT, "f", "float"),
694 (TiffTags.DOUBLE, "d", "double"),
--> 695 (TiffTags.IFD, "L", "long"),
696 ],
697 )

AttributeError: module 'PIL.TiffTags' has no attribute 'IFD'

I think instead of
!git clone https://github.com/openai/mujoco-py.git,
we could
!git clone -b v2.0.2.2 https://github.com/openai/mujoco-py.git
according to the requirements.txt
But this still couldn't work, does anyone know how to install mujoco 2.0.2.2

@goodboychan
Copy link
Author

I think it's related on PIL library while making GIF files.
Could you try this?

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

Successfully merging this pull request may close these issues.

2 participants