(seq_len,lst)
| 57 | return torch.stack(result) |
| 58 | |
| 59 | def pad_frame_sequence(seq_len,lst): |
| 60 | attention_masks = [] |
| 61 | result=[] |
| 62 | for video in lst: |
| 63 | video=torch.FloatTensor(video) |
| 64 | ori_len=video.shape[0] |
| 65 | if ori_len>=seq_len: |
| 66 | gap=ori_len//seq_len |
| 67 | video=video[::gap][:seq_len] |
| 68 | mask = np.ones((seq_len)) |
| 69 | else: |
| 70 | video=torch.cat((video,torch.zeros([seq_len-ori_len,video.shape[1]],dtype=torch.float)),dim=0) |
| 71 | mask = np.append(np.ones(ori_len), np.zeros(seq_len-ori_len)) |
| 72 | result.append(video) |
| 73 | mask = torch.IntTensor(mask) |
| 74 | attention_masks.append(mask) |
| 75 | return torch.stack(result), torch.stack(attention_masks) |
| 76 | |
| 77 | |
| 78 | def _init_fn(worker_id): |
no outgoing calls
no test coverage detected