@@ -179,21 +179,17 @@ def training_step(
179179 # import pdb; pdb.set_trace()
180180 # Get the input data to noise and denoise~(image, video) and the corresponding conditioner.
181181 self .net = model
182- x0_from_data_batch , x0 , condition = self .get_data_and_condition (data_batch )
182+ x0 , condition = self .get_data_and_condition (data_batch )
183183
184184 # Sample pertubation noise levels and N(0, 1) noises
185185 sigma , epsilon = self .draw_training_sigma_and_epsilon (x0 .size (), condition )
186186
187187 if parallel_state .is_pipeline_last_stage ():
188- output_batch , pred_mse , edm_loss = self .compute_loss_with_epsilon_and_sigma (
189- data_batch , x0_from_data_batch , x0 , condition , epsilon , sigma
190- )
188+ output_batch , pred_mse , edm_loss = self .compute_loss_with_epsilon_and_sigma (x0 , condition , epsilon , sigma )
191189
192190 return output_batch , edm_loss
193191 else :
194- net_output = self .compute_loss_with_epsilon_and_sigma (
195- data_batch , x0_from_data_batch , x0 , condition , epsilon , sigma
196- )
192+ net_output = self .compute_loss_with_epsilon_and_sigma (x0 , condition , epsilon , sigma )
197193 return net_output
198194
199195 def denoise (self , xt : torch .Tensor , sigma : torch .Tensor , condition : dict [str , torch .Tensor ]):
@@ -232,8 +228,6 @@ def denoise(self, xt: torch.Tensor, sigma: torch.Tensor, condition: dict[str, to
232228
233229 def compute_loss_with_epsilon_and_sigma (
234230 self ,
235- data_batch : dict [str , torch .Tensor ],
236- x0_from_data_batch : torch .Tensor ,
237231 x0 : torch .Tensor ,
238232 condition : dict [str , torch .Tensor ],
239233 epsilon : torch .Tensor ,
@@ -294,14 +288,14 @@ def get_per_sigma_loss_weights(self, sigma: torch.Tensor):
294288
295289 def get_condition_uncondition (self , data_batch : Dict ):
296290 """Returns conditioning and unconditioning for classifier-free guidance."""
297- _ , _ , condition = self .get_data_and_condition (data_batch , dropout_rate = 0.0 )
291+ _ , condition = self .get_data_and_condition (data_batch , dropout_rate = 0.0 )
298292
299293 if "neg_context_embeddings" in data_batch :
300294 data_batch ["context_embeddings" ] = data_batch ["neg_context_embeddings" ]
301295 data_batch ["context_mask" ] = data_batch ["context_mask" ]
302- _ , _ , uncondition = self .get_data_and_condition (data_batch , dropout_rate = 1.0 )
296+ _ , uncondition = self .get_data_and_condition (data_batch , dropout_rate = 1.0 )
303297 else :
304- _ , _ , uncondition = self .get_data_and_condition (data_batch , dropout_rate = 1.0 )
298+ _ , uncondition = self .get_data_and_condition (data_batch , dropout_rate = 1.0 )
305299
306300 return condition , uncondition
307301
@@ -419,13 +413,14 @@ def get_data_and_condition(self, data_batch: dict[str, Tensor], dropout_rate=0.2
419413 Raw data, latent data, and conditioning information.
420414 """
421415 # Latent state
422- raw_state = data_batch ["video" ] * self .sigma_data
423- # assume data is already encoded
424- latent_state = raw_state
425-
426- # Condition
427- data_batch ["crossattn_emb" ] = self .random_dropout_input (
416+ latent_state = data_batch ["video" ] * self .sigma_data
417+ condition = {} # Create a new dictionary for condition
418+ # Copy all keys from data_batch except 'video'
419+ for key , value in data_batch .items ():
420+ if key not in ["video" , "context_embeddings" ]:
421+ condition [key ] = value
422+
423+ condition ["crossattn_emb" ] = self .random_dropout_input (
428424 data_batch ["context_embeddings" ], dropout_rate = dropout_rate
429425 )
430-
431- return raw_state , latent_state , data_batch
426+ return latent_state , condition
0 commit comments