(filepath, classes)
Load training data from skeletons_info.txt.
    Some notations:
        N: number of valid data.
        P: feature dimension. Here P=36.
        C: number of classes.
    Arguments:
        filepath {str}: file path of `skeletons_info.txt`, which stores the skeletons and labels.
    Returns:
        X: {np.array, shape=NxP}:           Skeleton data (feature) of each valid image.
        Y: {list of int, len=N}:            Label of each valid image.
        video_indices {list of int, len=N}:  The video index of which the image belongs to.
        classes {list of string, len=C}:    The classes of all actions.
Load training data from skeletons_info.txt.
    Some notations:
        N: number of valid data.
        P: feature dimension. Here P=36.
        C: number of classes.
    Arguments:
        filepath {str}: file path of `skeletons_info.txt`, which stores the skeletons and labels.
    Returns:
        X: {np.array, shape=NxP}:           Skeleton data (feature) of each valid image.
        Y: {list of int, len=N}:            Label of each valid image.
        video_indices {list of int, len=N}:  The video index of which the image belongs to.
        classes {list of string, len=C}:    The classes of all actions.
Load training data from skeletons_info . txt . Some notations : N : number of valid data . P : feature dimension . Here P = 36 . C : number of classes . Arguments : filepath { str } : file path of skeletons_info . txt which stores the skeletons and labels . Returns : X : { np . array shape = NxP } : Skeleton data ( feature ) of each valid image . Y : { list of int len = N } : Label of each valid image . video_indices { list of int len = N } : The video index of which the image belongs to . classes { list of string len = C } : The classes of all actions .
def load_skeleton_data(filepath, classes):
    ''' Load training data from skeletons_info.txt.
    Some notations:
        N: number of valid data.
        P: feature dimension. Here P=36.
        C: number of classes.
    Arguments:
        filepath {str}: file path of `skeletons_info.txt`, which stores the skeletons and labels.
    Returns:
        X: {np.array, shape=NxP}:           Skeleton data (feature) of each valid image.
        Y: {list of int, len=N}:            Label of each valid image.
        video_indices {list of int, len=N}:  The video index of which the image belongs to.
        classes {list of string, len=C}:    The classes of all actions.
    '''

    label2index = {c: i for i, c in enumerate(classes)}

    with open(filepath, 'r') as f:

        # Load data
        dataset = simplejson.load(f)

        # Remove bad data. A bad data is filled with zeros.
        def is_good_data(row):
            return row[0] != 0
        dataset = [row for i, row in enumerate(dataset) if is_good_data(row)]

        # Get skeleton data, which is in the pos [5, 41)
        # LEN_IMG_INFO = 5
        # LEN_SKELETON_XY = 36
        X = np.array([row[LEN_IMG_INFO:LEN_IMG_INFO+LEN_SKELETON_XY]
                      for row in dataset])

        # row[1] is the video index of the image
        video_indices = [row[1] for row in dataset]

        # row[3] is the label of the image
        # Y_str = [[row[3]] for row in dataset] # deprecated
        Y_str = [row[3] for row in dataset]

        # Convert string label to indices
        # classes, Y = _get_classes_and_label_indices(Y_str) # deprecated
        Y = [label2index[label] for label in Y_str]

        # Remove data with missing upper body joints
        if 0:
            valid_indices = _get_skeletons_with_complete_upper_body(X, NaN)
            X = X[valid_indices, :]
            Y = [Y[i] for i in valid_indices]
            video_indices = [video_indices[i] for i in valid_indices]
            print("Num samples after removal = ", len(Y))

        # Print data properties
        N = len(Y)
        P = len(X[0])
        C = len(classes)
        print(f"\nNumber of samples = {N} \n"
              f"Raw feature length = {P} \n"
              f"Number of classes = {C}")
        print(f"Classes: {classes}")

        return X, Y, video_indices

    raise RuntimeError("Failed to load skeletons txt: " + filepath)
def load_skeleton_data ( filepath , classes ) : label2index = { c : i for i , c in enumerate ( classes ) } with open ( filepath , 'r' ) as f : # Load data dataset = simplejson . load ( f ) # Remove bad data. A bad data is filled with zeros. def is_good_data ( row ) : return row [ 0 ] != 0 dataset = [ row for i , row in enumerate ( dataset ) if is_good_data ( row ) ] # Get skeleton data, which is in the pos [5, 41) # LEN_IMG_INFO = 5 # LEN_SKELETON_XY = 36 X = np . array ( [ row [ LEN_IMG_INFO : LEN_IMG_INFO + LEN_SKELETON_XY ] for row in dataset ] ) # row[1] is the video index of the image video_indices = [ row [ 1 ] for row in dataset ] # row[3] is the label of the image # Y_str = [[row[3]] for row in dataset] # deprecated Y_str = [ row [ 3 ] for row in dataset ] # Convert string label to indices # classes, Y = _get_classes_and_label_indices(Y_str) # deprecated Y = [ label2index [ label ] for label in Y_str ] # Remove data with missing upper body joints if 0 : valid_indices = _get_skeletons_with_complete_upper_body ( X , NaN ) X = X [ valid_indices , : ] Y = [ Y [ i ] for i in valid_indices ] video_indices = [ video_indices [ i ] for i in valid_indices ] print ( "Num samples after removal = " , len ( Y ) ) # Print data properties N = len ( Y ) P = len ( X [ 0 ] ) C = len ( classes ) print ( f"\nNumber of samples = {N} \n" f"Raw feature length = {P} \n" f"Number of classes = {C}" ) print ( f"Classes: {classes}" ) return X , Y , video_indices raise RuntimeError ( "Failed to load skeletons txt: " + filepath )