diff --git a/Dreamer/__pycache__/dreamers.cpython-37.pyc b/Dreamer/__pycache__/dreamers.cpython-37.pyc new file mode 100644 index 0000000..2edd63d Binary files /dev/null and b/Dreamer/__pycache__/dreamers.cpython-37.pyc differ diff --git a/Dreamer/__pycache__/env_tools.cpython-37.pyc b/Dreamer/__pycache__/env_tools.cpython-37.pyc new file mode 100644 index 0000000..bebf4fc Binary files /dev/null and b/Dreamer/__pycache__/env_tools.cpython-37.pyc differ diff --git a/Dreamer/__pycache__/models.cpython-37.pyc b/Dreamer/__pycache__/models.cpython-37.pyc new file mode 100644 index 0000000..2aafc9a Binary files /dev/null and b/Dreamer/__pycache__/models.cpython-37.pyc differ diff --git a/Dreamer/__pycache__/tools.cpython-37.pyc b/Dreamer/__pycache__/tools.cpython-37.pyc new file mode 100644 index 0000000..173b69b Binary files /dev/null and b/Dreamer/__pycache__/tools.cpython-37.pyc differ diff --git a/Dreamer/__pycache__/tools.cpython-38.pyc b/Dreamer/__pycache__/tools.cpython-38.pyc new file mode 100644 index 0000000..babb8e9 Binary files /dev/null and b/Dreamer/__pycache__/tools.cpython-38.pyc differ diff --git a/Dreamer/__pycache__/wrappers.cpython-37.pyc b/Dreamer/__pycache__/wrappers.cpython-37.pyc new file mode 100644 index 0000000..a86b4d2 Binary files /dev/null and b/Dreamer/__pycache__/wrappers.cpython-37.pyc differ diff --git a/Dreamer/__pycache__/wrappers.cpython-38.pyc b/Dreamer/__pycache__/wrappers.cpython-38.pyc new file mode 100644 index 0000000..562e5f9 Binary files /dev/null and b/Dreamer/__pycache__/wrappers.cpython-38.pyc differ diff --git a/Dreamer/dmc2gym/__pycache__/__init__.cpython-37.pyc b/Dreamer/dmc2gym/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..2a634fa Binary files /dev/null and b/Dreamer/dmc2gym/__pycache__/__init__.cpython-37.pyc differ diff --git a/Dreamer/dmc2gym/__pycache__/natural_imgsource.cpython-37.pyc b/Dreamer/dmc2gym/__pycache__/natural_imgsource.cpython-37.pyc new file mode 100644 index 0000000..99eabcf Binary files /dev/null and b/Dreamer/dmc2gym/__pycache__/natural_imgsource.cpython-37.pyc differ diff --git a/Dreamer/dmc2gym/__pycache__/wrappers.cpython-37.pyc b/Dreamer/dmc2gym/__pycache__/wrappers.cpython-37.pyc new file mode 100644 index 0000000..62e27d3 Binary files /dev/null and b/Dreamer/dmc2gym/__pycache__/wrappers.cpython-37.pyc differ diff --git a/Dreamer/dmc2gym/wrappers.py b/Dreamer/dmc2gym/wrappers.py index 69bfcbd..855729d 100644 --- a/Dreamer/dmc2gym/wrappers.py +++ b/Dreamer/dmc2gym/wrappers.py @@ -122,7 +122,7 @@ class DMCWrapper(core.Env): if img_source == "images": self._bg_source = natural_imgsource.RandomImageSource(shape2d, files, grayscale=False, max_videos=100, random_bg=False) elif img_source == "video": - self._bg_source = natural_imgsource.RandomVideoSource(shape2d, files, grayscale=False,max_videos=100, random_bg=False) + self._bg_source = natural_imgsource.RandomVideoSource(shape2d, files, grayscale=False, max_videos=100, random_bg=False) else: raise Exception("img_source %s not defined." % img_source) diff --git a/Dreamer/dreamers.py b/Dreamer/dreamers.py index 76612fd..144ad4c 100644 --- a/Dreamer/dreamers.py +++ b/Dreamer/dreamers.py @@ -308,6 +308,7 @@ class SeparationDreamer(Dreamer): with tf.GradientTape(persistent=True) as model_tape: # main + data["image"] = tf.transpose(data["image"], perm=[0, 1, 3, 4, 2]) embed = self._encode(data) post, prior = self._dynamics.observe(embed, data['action']) feat = self._dynamics.get_feat(post) diff --git a/Dreamer/local_dm_control_suite/__pycache__/__init__.cpython-37.pyc b/Dreamer/local_dm_control_suite/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..92bd50c Binary files /dev/null and b/Dreamer/local_dm_control_suite/__pycache__/__init__.cpython-37.pyc differ diff --git a/Dreamer/local_dm_control_suite/__pycache__/acrobot.cpython-37.pyc b/Dreamer/local_dm_control_suite/__pycache__/acrobot.cpython-37.pyc new file mode 100644 index 0000000..9743eb2 Binary files /dev/null and b/Dreamer/local_dm_control_suite/__pycache__/acrobot.cpython-37.pyc differ diff --git a/Dreamer/local_dm_control_suite/__pycache__/ball_in_cup.cpython-37.pyc b/Dreamer/local_dm_control_suite/__pycache__/ball_in_cup.cpython-37.pyc new file mode 100644 index 0000000..1459884 Binary files /dev/null and b/Dreamer/local_dm_control_suite/__pycache__/ball_in_cup.cpython-37.pyc differ diff --git a/Dreamer/local_dm_control_suite/__pycache__/base.cpython-37.pyc b/Dreamer/local_dm_control_suite/__pycache__/base.cpython-37.pyc new file mode 100644 index 0000000..b7c162a Binary files /dev/null and b/Dreamer/local_dm_control_suite/__pycache__/base.cpython-37.pyc differ diff --git a/Dreamer/local_dm_control_suite/__pycache__/cartpole.cpython-37.pyc b/Dreamer/local_dm_control_suite/__pycache__/cartpole.cpython-37.pyc new file mode 100644 index 0000000..10f31da Binary files /dev/null and b/Dreamer/local_dm_control_suite/__pycache__/cartpole.cpython-37.pyc differ diff --git a/Dreamer/local_dm_control_suite/__pycache__/cheetah.cpython-37.pyc b/Dreamer/local_dm_control_suite/__pycache__/cheetah.cpython-37.pyc new file mode 100644 index 0000000..3f05f78 Binary files /dev/null and b/Dreamer/local_dm_control_suite/__pycache__/cheetah.cpython-37.pyc differ diff --git a/Dreamer/local_dm_control_suite/__pycache__/finger.cpython-37.pyc b/Dreamer/local_dm_control_suite/__pycache__/finger.cpython-37.pyc new file mode 100644 index 0000000..4ef120d Binary files /dev/null and b/Dreamer/local_dm_control_suite/__pycache__/finger.cpython-37.pyc differ diff --git a/Dreamer/local_dm_control_suite/__pycache__/fish.cpython-37.pyc b/Dreamer/local_dm_control_suite/__pycache__/fish.cpython-37.pyc new file mode 100644 index 0000000..7a3f7ff Binary files /dev/null and b/Dreamer/local_dm_control_suite/__pycache__/fish.cpython-37.pyc differ diff --git a/Dreamer/local_dm_control_suite/__pycache__/hopper.cpython-37.pyc b/Dreamer/local_dm_control_suite/__pycache__/hopper.cpython-37.pyc new file mode 100644 index 0000000..3aa62c7 Binary files /dev/null and b/Dreamer/local_dm_control_suite/__pycache__/hopper.cpython-37.pyc differ diff --git a/Dreamer/local_dm_control_suite/__pycache__/humanoid.cpython-37.pyc b/Dreamer/local_dm_control_suite/__pycache__/humanoid.cpython-37.pyc new file mode 100644 index 0000000..c824b91 Binary files /dev/null and b/Dreamer/local_dm_control_suite/__pycache__/humanoid.cpython-37.pyc differ diff --git a/Dreamer/local_dm_control_suite/__pycache__/humanoid_CMU.cpython-37.pyc b/Dreamer/local_dm_control_suite/__pycache__/humanoid_CMU.cpython-37.pyc new file mode 100644 index 0000000..9af1eab Binary files /dev/null and b/Dreamer/local_dm_control_suite/__pycache__/humanoid_CMU.cpython-37.pyc differ diff --git a/Dreamer/local_dm_control_suite/__pycache__/lqr.cpython-37.pyc b/Dreamer/local_dm_control_suite/__pycache__/lqr.cpython-37.pyc new file mode 100644 index 0000000..cd2a998 Binary files /dev/null and b/Dreamer/local_dm_control_suite/__pycache__/lqr.cpython-37.pyc differ diff --git a/Dreamer/local_dm_control_suite/__pycache__/manipulator.cpython-37.pyc b/Dreamer/local_dm_control_suite/__pycache__/manipulator.cpython-37.pyc new file mode 100644 index 0000000..d17653d Binary files /dev/null and b/Dreamer/local_dm_control_suite/__pycache__/manipulator.cpython-37.pyc differ diff --git a/Dreamer/local_dm_control_suite/__pycache__/pendulum.cpython-37.pyc b/Dreamer/local_dm_control_suite/__pycache__/pendulum.cpython-37.pyc new file mode 100644 index 0000000..3b04cf6 Binary files /dev/null and b/Dreamer/local_dm_control_suite/__pycache__/pendulum.cpython-37.pyc differ diff --git a/Dreamer/local_dm_control_suite/__pycache__/point_mass.cpython-37.pyc b/Dreamer/local_dm_control_suite/__pycache__/point_mass.cpython-37.pyc new file mode 100644 index 0000000..d4ac91f Binary files /dev/null and b/Dreamer/local_dm_control_suite/__pycache__/point_mass.cpython-37.pyc differ diff --git a/Dreamer/local_dm_control_suite/__pycache__/quadruped.cpython-37.pyc b/Dreamer/local_dm_control_suite/__pycache__/quadruped.cpython-37.pyc new file mode 100644 index 0000000..83e89e5 Binary files /dev/null and b/Dreamer/local_dm_control_suite/__pycache__/quadruped.cpython-37.pyc differ diff --git a/Dreamer/local_dm_control_suite/__pycache__/reacher.cpython-37.pyc b/Dreamer/local_dm_control_suite/__pycache__/reacher.cpython-37.pyc new file mode 100644 index 0000000..e54d8a3 Binary files /dev/null and b/Dreamer/local_dm_control_suite/__pycache__/reacher.cpython-37.pyc differ diff --git a/Dreamer/local_dm_control_suite/__pycache__/stacker.cpython-37.pyc b/Dreamer/local_dm_control_suite/__pycache__/stacker.cpython-37.pyc new file mode 100644 index 0000000..8ca16eb Binary files /dev/null and b/Dreamer/local_dm_control_suite/__pycache__/stacker.cpython-37.pyc differ diff --git a/Dreamer/local_dm_control_suite/__pycache__/swimmer.cpython-37.pyc b/Dreamer/local_dm_control_suite/__pycache__/swimmer.cpython-37.pyc new file mode 100644 index 0000000..63fed40 Binary files /dev/null and b/Dreamer/local_dm_control_suite/__pycache__/swimmer.cpython-37.pyc differ diff --git a/Dreamer/local_dm_control_suite/__pycache__/walker.cpython-37.pyc b/Dreamer/local_dm_control_suite/__pycache__/walker.cpython-37.pyc new file mode 100644 index 0000000..8200b5d Binary files /dev/null and b/Dreamer/local_dm_control_suite/__pycache__/walker.cpython-37.pyc differ diff --git a/Dreamer/local_dm_control_suite/common/__pycache__/__init__.cpython-37.pyc b/Dreamer/local_dm_control_suite/common/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..b31a801 Binary files /dev/null and b/Dreamer/local_dm_control_suite/common/__pycache__/__init__.cpython-37.pyc differ diff --git a/Dreamer/tools.py b/Dreamer/tools.py index 133f867..f6909de 100644 --- a/Dreamer/tools.py +++ b/Dreamer/tools.py @@ -87,24 +87,26 @@ def video_summary(name, video, step=None, fps=20): def encode_gif(frames, fps): from subprocess import Popen, PIPE print(frames[0].shape) - if frames[0].shape[-1] != 3: + if frames[0].shape[-1] > 3: frames = np.transpose(frames, [0, 2, 3, 1]) h, w, c = frames[0].shape - print(h,w,c) - pxfmt = {1: 'gray', 3: 'rgb24'}[c] - cmd = ' '.join([ - f'ffmpeg -y -f rawvideo -vcodec rawvideo', - f'-r {fps:.02f} -s {w}x{h} -pix_fmt {pxfmt} -i - -filter_complex', - f'[0:v]split[x][z];[z]palettegen[y];[x]fifo[x];[x][y]paletteuse', - f'-r {fps:.02f} -f gif -']) - proc = Popen(cmd.split(' '), stdin=PIPE, stdout=PIPE, stderr=PIPE) - for image in frames: - proc.stdin.write(image.tostring()) - out, err = proc.communicate() - if proc.returncode: - raise IOError('\n'.join([' '.join(cmd), err.decode('utf8')])) - del proc - return out + print(frames[0].shape) + + if c!=64: + pxfmt = {1: 'gray', 3: 'rgb24'}[c] + cmd = ' '.join([ + f'ffmpeg -y -f rawvideo -vcodec rawvideo', + f'-r {fps:.02f} -s {w}x{h} -pix_fmt {pxfmt} -i - -filter_complex', + f'[0:v]split[x][z];[z]palettegen[y];[x]fifo[x];[x][y]paletteuse', + f'-r {fps:.02f} -f gif -']) + proc = Popen(cmd.split(' '), stdin=PIPE, stdout=PIPE, stderr=PIPE) + for image in frames: + proc.stdin.write(image.tostring()) + out, err = proc.communicate() + if proc.returncode: + raise IOError('\n'.join([' '.join(cmd), err.decode('utf8')])) + del proc + return out def simulate(agent, envs, steps=0, episodes=0, state=None): diff --git a/Dreamer/train_configs/dreamer.yaml b/Dreamer/train_configs/dreamer.yaml index 9d2b179..6444ba6 100644 --- a/Dreamer/train_configs/dreamer.yaml +++ b/Dreamer/train_configs/dreamer.yaml @@ -1,6 +1,6 @@ dmc: - logdir: /home/vedant/tia/Dreamer/logdir + logdir: /media/vedant/cpsDataStorageWK/Vedant/tia_logs video_dir_train: /media/vedant/cpsDataStorageWK/Vedant/natural_video_setting/train/ video_dir_test: /media/vedant/cpsDataStorageWK/Vedant/natural_video_setting/test/ debug: False diff --git a/Dreamer/train_configs/tia.yaml b/Dreamer/train_configs/tia.yaml index 1bf3f85..f0df1f7 100644 --- a/Dreamer/train_configs/tia.yaml +++ b/Dreamer/train_configs/tia.yaml @@ -1,6 +1,6 @@ dmc: - logdir: /home/vedant/tia/Dreamer/logdir + logdir: /media/vedant/cpsDataStorageWK/Vedant/tia_logs video_dir_train: /media/vedant/cpsDataStorageWK/Vedant/natural_video_setting/train/ video_dir_test: /media/vedant/cpsDataStorageWK/Vedant/natural_video_setting/test/ debug: False