-
Notifications
You must be signed in to change notification settings - Fork 384
/
vis_dataset.py
72 lines (54 loc) · 2.03 KB
/
vis_dataset.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
60
61
62
63
64
65
66
67
68
69
70
71
72
import logging
import numpy as np
from scipy.misc import imresize
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
from util.config import load_config
from dataset.pose_dataset import Batch
from dataset.factory import create as dataset_create
def display_dataset():
logging.basicConfig(level=logging.DEBUG)
cfg = load_config()
dataset = dataset_create(cfg)
dataset.set_shuffle(False)
while True:
batch = dataset.next_batch()
for frame_id in range(1):
img = batch[Batch.inputs][frame_id,:,:,:]
img = np.squeeze(img).astype('uint8')
scmap = batch[Batch.part_score_targets][frame_id,:,:,:]
scmap = np.squeeze(scmap)
# scmask = batch[Batch.part_score_weights]
# if scmask.size > 1:
# scmask = np.squeeze(scmask).astype('uint8')
# else:
# scmask = np.zeros(img.shape)
subplot_height = 4
subplot_width = 5
num_plots = subplot_width * subplot_height
f, axarr = plt.subplots(subplot_height, subplot_width)
for j in range(num_plots):
plot_j = j // subplot_width
plot_i = j % subplot_width
curr_plot = axarr[plot_j, plot_i]
curr_plot.axis('off')
if j >= cfg.num_joints:
continue
scmap_part = scmap[:,:,j]
scmap_part = imresize(scmap_part, 8.0, interp='nearest')
scmap_part = np.lib.pad(scmap_part, ((4, 0), (4, 0)), 'minimum')
curr_plot.set_title("{}".format(j+1))
curr_plot.imshow(img)
curr_plot.hold(True)
curr_plot.imshow(scmap_part, alpha=.5)
# figure(0)
# plt.imshow(np.sum(scmap, axis=2))
# plt.figure(100)
# plt.imshow(img)
# plt.figure(2)
# plt.imshow(scmask)
plt.show()
plt.waitforbuttonpress()
if __name__ == '__main__':
display_dataset()