Loading Dataset
%load_ext autoreload
%autoreload 2
%matplotlib inline
The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload

class Human36Dataset[source]

Human36Dataset(actions, data_path, is_train=True) :: Dataset

An abstract class representing a :class:Dataset.

All datasets that represent a map from keys to data samples should subclass it. All subclasses should overwrite :meth:__getitem__, supporting fetching a data sample for a given key. Subclasses could also optionally overwrite :meth:__len__, which is expected to return the size of the dataset by many :class:~torch.utils.data.Sampler implementations and the default options of :class:~torch.utils.data.DataLoader.

.. note:: :class:~torch.utils.data.DataLoader by default constructs a index sampler that yields integral indices. To make it work with a map-style dataset with non-integral indices/keys, a custom sampler must be provided.

get_actions('all')
['Directions',
 'Discussion',
 'Eating',
 'Greeting',
 'Phoning',
 'Photo',
 'Posing',
 'Purchases',
 'Sitting',
 'SittingDown',
 'Smoking',
 'Waiting',
 'WalkDog',
 'Walking',
 'WalkTogether']
train_h36 = Human36Dataset(get_actions('Greeting'), data_path, is_train=True)
test_h36  = Human36Dataset(get_actions('Greeting'), data_path, is_train=False)
len(train_h36), len(test_h36)
(1559752, 550644)
rcams = torch.load(data_path/'rcams.pt')

stat_2d = torch.load(data_path/'stat_2d.pt')
mean_2d = stat_2d['mean']
std_2d = stat_2d['std']
dim_use_2d = stat_2d['dim_use']
dim_ignore_2d = stat_2d['dim_ignore']

stat_3d = torch.load(data_path/'stat_3d.pt')
mean_3d = stat_3d['mean']
std_3d = stat_3d['std']
dim_use_3d = stat_3d['dim_use']
dim_ignore_3d = stat_3d['dim_ignore']
idx = 2000
train_2d = train_h36[idx][0].reshape(1, -1)
train_3d = train_h36[idx][1].reshape(1, -1)
train_key = train_h36.get_key(idx)

test_2d = test_h36[idx][0].reshape(1, -1)
test_3d = test_h36[idx][1].reshape(1, -1)
test_key = test_h36.get_key(idx)
ts_2d = unnormalize_data(train_2d, mean_2d, std_2d, dim_ignore_2d)
ts_3d = unnormalize_data(train_3d, mean_3d, std_3d, dim_ignore_3d)
ts_3d = cam_to_world_centered(ts_3d, train_key, rcams)
train_2d
tensor([[-0.1493, -0.4170, -0.3561, -0.4096, -0.2728, -0.3121, -0.2001, -0.2659,
          0.0996, -0.4233,  0.0574, -0.2929,  0.0746, -0.3450, -0.2165, -0.3450,
         -0.2395, -0.3036, -0.2866, -0.3030,  0.0307, -0.4009,  0.4522, -1.0641,
          0.5104, -1.3222, -0.4420, -0.3326, -0.5987, -0.8219, -0.3788, -1.0461]])
plt.figure(figsize=(16,6))
gs2 = GridSpec(1,2)
ax1 = plt.subplot(gs2[0])
ax2 = plt.subplot(gs2[1], projection='3d')
show_2d_pose(ts_2d, ax1)
ax1.invert_yaxis()

show_3d_pose(ts_3d, ax2)

plt.show()
plt.figure(figsize=(16,6))
gs2 = GridSpec(1,2)
ax1 = plt.subplot(gs2[0])
ax2 = plt.subplot(gs2[1], projection='3d')

ts_2d = unnormalize_data(test_2d, mean_2d, std_2d, dim_ignore_2d)
ts_3d = unnormalize_data(test_3d, mean_3d, std_3d, dim_ignore_3d)
ts_3d = cam_to_world_centered(ts_3d, test_key, rcams)

show_2d_pose(ts_2d, ax1)
ax1.invert_yaxis()

show_3d_pose(ts_3d, ax2)

plt.show()