Spaces:
Paused
Paused
Update pipeline_ltx_video.py
Browse files- pipeline_ltx_video.py +30 -15
pipeline_ltx_video.py
CHANGED
|
@@ -989,24 +989,39 @@ class LTXVideoPipeline(DiffusionPipeline):
|
|
| 989 |
# here `guidance_scale` is defined analog to the guidance weight `w` of equation (2)
|
| 990 |
# of the Imagen paper: https://arxiv.org/pdf/2205.11487.pdf . `guidance_scale = 1`
|
| 991 |
# corresponds to doing no classifier free guidance.
|
| 992 |
-
|
| 993 |
-
|
| 994 |
-
|
| 995 |
-
|
| 996 |
-
|
| 997 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 998 |
|
| 999 |
-
|
| 1000 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1001 |
else:
|
| 1002 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1003 |
|
| 1004 |
-
|
| 1005 |
-
|
| 1006 |
-
|
| 1007 |
-
|
| 1008 |
-
|
| 1009 |
-
|
| 1010 |
|
| 1011 |
# Normalize skip_block_list to always be None or a list of lists matching timesteps
|
| 1012 |
if skip_block_list is not None:
|
|
|
|
| 989 |
# here `guidance_scale` is defined analog to the guidance weight `w` of equation (2)
|
| 990 |
# of the Imagen paper: https://arxiv.org/pdf/2205.11487.pdf . `guidance_scale = 1`
|
| 991 |
# corresponds to doing no classifier free guidance.
|
| 992 |
+
# Bloco Final e 脿 Prova de Balas
|
| 993 |
+
def _remap_guidance_list(param, timesteps, guidance_mapping):
|
| 994 |
+
if isinstance(param, list):
|
| 995 |
+
# Caso do atalho: [1] deve ser esticado para o tamanho de timesteps
|
| 996 |
+
if len(param) == 1:
|
| 997 |
+
return param * len(timesteps)
|
| 998 |
+
# Caso normal: remapeia usando a guidance_mapping
|
| 999 |
+
else:
|
| 1000 |
+
return [param[guidance_mapping[i]] for i in range(len(timesteps))]
|
| 1001 |
+
# Caso de valor 煤nico (float/int): estica para o tamanho de timesteps
|
| 1002 |
+
else:
|
| 1003 |
+
return [param] * len(timesteps)
|
| 1004 |
|
| 1005 |
+
# Cria a guidance_mapping segura
|
| 1006 |
+
if guidance_timesteps:
|
| 1007 |
+
guidance_mapping = []
|
| 1008 |
+
for timestep in timesteps:
|
| 1009 |
+
indices = [i for i, val in enumerate(guidance_timesteps) if val >= timestep]
|
| 1010 |
+
guidance_mapping.append(indices[-1] if indices else len(guidance_timesteps) - 1)
|
| 1011 |
else:
|
| 1012 |
+
# Fallback seguro que previne o NameError
|
| 1013 |
+
guidance_mapping = list(range(len(timesteps)))
|
| 1014 |
+
|
| 1015 |
+
guidance_scale = _remap_guidance_list(guidance_scale, timesteps, guidance_mapping)
|
| 1016 |
+
stg_scale = _remap_guidance_list(stg_scale, timesteps, guidance_mapping)
|
| 1017 |
+
rescaling_scale = _remap_guidance_list(rescaling_scale, timesteps, guidance_mapping)
|
| 1018 |
|
| 1019 |
+
# L贸gica especial para skip_block_list
|
| 1020 |
+
if skip_block_list is not None:
|
| 1021 |
+
if len(skip_block_list) > 0 and not isinstance(skip_block_list[0], list):
|
| 1022 |
+
skip_block_list = [skip_block_list] * len(timesteps)
|
| 1023 |
+
elif isinstance(skip_block_list, list) and len(skip_block_list) > 1: # Apenas remapeia se for uma lista de listas
|
| 1024 |
+
skip_block_list = [skip_block_list[guidance_mapping[i]] for i in range(len(timesteps))]
|
| 1025 |
|
| 1026 |
# Normalize skip_block_list to always be None or a list of lists matching timesteps
|
| 1027 |
if skip_block_list is not None:
|