hannahbull / clean_op_data_sl

GNU General Public License v3.0
5 stars 0 forks source link

Wrong loop when converting data to 25 fps #6

Open jessicalfr opened 1 year ago

jessicalfr commented 1 year ago

I was applying the clean_op_data.py script to the MediaPi-Skel dataset and got a strange error.

Traceback (most recent call last):
  File "clean_op_data.py", line 219, in <module>
    conv_data_list_red[:, j, k, 0] = convert_30_25_fps(data_numpy[:, j, k, 0],
  File "/baseline/clean_op_data_sl/utils.py", line 168, in convert_30_25_fps
    vector = [vector[0]]+[(5-i%6)/5*vector[i]*int(scores[i]!=0)
IndexError: index 0 is out of bounds for axis 0 with size 0

When debugging I found that the function convert_30_25_fps is inside a loop defined as for i in range(len(data_list)) but the i index isn't being used in the loop at all:

        ### convert to 25 fps at end
        if (fps>=28 and fps <=32 and convert_to_25fps):
            for i in range(len(data_list)):
                conv_data_list_red = np.zeros((len([1 for n in range(data_numpy.shape[0]-1) if n % 6 != 5]),
                                               data_numpy.shape[1],
                                               data_numpy.shape[2],
                                               data_numpy.shape[3]))
                for j in range(3):
                    for k in range(127):
                        if (j!=2):
                            conv_data_list_red[:, j, k, 0] = convert_30_25_fps(data_numpy[:, j, k, 0],
                                                                                    scores = data_numpy[:, 2, k, 0],
                                                                                    labels = False)
                        else:
                            conv_data_list_red[:, j, k, 0] = convert_30_25_fps(data_numpy[:, j, k, 0],
                                                                                    scores = None,
                                                                                    labels = False)
                data_numpy = conv_data_list_red

For an example video (video 00027 from MediaPi-Skel dataset), we get a scene in the interval of frames [2438, 4400], and the data_numpy object has shape (1925, 3, 127, 1) before the loop. The original video has a fps of ~29.97 and, at the end of the first iteration, data_numpy has shape (1604, 3, 127, 1) (reducing the fps to ~25). But since len(data_list)==57, the loop continues and the size of the first dimension is reduced until it becomes (0, 3, 127, 1) at iteration i==35. And then the program gets the above mentioned error.

I believe this loop is wrong and the convert_30_25_fps funcion must be applied to the scene data only once.