MCPcopy Create free account
hub / github.com/ICTMCG/FakeSV / pad_sequence

Function pad_sequence

code/run.py:22–42  ·  view source on GitHub ↗
(seq_len,lst, emb)

Source from the content-addressed store, hash-verified

20
21
22def 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
44def pad_sequence_bbox(seq_len,lst):
45 result=[]

Callers 4

SVFEND_collate_fnFunction · 0.85
FANVM_collate_fnFunction · 0.85
comments_collate_fnFunction · 0.85
title_w2v_collate_fnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected