Open-Sora: Democratizing Efficient Video Production for All
Python
fix bugs, runable
tianyi2d1590b5821f
diff --git a/.gitignore b/.gitignoreindex 55daee5..8797ae7 100644--- a/.gitignore+++ b/.gitignore@@ -177,3 +177,4 @@ pretrained_models/# Secret fileshostfilegradio_cached_examples/+wandb/diff --git a/opensora/schedulers/__init__.py b/opensora/schedulers/__init__.pyindex 97ea76f..c7733a4 100644--- a/opensora/schedulers/__init__.py+++ b/opensora/schedulers/__init__.py@@ -1,2 +1,3 @@from .dpms import DPMSfrom .iddpm import IDDPM+from .rf import RFLOWdiff --git a/opensora/schedulers/rf/__init__.py b/opensora/schedulers/rf/__init__.pyindex 7520602..dd1009e 100644--- a/opensora/schedulers/rf/__init__.py+++ b/opensora/schedulers/rf/__init__.py@@ -54,6 +54,9 @@ class RFLOW:z = z + v_pred * dtreturn z++ def training_losses(self, model, x_start, t, model_kwargs=None, noise = None, mask = None, weights = None):+ return self.scheduler.training_losses(model, x_start, t, model_kwargs, noise, mask, weights)diff --git a/opensora/schedulers/rf/rectified_flow.py b/opensora/schedulers/rf/rectified_flow.pyindex 03aef76..9f85c10 100644--- a/opensora/schedulers/rf/rectified_flow.py+++ b/opensora/schedulers/rf/rectified_flow.py@@ -29,11 +29,13 @@ class RFlowScheduler:model_kwargs = {}if noise is None:noise = torch.randn_like(x_start)+ assert noise.shape == x_start.shapex_t = self.add_noise(x_start, noise, t)terms = {}- velocity_pred = model(x_t, t, **model_kwargs)+ model_output = model(x_t, t, **model_kwargs)+ velocity_pred = model_output.chunk(2, dim = 1)[0]loss = (velocity_pred - (x_start - noise)).pow(2).mean()terms['loss'] = loss@@ -52,6 +54,11 @@ class RFlowScheduler:timepoints = timesteps.float() / self.num_timesteps # [0, 999/1000]timepoints = 1 - timepoints # [1,1/1000]+ # timepoint (bsz) noise: (bsz, 4, frame, w ,h)+ # expand timepoint to noise shape+ timepoints = timepoints.unsqueeze(1).unsqueeze(1).unsqueeze(1).unsqueeze(1)+ timepoints = timepoints.repeat(1, noise.shape[1], noise.shape[2], noise.shape[3], noise.shape[4])+return timepoints * original_samples + (1 - timepoints) * noise# def step(