MCPcopy Create free account
hub / github.com/MotrixLab/FineMoGen / ReMoDiffuseTransformer

Class ReMoDiffuseTransformer

mogen/models/transformers/remodiffuse.py:203–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201
202@SUBMODULES.register_module()
203class ReMoDiffuseTransformer(DiffusionTransformer):
204
205 def __init__(self, retrieval_cfg=None, scale_func_cfg=None, **kwargs):
206 super().__init__(**kwargs)
207 self.database = RetrievalDatabase(**retrieval_cfg)
208 self.scale_func_cfg = scale_func_cfg
209
210 def scale_func(self, timestep):
211 coarse_scale = self.scale_func_cfg['coarse_scale']
212 w = (1 - (1000 - timestep) / 1000) * coarse_scale + 1
213 if timestep > 100:
214 if random.randint(0, 1) == 0:
215 output = {
216 'both_coef': w,
217 'text_coef': 0,
218 'retr_coef': 1 - w,
219 'none_coef': 0
220 }
221 else:
222 output = {
223 'both_coef': 0,
224 'text_coef': w,
225 'retr_coef': 0,
226 'none_coef': 1 - w
227 }
228 else:
229 both_coef = self.scale_func_cfg['both_coef']
230 text_coef = self.scale_func_cfg['text_coef']
231 retr_coef = self.scale_func_cfg['retr_coef']
232 none_coef = 1 - both_coef - text_coef - retr_coef
233 output = {
234 'both_coef': both_coef,
235 'text_coef': text_coef,
236 'retr_coef': retr_coef,
237 'none_coef': none_coef
238 }
239 return output
240
241 def get_precompute_condition(self,
242 text=None,
243 motion_length=None,
244 xf_out=None,
245 re_dict=None,
246 device=None,
247 sample_idx=None,
248 clip_feat=None,
249 **kwargs):
250 if xf_out is None:
251 xf_out = self.encode_text(text, clip_feat, device)
252 output = {'xf_out': xf_out}
253 if re_dict is None:
254 re_dict = self.database(text,
255 motion_length,
256 self.clip,
257 device,
258 idx=sample_idx)
259 output['re_dict'] = re_dict
260 return output

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected