forked from openai/random-network-distillation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
visualize.py
59 lines (45 loc) · 1.33 KB
/
visualize.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import matplotlib.pyplot as plt
import pickle
from PIL import Image
import argparse
parser = argparse.ArgumentParser(description='Visualize attention')
parser.add_argument("video_path", type=str, help="Path to the videos_0.pk path in the openai_savings")
args = parser.parse_args()
path = args.video_path
f = open(path, 'rb')
for _ in range(200):
episode = pickle.load(f)
episode = pickle.load(f)
attention = episode['attention']
obs = episode['obs']
square = 7
ix = 1
fig = plt.figure(constrained_layout=True)
gs = fig.add_gridspec(14, 7)
for i in range(square):
for j in range(square):
# specify subplot and turn of axis
sub = fig.add_subplot(gs[i,j])
sub.set_xticks([])
sub.set_yticks([])
sub.imshow(attention[20, :, :, ix-1], cmap='gray', aspect='auto')
ix += 1
sub = fig.add_subplot(gs[7:, :])
sub.set_xticks([])
sub.set_yticks([])
sub.imshow(obs[20,...,:3])
plt.show()
# square = 7
# ix = 1
# for _ in range(square):
# for _ in range(square):
# # specify subplot and turn of axis
# ax = plt.subplot(square, square, ix)
# ax.set_xticks([])
# ax.set_yticks([])
# # plot filter channel in grayscale
# plt.imshow(attention[480, :, :, ix-1], cmap='gray')
# ix += 1
# plt.show()
# imgplot = plt.imshow(obs[480,...,:3])
# plt.show()