MCPcopy Create free account
hub / github.com/deepbrainai-research/float / forward

Method forward

models/float/FLOAT.py:211–222  ·  view source on GitHub ↗
(self, a:torch.Tensor, prev_a:torch.Tensor = None)

Source from the content-addressed store, hash-verified

209 return a
210
211 def forward(self, a:torch.Tensor, prev_a:torch.Tensor = None) -> torch.Tensor:
212 if prev_a is not None:
213 a = torch.cat([prev_a, a], dim = 1)
214 if a.shape[1] % int( (self.num_frames_for_clip + self.num_prev_frames) * self.opt.sampling_rate / self.opt.fps) != 0:
215 a = F.pad(a, (0, int((self.num_frames_for_clip + self.num_prev_frames) * self.opt.sampling_rate / self.opt.fps) - a.shape[1]), mode='replicate')
216 a = self.get_wav2vec2_feature(a, seq_len = self.num_frames_for_clip + self.num_prev_frames)
217 else:
218 if a.shape[1] % int( self.num_frames_for_clip * self.opt.sampling_rate / self.opt.fps) != 0:
219 a = F.pad(a, (0, int(self.num_frames_for_clip * self.opt.sampling_rate / self.opt.fps) - a.shape[1]), mode = 'replicate')
220 a = self.get_wav2vec2_feature(a, seq_len = self.num_frames_for_clip)
221
222 return self.audio_projection(a) # frame by frame
223
224 @torch.no_grad()
225 def inference(self, a: torch.Tensor, seq_len:int) -> torch.Tensor:

Callers 1

predict_emotionMethod · 0.45

Calls 1

get_wav2vec2_featureMethod · 0.95

Tested by

no test coverage detected