expose flow_shift, add vid2vid
This commit is contained in:
@@ -226,6 +226,7 @@ class HunyuanVideoPipeline(DiffusionPipeline):
|
||||
else:
|
||||
latents = latents.to(device)
|
||||
timesteps, num_inference_steps = self.get_timesteps(num_inference_steps, denoise_strength, device)
|
||||
latent_timestep = timesteps[:1]
|
||||
frames_needed = noise.shape[1]
|
||||
current_frames = latents.shape[1]
|
||||
|
||||
@@ -236,8 +237,9 @@ class HunyuanVideoPipeline(DiffusionPipeline):
|
||||
self.additional_frames = repeat_factor
|
||||
elif frames_needed < current_frames:
|
||||
latents = latents[:, :frames_needed, :, :, :]
|
||||
print(timesteps)
|
||||
|
||||
latents = noise.to(device) *0.5 + latents * 0.5
|
||||
latents = latents * (1 - latent_timestep / 1000) + latent_timestep / 1000 * noise
|
||||
|
||||
# Check existence to make it compatible with FlowMatchEulerDiscreteScheduler
|
||||
if hasattr(self.scheduler, "init_noise_sigma"):
|
||||
|
||||
@@ -77,9 +77,10 @@ class FlowMatchDiscreteScheduler(SchedulerMixin, ConfigMixin):
|
||||
n_tokens: Optional[int] = None,
|
||||
):
|
||||
sigmas = torch.linspace(1, 0, num_train_timesteps + 1)
|
||||
|
||||
print("Scheduler config:", self.config)
|
||||
if not reverse:
|
||||
sigmas = sigmas.flip(0)
|
||||
self.shift = shift
|
||||
|
||||
self.sigmas = sigmas
|
||||
# the value fed to model
|
||||
@@ -183,7 +184,7 @@ class FlowMatchDiscreteScheduler(SchedulerMixin, ConfigMixin):
|
||||
return sample
|
||||
|
||||
def sd3_time_shift(self, t: torch.Tensor):
|
||||
return (self.config.shift * t) / (1 + (self.config.shift - 1) * t)
|
||||
return (self.shift * t) / (1 + (self.shift - 1) * t)
|
||||
|
||||
def step(
|
||||
self,
|
||||
|
||||
@@ -572,6 +572,7 @@ class HyVideoSampler:
|
||||
"num_frames": ("INT", {"default": 49, "min": 1, "max": 1024, "step": 4}),
|
||||
"steps": ("INT", {"default": 30, "min": 1}),
|
||||
"guidance_scale": ("FLOAT", {"default": 6.0, "min": 0.0, "max": 30.0, "step": 0.01}),
|
||||
"flow_shift": ("FLOAT", {"default": 9.0, "min": 0.0, "max": 30.0, "step": 0.01}),
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
|
||||
"force_offload": ("BOOLEAN", {"default": True}),
|
||||
|
||||
@@ -587,7 +588,7 @@ class HyVideoSampler:
|
||||
FUNCTION = "process"
|
||||
CATEGORY = "HunyuanVideoWrapper"
|
||||
|
||||
def process(self, model, hyvid_embeds, steps, guidance_scale, seed, width, height, num_frames, samples=None, denoise_strength=1.0, force_offload=True):
|
||||
def process(self, model, hyvid_embeds, flow_shift, steps, guidance_scale, seed, width, height, num_frames, samples=None, denoise_strength=1.0, force_offload=True):
|
||||
mm.unload_all_models()
|
||||
mm.soft_empty_cache()
|
||||
|
||||
@@ -622,6 +623,8 @@ class HyVideoSampler:
|
||||
model["pipe"].transformer, num_frames, target_height, target_width
|
||||
)
|
||||
n_tokens = freqs_cos.shape[0]
|
||||
|
||||
model["pipe"].scheduler.shift = flow_shift
|
||||
|
||||
# autocast_context = torch.autocast(
|
||||
# mm.get_autocast_device(device), dtype=dtype
|
||||
|
||||
Reference in New Issue
Block a user