roykapon / MAS

The official implementation of the paper "MAS: Multiview Ancestral Sampling for 3D Motion Generation Using 2D Diffusion"
MIT License
97 stars 3 forks source link

"Mean.npy" and "Std.npy" #2

Closed sherlhw closed 1 month ago

sherlhw commented 7 months ago

Hi! What are the "Mean.npy" and "Std.npy" files? If I want to make my own dataset, how do I get the "Mean.npy" and "Std.npy" files?

roykapon commented 7 months ago

The Mean.npy and Std.npy save the mean and standard deviation of each joint across all frames in the dataset (Its dimension is 2×(number of joints) since we treat the x and y dimensions separately). It is obtained by concatenating all motion sequences and apply np.mean or np.std across the time dimension. This is the code we used for our datasets.

import os
from tqdm import tqdm
import numpy as np
from os.path import join as pjoin

data_dir = 'your/motions/directory'
save_dir = pjoin(data_dir, '..')

source_list = os.listdir(data_dir)

data = []
for source_file in tqdm(source_list):
    source_data = np.load(pjoin(data_dir, source_file))
    data += [*source_data]

mean = np.mean(data, axis=0)
mean = mean[...,:2]
std = np.std(data, axis=0)
std = std[...,:2]
print(f'mean: {mean}')
print(f'std: {std}')

print(f'saving mean and std to {save_dir}')
np.save(pjoin(save_dir, 'Mean'), mean)
np.save(pjoin(save_dir, 'Std'), std)

The mean = mean[...,:2] row is meant to delete the confidence of the joint (mostly relevant when the joints were predicted by some detector) if it exists.

GithubAccountTo commented 6 months ago

How do I get.npy files for my own dataset

roykapon commented 1 month ago

This issue is discussed in #3 so closing it for now.