Update run_generator.py
Browse files- run_generator.py +51 -23
run_generator.py
CHANGED
|
@@ -11,20 +11,17 @@ import subprocess
|
|
| 11 |
import random
|
| 12 |
import argparse
|
| 13 |
from typing import Sequence, Mapping, Any, Union
|
| 14 |
-
import shutil
|
| 15 |
|
| 16 |
-
# --- 0. κΈ°λ³Έ μ€μ λ° μΈμ νμ±
|
| 17 |
def parse_args():
|
| 18 |
parser = argparse.ArgumentParser(description="ComfyUI Video Generation Script with All Controls from 1.py")
|
| 19 |
parser.add_argument("--positive_prompt", type=str, required=True); parser.add_argument("--negative_prompt", type=str, required=True)
|
| 20 |
parser.add_argument("--width", type=int, required=True); parser.add_argument("--height", type=int, required=True)
|
| 21 |
parser.add_argument("--length", type=int, required=True); parser.add_argument("--upscale_ratio", type=float, required=True)
|
| 22 |
-
|
| 23 |
-
# β¨ μμ : CFG μΈμ λΆλ¦¬
|
| 24 |
parser.add_argument("--steps", type=int, default=4)
|
| 25 |
-
parser.add_argument("--cfg_high", type=float, default=1.0)
|
| 26 |
-
parser.add_argument("--cfg_low", type=float, default=1.0)
|
| 27 |
-
|
| 28 |
parser.add_argument("--sampler_name_high", type=str, default="euler"); parser.add_argument("--scheduler_high", type=str, default="simple")
|
| 29 |
parser.add_argument("--sampler_name_low", type=str, default="euler"); parser.add_argument("--scheduler_low", type=str, default="simple")
|
| 30 |
parser.add_argument("--noise_seed", type=int, default=-1); parser.add_argument("--split_point_percent", type=float, default=50.0)
|
|
@@ -103,10 +100,41 @@ def import_custom_nodes() -> None:
|
|
| 103 |
def main():
|
| 104 |
args = parse_args()
|
| 105 |
print("π λμμ μμ±μ μμν©λλ€ (Full Control Mode, VRAM Optimized)...\n")
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
os.makedirs(f"{COMFYUI_BASE_PATH}/output/interpolated", exist_ok=True)
|
|
|
|
| 110 |
add_comfyui_directory_to_sys_path()
|
| 111 |
try: from utils.extra_config import load_extra_path_config
|
| 112 |
except ImportError: print("β οΈ ComfyUIμ extra_model_paths.yaml λ‘λ© μ€ν¨ (무μνκ³ μ§ν)"); load_extra_path_config = lambda x: None
|
|
@@ -126,10 +154,9 @@ def main():
|
|
| 126 |
clipvisionencode=NODE_CLASS_MAPPINGS["CLIPVisionEncode"]()
|
| 127 |
pathchsageattentionkj=NODE_CLASS_MAPPINGS["PathchSageAttentionKJ"]()
|
| 128 |
|
| 129 |
-
# --- β¨ 1λ¨κ³: CLIP Vision λ‘μ§ μΆκ° λ° λ©λͺ¨λ¦¬ ν΄μ
|
| 130 |
print("\n1λ¨κ³: λ°μ΄ν° λ‘λ© λ° μ΄κΈ° Latent μμ± μ€...");
|
| 131 |
print(f" - CLIP λ‘λ©: {args.clip_name}");
|
| 132 |
-
# β¨ SyntaxError μμ : λΆνμν \ μ κ±°
|
| 133 |
cliploader_460 = cliploader.load_clip(clip_name=args.clip_name, type="wan", device="default");
|
| 134 |
cliptextencode_462 = cliptextencode.encode(text=args.positive_prompt, clip=get_value_at_index(cliploader_460, 0));
|
| 135 |
cliptextencode_463 = cliptextencode.encode(text=args.negative_prompt, clip=get_value_at_index(cliploader_460, 0));
|
|
@@ -137,7 +164,7 @@ def main():
|
|
| 137 |
|
| 138 |
imageresizekjv2_401 = imageresizekjv2.resize(
|
| 139 |
width=args.width, height=args.height,
|
| 140 |
-
upscale_method=args.input_resize_algo,
|
| 141 |
image=get_value_at_index(loadimage_88, 0), keep_proportion="crop",
|
| 142 |
pad_color="0, 0, 0", crop_position="center", divisible_by=2,
|
| 143 |
unique_id=random.randint(1, 2**64)
|
|
@@ -149,7 +176,7 @@ def main():
|
|
| 149 |
clipvisionencode_cv = clipvisionencode.encode(
|
| 150 |
crop="none",
|
| 151 |
clip_vision=get_value_at_index(clipvisionloader_cv, 0),
|
| 152 |
-
image=get_value_at_index(imageresizekjv2_401, 0)
|
| 153 |
);
|
| 154 |
clip_vision_output = get_value_at_index(clipvisionencode_cv, 0)
|
| 155 |
|
|
@@ -164,7 +191,7 @@ def main():
|
|
| 164 |
positive=get_value_at_index(cliptextencode_462, 0),
|
| 165 |
negative=get_value_at_index(cliptextencode_463, 0),
|
| 166 |
vae=get_value_at_index(vaeloader_temp, 0),
|
| 167 |
-
clip_vision_output=clip_vision_output,
|
| 168 |
start_image=get_value_at_index(imageresizekjv2_401, 0)
|
| 169 |
);
|
| 170 |
|
|
@@ -183,7 +210,7 @@ def main():
|
|
| 183 |
if args.lora_high_2_name != "None": print(f" - H LoRA 2: {args.lora_high_2_name}"); model_for_patching, clip = loraloader.load_lora(lora_name=args.lora_high_2_name, strength_model=args.lora_high_2_strength_model, strength_clip=args.lora_high_2_strength_clip, model=model_for_patching, clip=clip)
|
| 184 |
shifted_model = get_value_at_index(modelsamplingsd3.patch(shift=args.shift, model=model_for_patching), 0); final_model = shifted_model;
|
| 185 |
|
| 186 |
-
#
|
| 187 |
ksampleradvanced_466 = ksampleradvanced.sample(add_noise="enable", noise_seed=final_seed, steps=args.steps, cfg=args.cfg_high, sampler_name=args.sampler_name_high, scheduler=args.scheduler_high, start_at_step=0, end_at_step=split_step, return_with_leftover_noise="enable", model=final_model, positive=get_value_at_index(wanimagetovideo_464, 0), negative=get_value_at_index(wanimagetovideo_464, 1), latent_image=get_value_at_index(wanimagetovideo_464, 2));
|
| 188 |
|
| 189 |
if to_bool(args.sageattention): del pathchsageattentionkj_124
|
|
@@ -195,7 +222,7 @@ def main():
|
|
| 195 |
if args.lora_low_2_name != "None": print(f" - L LoRA 2: {args.lora_low_2_name}"); model_for_patching, clip = loraloader.load_lora(lora_name=args.lora_low_2_name, strength_model=args.lora_low_2_strength_model, strength_clip=args.lora_low_2_strength_clip, model=model_for_patching, clip=clip)
|
| 196 |
shifted_model = get_value_at_index(modelsamplingsd3.patch(shift=args.shift, model=model_for_patching), 0); final_model = shifted_model;
|
| 197 |
|
| 198 |
-
#
|
| 199 |
ksampleradvanced_465 = ksampleradvanced.sample(add_noise="disable", noise_seed=final_seed, steps=args.steps, cfg=args.cfg_low, sampler_name=args.sampler_name_low, scheduler=args.scheduler_low, start_at_step=split_step, end_at_step=10000, return_with_leftover_noise="disable", model=final_model, positive=get_value_at_index(wanimagetovideo_464, 0), negative=get_value_at_index(wanimagetovideo_464, 1), latent_image=get_value_at_index(ksampleradvanced_466, 0));
|
| 200 |
|
| 201 |
if to_bool(args.sageattention): del pathchsageattentionkj_129
|
|
@@ -228,7 +255,7 @@ def main():
|
|
| 228 |
if loaded_images is None: print(" - (κ²½κ³ ) 건λλΈ μ μλ μ΄λ―Έμ§κ° λ‘λλμμ΅λλ€, μ΄ λ°°μΉλ₯Ό 건λλλλ€."); continue
|
| 229 |
imageupscale_chunk = imageupscalewithmodel.upscale(upscale_model=get_value_at_index(upscalemodelloader_384, 0), image=loaded_images);
|
| 230 |
imagescale_chunk = imagescaleby.upscale(
|
| 231 |
-
upscale_method=args.output_resize_algo,
|
| 232 |
scale_by=scale_by_ratio,
|
| 233 |
image=get_value_at_index(imageupscale_chunk, 0)
|
| 234 |
);
|
|
@@ -237,7 +264,7 @@ def main():
|
|
| 237 |
del upscalemodelloader_384; clear_memory(); combine_input_dir_for_ffmpeg = f"{COMFYUI_BASE_PATH}/output/up"; print("5λ¨κ³ μλ£.")
|
| 238 |
else: print("\n5λ¨κ³: μ
μ€μΌμΌλ§ 건λλ (λΉμ¨ 1.0).")
|
| 239 |
|
| 240 |
-
# --- β¨ 6λ¨κ³: RIFE μ²ν¬ λ‘μ§ μμ (Overlap μ μ©)
|
| 241 |
print("\n6λ¨κ³: λΉλμ€ κ²°ν© μ€λΉ μ€..."); final_frame_rate = float(args.frame_rate); ffmpeg_input_dir = combine_input_dir_for_ffmpeg
|
| 242 |
if to_bool(args.interpolation):
|
| 243 |
print(" - νλ μ λ³΄κ° (RIFE)μ νμ±νν©λλ€."); interpolated_dir = f"{COMFYUI_BASE_PATH}/output/interpolated"; source_dir = combine_input_dir_for_ffmpeg
|
|
@@ -277,7 +304,7 @@ def main():
|
|
| 277 |
|
| 278 |
if loaded_images is None:
|
| 279 |
print(" - (κ²½κ³ ) 건λλΈ μ μλ μ΄λ―Έμ§κ° λ‘λλμμ΅λλ€, μ΄ λ°°μΉλ₯Ό οΏ½οΏ½οΏ½λλλλ€.");
|
| 280 |
-
current_frame_idx += chunk_size
|
| 281 |
is_first_chunk = False
|
| 282 |
continue
|
| 283 |
|
|
@@ -291,7 +318,7 @@ def main():
|
|
| 291 |
|
| 292 |
images_to_save = rife_chunk_result_tensor
|
| 293 |
if not is_first_chunk:
|
| 294 |
-
#
|
| 295 |
print(f" - (Overlap) μ€λ³΅ νλ μ 1κ° μ κ±° ν μ μ₯")
|
| 296 |
images_to_save = rife_chunk_result_tensor[1:]
|
| 297 |
|
|
@@ -307,7 +334,7 @@ def main():
|
|
| 307 |
# --- 6λ¨κ³ μμ μλ£ ---
|
| 308 |
|
| 309 |
print(f" - μ΅μ’
λΉλμ€λ₯Ό FFmpeg ({args.video_encoder})λ‘ κ²°ν©ν©λλ€..."); print(f" - μ
λ ₯ ν΄λ: '{ffmpeg_input_dir}'")
|
| 310 |
-
input_pattern = os.path.join(ffmpeg_input_dir, "example_%05d_.png")
|
| 311 |
timestamp = time.strftime("%Y%m%d-%H%M%S"); output_filename = f"AnimateDiff_{timestamp}.mp4"; output_path = os.path.join(COMFYUI_BASE_PATH, "output", output_filename)
|
| 312 |
ffmpeg_cmd = ["ffmpeg", "-framerate", str(final_frame_rate), "-i", input_pattern]
|
| 313 |
encoder_choice = args.video_encoder
|
|
@@ -328,7 +355,7 @@ def main():
|
|
| 328 |
except Exception as e: print(f" β μ€λ₯: FFmpeg μ€ν μ€ μμμΉ λͺ»ν μ€λ₯ λ°μ: {e}"); raise
|
| 329 |
print("β
λͺ¨λ λ¨κ³ μλ£.")
|
| 330 |
|
| 331 |
-
# --- β¨ UnboundLocalError ν΄κ²° λ° λ³΅μ¬ λ‘μ§ (μ΅μ’
)
|
| 332 |
latest_video = None
|
| 333 |
|
| 334 |
if os.path.exists(output_path):
|
|
@@ -360,3 +387,4 @@ def main():
|
|
| 360 |
|
| 361 |
if __name__ == "__main__":
|
| 362 |
main()
|
|
|
|
|
|
| 11 |
import random
|
| 12 |
import argparse
|
| 13 |
from typing import Sequence, Mapping, Any, Union
|
| 14 |
+
import shutil
|
| 15 |
|
| 16 |
+
# --- 0. κΈ°λ³Έ μ€μ λ° μΈμ νμ± ---
|
| 17 |
def parse_args():
|
| 18 |
parser = argparse.ArgumentParser(description="ComfyUI Video Generation Script with All Controls from 1.py")
|
| 19 |
parser.add_argument("--positive_prompt", type=str, required=True); parser.add_argument("--negative_prompt", type=str, required=True)
|
| 20 |
parser.add_argument("--width", type=int, required=True); parser.add_argument("--height", type=int, required=True)
|
| 21 |
parser.add_argument("--length", type=int, required=True); parser.add_argument("--upscale_ratio", type=float, required=True)
|
|
|
|
|
|
|
| 22 |
parser.add_argument("--steps", type=int, default=4)
|
| 23 |
+
parser.add_argument("--cfg_high", type=float, default=1.0)
|
| 24 |
+
parser.add_argument("--cfg_low", type=float, default=1.0)
|
|
|
|
| 25 |
parser.add_argument("--sampler_name_high", type=str, default="euler"); parser.add_argument("--scheduler_high", type=str, default="simple")
|
| 26 |
parser.add_argument("--sampler_name_low", type=str, default="euler"); parser.add_argument("--scheduler_low", type=str, default="simple")
|
| 27 |
parser.add_argument("--noise_seed", type=int, default=-1); parser.add_argument("--split_point_percent", type=float, default=50.0)
|
|
|
|
| 100 |
def main():
|
| 101 |
args = parse_args()
|
| 102 |
print("π λμμ μμ±μ μμν©λλ€ (Full Control Mode, VRAM Optimized)...\n")
|
| 103 |
+
|
| 104 |
+
# π¨π¨π¨ μμ λ λΆλΆ μμ: .mp4, .mkv, .webm νμΌμ μ μΈνκ³ output ν΄λ μ 리 π¨π¨π¨
|
| 105 |
+
output_dir = os.path.join(COMFYUI_BASE_PATH, 'output')
|
| 106 |
+
print(f" - μ΄μ μΆλ ₯λ¬Ό μ 리 μ€... (Output: {output_dir})")
|
| 107 |
+
|
| 108 |
+
deleted_count = 0
|
| 109 |
+
try:
|
| 110 |
+
# output ν΄λ λ΄μ λͺ¨λ νμΌκ³Ό ν΄λ λͺ©λ‘μ κ°μ Έμ΅λλ€.
|
| 111 |
+
for item_name in os.listdir(output_dir):
|
| 112 |
+
item_path = os.path.join(output_dir, item_name)
|
| 113 |
+
|
| 114 |
+
# π‘ 쑰건: λΉλμ€ νμΌ νμ₯μ(.mp4, .mkv, .webm)λ μμ νμ§ μκ³ λ³΄μ‘΄ν©λλ€.
|
| 115 |
+
if item_name.lower().endswith(('.mp4', '.mkv', '.webm')):
|
| 116 |
+
print(f" - ποΈ λΉλμ€ νμΌ '{item_name}'μ 보쑴ν©λλ€.")
|
| 117 |
+
continue
|
| 118 |
+
|
| 119 |
+
# νμΌ λλ λ§ν¬μΈ κ²½μ° μμ
|
| 120 |
+
if os.path.isfile(item_path) or os.path.islink(item_path):
|
| 121 |
+
os.unlink(item_path)
|
| 122 |
+
deleted_count += 1
|
| 123 |
+
# ν΄λμΈ κ²½μ° μ¬κ·μ μΌλ‘ μμ
|
| 124 |
+
elif os.path.isdir(item_path):
|
| 125 |
+
shutil.rmtree(item_path)
|
| 126 |
+
deleted_count += 1
|
| 127 |
+
|
| 128 |
+
print(f" β
μ 리 μλ£. 보쑴λ λΉλμ€ μΈ {deleted_count}κ°μ νλͺ©μ΄ μμ λμμ΅λλ€.")
|
| 129 |
+
except Exception as e:
|
| 130 |
+
print(f" β μΆλ ₯ ν΄λ μ 리 μ€ μ€λ₯ λ°μ: {e}")
|
| 131 |
+
# π¨π¨π¨ μμ λ λΆλΆ λ π¨π¨π¨
|
| 132 |
+
|
| 133 |
+
# μμ ν΄λ μ¬μμ± (μ 리 κ³Όμ μμ μμ λμμ μ μμ)
|
| 134 |
+
os.makedirs(f"{COMFYUI_BASE_PATH}/output/temp", exist_ok=True);
|
| 135 |
+
os.makedirs(f"{COMFYUI_BASE_PATH}/output/up", exist_ok=True)
|
| 136 |
os.makedirs(f"{COMFYUI_BASE_PATH}/output/interpolated", exist_ok=True)
|
| 137 |
+
|
| 138 |
add_comfyui_directory_to_sys_path()
|
| 139 |
try: from utils.extra_config import load_extra_path_config
|
| 140 |
except ImportError: print("β οΈ ComfyUIμ extra_model_paths.yaml λ‘λ© μ€ν¨ (무μνκ³ μ§ν)"); load_extra_path_config = lambda x: None
|
|
|
|
| 154 |
clipvisionencode=NODE_CLASS_MAPPINGS["CLIPVisionEncode"]()
|
| 155 |
pathchsageattentionkj=NODE_CLASS_MAPPINGS["PathchSageAttentionKJ"]()
|
| 156 |
|
| 157 |
+
# --- β¨ 1λ¨κ³: CLIP Vision λ‘μ§ μΆκ° λ° λ©λͺ¨λ¦¬ ν΄μ ---
|
| 158 |
print("\n1λ¨κ³: λ°μ΄ν° λ‘λ© λ° μ΄κΈ° Latent μμ± μ€...");
|
| 159 |
print(f" - CLIP λ‘λ©: {args.clip_name}");
|
|
|
|
| 160 |
cliploader_460 = cliploader.load_clip(clip_name=args.clip_name, type="wan", device="default");
|
| 161 |
cliptextencode_462 = cliptextencode.encode(text=args.positive_prompt, clip=get_value_at_index(cliploader_460, 0));
|
| 162 |
cliptextencode_463 = cliptextencode.encode(text=args.negative_prompt, clip=get_value_at_index(cliploader_460, 0));
|
|
|
|
| 164 |
|
| 165 |
imageresizekjv2_401 = imageresizekjv2.resize(
|
| 166 |
width=args.width, height=args.height,
|
| 167 |
+
upscale_method=args.input_resize_algo,
|
| 168 |
image=get_value_at_index(loadimage_88, 0), keep_proportion="crop",
|
| 169 |
pad_color="0, 0, 0", crop_position="center", divisible_by=2,
|
| 170 |
unique_id=random.randint(1, 2**64)
|
|
|
|
| 176 |
clipvisionencode_cv = clipvisionencode.encode(
|
| 177 |
crop="none",
|
| 178 |
clip_vision=get_value_at_index(clipvisionloader_cv, 0),
|
| 179 |
+
image=get_value_at_index(imageresizekjv2_401, 0)
|
| 180 |
);
|
| 181 |
clip_vision_output = get_value_at_index(clipvisionencode_cv, 0)
|
| 182 |
|
|
|
|
| 191 |
positive=get_value_at_index(cliptextencode_462, 0),
|
| 192 |
negative=get_value_at_index(cliptextencode_463, 0),
|
| 193 |
vae=get_value_at_index(vaeloader_temp, 0),
|
| 194 |
+
clip_vision_output=clip_vision_output,
|
| 195 |
start_image=get_value_at_index(imageresizekjv2_401, 0)
|
| 196 |
);
|
| 197 |
|
|
|
|
| 210 |
if args.lora_high_2_name != "None": print(f" - H LoRA 2: {args.lora_high_2_name}"); model_for_patching, clip = loraloader.load_lora(lora_name=args.lora_high_2_name, strength_model=args.lora_high_2_strength_model, strength_clip=args.lora_high_2_strength_clip, model=model_for_patching, clip=clip)
|
| 211 |
shifted_model = get_value_at_index(modelsamplingsd3.patch(shift=args.shift, model=model_for_patching), 0); final_model = shifted_model;
|
| 212 |
|
| 213 |
+
# μμ : cfg=args.cfg_high μ¬μ©
|
| 214 |
ksampleradvanced_466 = ksampleradvanced.sample(add_noise="enable", noise_seed=final_seed, steps=args.steps, cfg=args.cfg_high, sampler_name=args.sampler_name_high, scheduler=args.scheduler_high, start_at_step=0, end_at_step=split_step, return_with_leftover_noise="enable", model=final_model, positive=get_value_at_index(wanimagetovideo_464, 0), negative=get_value_at_index(wanimagetovideo_464, 1), latent_image=get_value_at_index(wanimagetovideo_464, 2));
|
| 215 |
|
| 216 |
if to_bool(args.sageattention): del pathchsageattentionkj_124
|
|
|
|
| 222 |
if args.lora_low_2_name != "None": print(f" - L LoRA 2: {args.lora_low_2_name}"); model_for_patching, clip = loraloader.load_lora(lora_name=args.lora_low_2_name, strength_model=args.lora_low_2_strength_model, strength_clip=args.lora_low_2_strength_clip, model=model_for_patching, clip=clip)
|
| 223 |
shifted_model = get_value_at_index(modelsamplingsd3.patch(shift=args.shift, model=model_for_patching), 0); final_model = shifted_model;
|
| 224 |
|
| 225 |
+
# μμ : cfg=args.cfg_low μ¬μ©
|
| 226 |
ksampleradvanced_465 = ksampleradvanced.sample(add_noise="disable", noise_seed=final_seed, steps=args.steps, cfg=args.cfg_low, sampler_name=args.sampler_name_low, scheduler=args.scheduler_low, start_at_step=split_step, end_at_step=10000, return_with_leftover_noise="disable", model=final_model, positive=get_value_at_index(wanimagetovideo_464, 0), negative=get_value_at_index(wanimagetovideo_464, 1), latent_image=get_value_at_index(ksampleradvanced_466, 0));
|
| 227 |
|
| 228 |
if to_bool(args.sageattention): del pathchsageattentionkj_129
|
|
|
|
| 255 |
if loaded_images is None: print(" - (κ²½κ³ ) 건λλΈ μ μλ μ΄λ―Έμ§κ° λ‘λλμμ΅λλ€, μ΄ λ°°μΉλ₯Ό 건λλλλ€."); continue
|
| 256 |
imageupscale_chunk = imageupscalewithmodel.upscale(upscale_model=get_value_at_index(upscalemodelloader_384, 0), image=loaded_images);
|
| 257 |
imagescale_chunk = imagescaleby.upscale(
|
| 258 |
+
upscale_method=args.output_resize_algo,
|
| 259 |
scale_by=scale_by_ratio,
|
| 260 |
image=get_value_at_index(imageupscale_chunk, 0)
|
| 261 |
);
|
|
|
|
| 264 |
del upscalemodelloader_384; clear_memory(); combine_input_dir_for_ffmpeg = f"{COMFYUI_BASE_PATH}/output/up"; print("5λ¨κ³ μλ£.")
|
| 265 |
else: print("\n5λ¨κ³: μ
μ€μΌμΌλ§ 건λλ (λΉμ¨ 1.0).")
|
| 266 |
|
| 267 |
+
# --- β¨ 6λ¨κ³: RIFE μ²ν¬ λ‘μ§ μμ (Overlap μ μ©) ---
|
| 268 |
print("\n6λ¨κ³: λΉλμ€ κ²°ν© μ€λΉ μ€..."); final_frame_rate = float(args.frame_rate); ffmpeg_input_dir = combine_input_dir_for_ffmpeg
|
| 269 |
if to_bool(args.interpolation):
|
| 270 |
print(" - νλ μ λ³΄κ° (RIFE)μ νμ±νν©λλ€."); interpolated_dir = f"{COMFYUI_BASE_PATH}/output/interpolated"; source_dir = combine_input_dir_for_ffmpeg
|
|
|
|
| 304 |
|
| 305 |
if loaded_images is None:
|
| 306 |
print(" - (κ²½κ³ ) 건λλΈ μ μλ μ΄λ―Έμ§κ° λ‘λλμμ΅λλ€, μ΄ λ°°μΉλ₯Ό οΏ½οΏ½οΏ½λλλλ€.");
|
| 307 |
+
current_frame_idx += chunk_size
|
| 308 |
is_first_chunk = False
|
| 309 |
continue
|
| 310 |
|
|
|
|
| 318 |
|
| 319 |
images_to_save = rife_chunk_result_tensor
|
| 320 |
if not is_first_chunk:
|
| 321 |
+
# 첫 λ²μ§Έκ° μλ λͺ¨λ μ²ν¬λ κ²ΉμΉλ 첫 νλ μμ μ κ±° (ν
μ μ¬λΌμ΄μ±)
|
| 322 |
print(f" - (Overlap) μ€λ³΅ νλ μ 1κ° μ κ±° ν μ μ₯")
|
| 323 |
images_to_save = rife_chunk_result_tensor[1:]
|
| 324 |
|
|
|
|
| 334 |
# --- 6λ¨κ³ μμ μλ£ ---
|
| 335 |
|
| 336 |
print(f" - μ΅μ’
λΉλμ€λ₯Ό FFmpeg ({args.video_encoder})λ‘ κ²°ν©ν©λλ€..."); print(f" - μ
λ ₯ ν΄λ: '{ffmpeg_input_dir}'")
|
| 337 |
+
input_pattern = os.path.join(ffmpeg_input_dir, "example_%05d_.png")
|
| 338 |
timestamp = time.strftime("%Y%m%d-%H%M%S"); output_filename = f"AnimateDiff_{timestamp}.mp4"; output_path = os.path.join(COMFYUI_BASE_PATH, "output", output_filename)
|
| 339 |
ffmpeg_cmd = ["ffmpeg", "-framerate", str(final_frame_rate), "-i", input_pattern]
|
| 340 |
encoder_choice = args.video_encoder
|
|
|
|
| 355 |
except Exception as e: print(f" β μ€λ₯: FFmpeg μ€ν μ€ μμμΉ λͺ»ν μ€λ₯ λ°μ: {e}"); raise
|
| 356 |
print("β
λͺ¨λ λ¨κ³ μλ£.")
|
| 357 |
|
| 358 |
+
# --- β¨ UnboundLocalError ν΄κ²° λ° λ³΅μ¬ λ‘μ§ (μ΅μ’
) ---
|
| 359 |
latest_video = None
|
| 360 |
|
| 361 |
if os.path.exists(output_path):
|
|
|
|
| 387 |
|
| 388 |
if __name__ == "__main__":
|
| 389 |
main()
|
| 390 |
+
|