| 42 | return torch.stack(result) |
| 43 | |
| 44 | def pad_sequence_bbox(seq_len,lst): |
| 45 | result=[] |
| 46 | for video in lst: |
| 47 | if isinstance(video, list): |
| 48 | video = torch.stack(video) |
| 49 | ori_len=video.shape[0] |
| 50 | if ori_len == 0: |
| 51 | video = torch.zeros([seq_len,45,4096],dtype=torch.float) |
| 52 | elif ori_len>=seq_len: |
| 53 | video=torch.FloatTensor(video[:seq_len]) |
| 54 | else: |
| 55 | video=torch.cat([video,torch.zeros([seq_len-ori_len,45,4096],dtype=torch.float)],dim=0) |
| 56 | result.append(video) |
| 57 | return torch.stack(result) |
| 58 | |
| 59 | def pad_frame_sequence(seq_len,lst): |
| 60 | attention_masks = [] |