(self, caption, m_lens, dim_pose, batch_size=1024)
| 106 | return output |
| 107 | |
| 108 | def generate(self, caption, m_lens, dim_pose, batch_size=1024): |
| 109 | N = len(caption) |
| 110 | cur_idx = 0 |
| 111 | self.encoder.eval() |
| 112 | all_output = [] |
| 113 | while cur_idx < N: |
| 114 | if cur_idx + batch_size >= N: |
| 115 | batch_caption = caption[cur_idx:] |
| 116 | batch_m_lens = m_lens[cur_idx:] |
| 117 | else: |
| 118 | batch_caption = caption[cur_idx: cur_idx + batch_size] |
| 119 | batch_m_lens = m_lens[cur_idx: cur_idx + batch_size] |
| 120 | output = self.generate_batch(batch_caption, batch_m_lens, dim_pose) |
| 121 | B = output.shape[0] |
| 122 | |
| 123 | for i in range(B): |
| 124 | all_output.append(output[i]) |
| 125 | cur_idx += batch_size |
| 126 | return all_output |
| 127 | |
| 128 | def backward_G(self): |
| 129 | loss_mot_rec = self.mse_criterion(self.fake_noise, self.real_noise).mean(dim=-1) |
no test coverage detected