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

Function pad_frame_sequence

code/run.py:59–75  ·  view source on GitHub ↗
(seq_len,lst)

Source from the content-addressed store, hash-verified

57 return torch.stack(result)
58
59def 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
78def _init_fn(worker_id):

Callers 4

SVFEND_collate_fnFunction · 0.85
FANVM_collate_fnFunction · 0.85
c3d_collate_fnFunction · 0.85
vgg_collate_fnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected