ktr-hubrt / MPN

Official codes of CVPR21 paper: Learning Normal Dynamics in Videos with Meta Prototype Network
130 stars 42 forks source link

model文件夹中的utils.py文件 __getitem__(self, index)函数中的 return np.concatenate(batch, axis=0)是什么意思?? #8

Closed xiaobing-fang closed 3 years ago

xiaobing-fang commented 3 years ago
def __getitem__(self, index):

    video_name = self.video_names[index]
    length = self.videos[video_name]['length']-4
    seg_ind = random.sample(range(0, self.num_segs), 1)
    frame_ind = random.sample(range(0, length//self.num_segs), self.task_size)

    batch = []
    for j in range(self.task_size):
        couple = []
        frame_name = seg_ind[0]*(length//self.num_segs)+frame_ind[j]
        for i in range(self._time_step+self._num_pred):
            image = np_load_frame(self.videos[video_name]['frame'][frame_name+i], self._resize_height, self._resize_width)
            # print(self.videos[video_name]['frame'][frame_name+i])
            if self.transform is not None:
                couple.append(self.transform(image))
        batch.append(np.expand_dims(np.concatenate(couple, axis=0), axis=0))
    # import pdb;pdb.set_trace()
    return np.concatenate(batch, axis=0)  
ktr-hubrt commented 3 years ago

读取图片堆成一个batch