(seq_len,lst, emb)
| 20 | |
| 21 | |
| 22 | def pad_sequence(seq_len,lst, emb): |
| 23 | result=[] |
| 24 | for video in lst: |
| 25 | if isinstance(video, list): |
| 26 | video = torch.stack(video) |
| 27 | ori_len=video.shape[0] |
| 28 | if ori_len == 0: |
| 29 | video = torch.zeros([seq_len,emb],dtype=torch.long) |
| 30 | elif ori_len>=seq_len: |
| 31 | if emb == 200: |
| 32 | video=torch.FloatTensor(video[:seq_len]) |
| 33 | else: |
| 34 | video=torch.LongTensor(video[:seq_len]) |
| 35 | else: |
| 36 | video=torch.cat([video,torch.zeros([seq_len-ori_len,video.shape[1]],dtype=torch.long)],dim=0) |
| 37 | if emb == 200: |
| 38 | video=torch.FloatTensor(video) |
| 39 | else: |
| 40 | video=torch.LongTensor(video) |
| 41 | result.append(video) |
| 42 | return torch.stack(result) |
| 43 | |
| 44 | def pad_sequence_bbox(seq_len,lst): |
| 45 | result=[] |
no outgoing calls
no test coverage detected