FangSen9000 Claude commited on
Commit ·
6b0f4c6
1
Parent(s): 2f8d0cb
Add optimized ControlNeXt-SVD-v2 implementation with direct pose input support
Browse filesMajor improvements:
- Add run_controlnext_optimized.py with FP16 support, xformers, and GEGLU optimization
- Add direct pose video/images input to bypass DWPose extraction
- Implement smart output naming based on input filename
- Add ComfyUI-ControlNeXt-SVD reference implementation for analysis
- Update README with optimized inference examples
- Add easy_dwpose integration for pose extraction
- Generate example pose videos with text2pose system
Performance optimizations:
- Default FP16 precision for faster inference
- Memory-efficient attention with xformers
- Chunked VAE decoding to reduce memory usage
- GEGLU inplace operations for memory savings
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- ControlNeXt-SVD-v2/git_push2.log +0 -15
- ControlNeXt-SVD-v2/run_controlnext_optimized.py +383 -0
- ControlNeXt-SVD-v2/utils/__pycache__/pre_process_direct.cpython-310.pyc +0 -0
- ControlNeXt-SVD-v2/utils/pre_process_direct.py +182 -0
- README.md +16 -28
- easy_dwpose/__pycache__/__init__.cpython-310.pyc +0 -0
- easy_dwpose/__pycache__/dwpose.cpython-310.pyc +0 -0
- easy_dwpose/body_estimation/__pycache__/__init__.cpython-310.pyc +0 -0
- easy_dwpose/body_estimation/__pycache__/detector.cpython-310.pyc +0 -0
- easy_dwpose/body_estimation/__pycache__/pose.cpython-310.pyc +0 -0
- easy_dwpose/body_estimation/__pycache__/utils.cpython-310.pyc +0 -0
- easy_dwpose/body_estimation/__pycache__/wholebody.cpython-310.pyc +0 -0
- easy_dwpose/draw/__pycache__/__init__.cpython-310.pyc +0 -0
- easy_dwpose/draw/__pycache__/controlnext.cpython-310.pyc +0 -0
- easy_dwpose/draw/__pycache__/openpose.cpython-310.pyc +0 -0
- generated_pose_video/GOOD_AFTERNOON_25073_01435_20250803_222800.mp4 +3 -0
- generated_sign_video/output.mp4 +2 -2
- generated_sign_video/test_1.mp4 +2 -2
- generated_sign_video_direct/GOOD_AFTERNOON_25073_01435_20250803_222800.mp4 +3 -0
- generated_sign_video_direct/GOOD_AFTERNOON_25073_01435_20250803_222800_combined.mp4 +3 -0
- useless/abandon_cmd.md +64 -0
- ControlNeXt-SVD-v2/run_controlnext.py → useless/run_controlnext_v1(无优化.py +0 -0
- useless/run_with_pose_video.sh +59 -0
ControlNeXt-SVD-v2/git_push2.log
DELETED
|
@@ -1,15 +0,0 @@
|
|
| 1 |
-
Uploading LFS objects: 100% (25/25), 6.2 GB | 0 B/s, done.
|
| 2 |
-
remote: [31m-------------------------------------------------------------------------[0m
|
| 3 |
-
remote: [31mYour push was rejected because it contains binary files.[0m
|
| 4 |
-
remote: [31mPlease use https://git-lfs.github.com/ to store binary files.[0m
|
| 5 |
-
remote: [31mSee also: https://hf.co/docs/hub/repositories-getting-started#terminal[0m
|
| 6 |
-
remote: [31m[0m
|
| 7 |
-
remote: [31mOffending files:[0m
|
| 8 |
-
remote: [31m - ref_img_dict/01.jpeg (ref: refs/heads/main)[0m
|
| 9 |
-
remote: [31m - ref_img_dict/02.jpeg (ref: refs/heads/main)[0m
|
| 10 |
-
remote: [31m - ref_img_dict/03.jpeg (ref: refs/heads/main)[0m
|
| 11 |
-
remote: [31m - ref_img_dict/04.jpeg (ref: refs/heads/main)[0m
|
| 12 |
-
remote: [31m-------------------------------------------------------------------------[0m
|
| 13 |
-
To hf.co:datasets/FangSen9000/StableSigner
|
| 14 |
-
! [remote rejected] main -> main (pre-receive hook declined)
|
| 15 |
-
error: failed to push some refs to 'hf.co:datasets/FangSen9000/StableSigner'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ControlNeXt-SVD-v2/run_controlnext_optimized.py
ADDED
|
@@ -0,0 +1,383 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import torch
|
| 3 |
+
import numpy as np
|
| 4 |
+
from PIL import Image
|
| 5 |
+
from pipeline.pipeline_stable_video_diffusion_controlnext import StableVideoDiffusionPipelineControlNeXt
|
| 6 |
+
from models.controlnext_vid_svd import ControlNeXtSDVModel
|
| 7 |
+
from models.unet_spatio_temporal_condition_controlnext import UNetSpatioTemporalConditionControlNeXtModel
|
| 8 |
+
from transformers import CLIPVisionModelWithProjection
|
| 9 |
+
import re
|
| 10 |
+
from diffusers import AutoencoderKLTemporalDecoder
|
| 11 |
+
from moviepy.editor import ImageSequenceClip
|
| 12 |
+
from decord import VideoReader
|
| 13 |
+
import argparse
|
| 14 |
+
from safetensors.torch import load_file
|
| 15 |
+
from utils.pre_process import preprocess
|
| 16 |
+
from utils.pre_process_direct import preprocess_direct_pose, load_pose_from_images
|
| 17 |
+
import gc
|
| 18 |
+
|
| 19 |
+
# Patch GEGLU for memory optimization
|
| 20 |
+
try:
|
| 21 |
+
import diffusers.models.activations
|
| 22 |
+
def patch_geglu_inplace():
|
| 23 |
+
"""Patch GEGLU with inplace multiplication to save GPU memory."""
|
| 24 |
+
def forward(self, hidden_states):
|
| 25 |
+
hidden_states, gate = self.proj(hidden_states).chunk(2, dim=-1)
|
| 26 |
+
return hidden_states.mul_(self.gelu(gate))
|
| 27 |
+
diffusers.models.activations.GEGLU.forward = forward
|
| 28 |
+
patch_geglu_inplace()
|
| 29 |
+
print("✓ GEGLU optimization applied")
|
| 30 |
+
except:
|
| 31 |
+
pass
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def write_mp4(video_path, samples, fps=14, audio_bitrate="192k"):
|
| 35 |
+
clip = ImageSequenceClip(samples, fps=fps)
|
| 36 |
+
clip.write_videofile(video_path, audio_codec="aac", audio_bitrate=audio_bitrate,
|
| 37 |
+
ffmpeg_params=["-crf", "18", "-preset", "slow"])
|
| 38 |
+
|
| 39 |
+
def save_vid_side_by_side(batch_output, validation_control_images, output_folder, fps, base_filename="output"):
|
| 40 |
+
# Helper function to convert tensors to PIL images and save as GIF
|
| 41 |
+
flattened_batch_output = [img for sublist in batch_output for img in sublist]
|
| 42 |
+
|
| 43 |
+
# Use base filename for the output files
|
| 44 |
+
video_path = os.path.join(output_folder, f'{base_filename}_combined.mp4')
|
| 45 |
+
final_images = []
|
| 46 |
+
outputs = []
|
| 47 |
+
# Helper function to concatenate images horizontally
|
| 48 |
+
def get_concat_h(im1, im2):
|
| 49 |
+
dst = Image.new('RGB', (im1.width + im2.width, max(im1.height, im2.height)))
|
| 50 |
+
dst.paste(im1, (0, 0))
|
| 51 |
+
dst.paste(im2, (im1.width, 0))
|
| 52 |
+
return dst
|
| 53 |
+
for image_list in zip(validation_control_images, flattened_batch_output):
|
| 54 |
+
predict_img = image_list[1].resize(image_list[0].size)
|
| 55 |
+
result = get_concat_h(image_list[0], predict_img)
|
| 56 |
+
final_images.append(np.array(result))
|
| 57 |
+
outputs.append(np.array(predict_img))
|
| 58 |
+
write_mp4(video_path, final_images, fps=fps)
|
| 59 |
+
|
| 60 |
+
output_path = os.path.join(output_folder, f'{base_filename}.mp4')
|
| 61 |
+
write_mp4(output_path, outputs, fps=fps)
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def load_tensor(tensor_path):
|
| 65 |
+
if os.path.splitext(tensor_path)[1] == '.bin':
|
| 66 |
+
return torch.load(tensor_path)
|
| 67 |
+
elif os.path.splitext(tensor_path)[1] == ".safetensors":
|
| 68 |
+
return load_file(tensor_path)
|
| 69 |
+
else:
|
| 70 |
+
print("without supported tensors")
|
| 71 |
+
os._exit()
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
def parse_args():
|
| 75 |
+
parser = argparse.ArgumentParser(
|
| 76 |
+
description="Script to train Stable Diffusion XL for InstructPix2Pix."
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
parser.add_argument(
|
| 80 |
+
"--pretrained_model_name_or_path",
|
| 81 |
+
type=str,
|
| 82 |
+
default=None,
|
| 83 |
+
required=True
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
parser.add_argument(
|
| 87 |
+
"--validation_control_video_path",
|
| 88 |
+
type=str,
|
| 89 |
+
default=None,
|
| 90 |
+
required=False,
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
parser.add_argument(
|
| 94 |
+
"--pose_video_path",
|
| 95 |
+
type=str,
|
| 96 |
+
default=None,
|
| 97 |
+
help="Path to pre-extracted pose video (bypass DWPose)"
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
parser.add_argument(
|
| 101 |
+
"--pose_images_dir",
|
| 102 |
+
type=str,
|
| 103 |
+
default=None,
|
| 104 |
+
help="Directory containing pose images (bypass DWPose)"
|
| 105 |
+
)
|
| 106 |
+
|
| 107 |
+
parser.add_argument(
|
| 108 |
+
"--output_dir",
|
| 109 |
+
type=str,
|
| 110 |
+
default=None,
|
| 111 |
+
required=True
|
| 112 |
+
)
|
| 113 |
+
|
| 114 |
+
parser.add_argument(
|
| 115 |
+
"--height",
|
| 116 |
+
type=int,
|
| 117 |
+
default=768,
|
| 118 |
+
required=False
|
| 119 |
+
)
|
| 120 |
+
|
| 121 |
+
parser.add_argument(
|
| 122 |
+
"--width",
|
| 123 |
+
type=int,
|
| 124 |
+
default=512,
|
| 125 |
+
required=False
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
parser.add_argument(
|
| 129 |
+
"--guidance_scale",
|
| 130 |
+
type=float,
|
| 131 |
+
default=2.,
|
| 132 |
+
required=False
|
| 133 |
+
)
|
| 134 |
+
|
| 135 |
+
parser.add_argument(
|
| 136 |
+
"--num_inference_steps",
|
| 137 |
+
type=int,
|
| 138 |
+
default=25,
|
| 139 |
+
required=False
|
| 140 |
+
)
|
| 141 |
+
|
| 142 |
+
parser.add_argument(
|
| 143 |
+
"--controlnext_path",
|
| 144 |
+
type=str,
|
| 145 |
+
default=None,
|
| 146 |
+
required=True
|
| 147 |
+
)
|
| 148 |
+
|
| 149 |
+
parser.add_argument(
|
| 150 |
+
"--unet_path",
|
| 151 |
+
type=str,
|
| 152 |
+
default=None,
|
| 153 |
+
required=True
|
| 154 |
+
)
|
| 155 |
+
|
| 156 |
+
parser.add_argument(
|
| 157 |
+
"--max_frame_num",
|
| 158 |
+
type=int,
|
| 159 |
+
default=50,
|
| 160 |
+
required=False
|
| 161 |
+
)
|
| 162 |
+
|
| 163 |
+
parser.add_argument(
|
| 164 |
+
"--ref_image_path",
|
| 165 |
+
type=str,
|
| 166 |
+
default=None,
|
| 167 |
+
required=True
|
| 168 |
+
)
|
| 169 |
+
|
| 170 |
+
parser.add_argument(
|
| 171 |
+
"--batch_frames",
|
| 172 |
+
type=int,
|
| 173 |
+
default=14,
|
| 174 |
+
required=False
|
| 175 |
+
)
|
| 176 |
+
|
| 177 |
+
parser.add_argument(
|
| 178 |
+
"--overlap",
|
| 179 |
+
type=int,
|
| 180 |
+
default=4,
|
| 181 |
+
required=False
|
| 182 |
+
)
|
| 183 |
+
|
| 184 |
+
parser.add_argument(
|
| 185 |
+
"--sample_stride",
|
| 186 |
+
type=int,
|
| 187 |
+
default=2,
|
| 188 |
+
required=False
|
| 189 |
+
)
|
| 190 |
+
|
| 191 |
+
parser.add_argument(
|
| 192 |
+
"--precision",
|
| 193 |
+
type=str,
|
| 194 |
+
default="fp16",
|
| 195 |
+
choices=["fp32", "fp16", "bf16"],
|
| 196 |
+
help="Model precision"
|
| 197 |
+
)
|
| 198 |
+
|
| 199 |
+
parser.add_argument(
|
| 200 |
+
"--enable_xformers",
|
| 201 |
+
action="store_true",
|
| 202 |
+
help="Enable xformers memory efficient attention"
|
| 203 |
+
)
|
| 204 |
+
|
| 205 |
+
parser.add_argument(
|
| 206 |
+
"--decode_chunk_size",
|
| 207 |
+
type=int,
|
| 208 |
+
default=2,
|
| 209 |
+
help="Chunk size for VAE decoding"
|
| 210 |
+
)
|
| 211 |
+
|
| 212 |
+
args = parser.parse_args()
|
| 213 |
+
return args
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
# Main script
|
| 217 |
+
if __name__ == "__main__":
|
| 218 |
+
args = parse_args()
|
| 219 |
+
|
| 220 |
+
# Set precision
|
| 221 |
+
dtype_map = {
|
| 222 |
+
"fp32": torch.float32,
|
| 223 |
+
"fp16": torch.float16,
|
| 224 |
+
"bf16": torch.bfloat16
|
| 225 |
+
}
|
| 226 |
+
dtype = dtype_map[args.precision]
|
| 227 |
+
|
| 228 |
+
print(f"🚀 Using precision: {args.precision}")
|
| 229 |
+
|
| 230 |
+
# Clear GPU cache
|
| 231 |
+
if torch.cuda.is_available():
|
| 232 |
+
torch.cuda.empty_cache()
|
| 233 |
+
gc.collect()
|
| 234 |
+
|
| 235 |
+
# Load models with optimizations
|
| 236 |
+
print("📦 Loading UNet...")
|
| 237 |
+
unet = UNetSpatioTemporalConditionControlNeXtModel.from_pretrained(
|
| 238 |
+
args.pretrained_model_name_or_path,
|
| 239 |
+
subfolder="unet",
|
| 240 |
+
low_cpu_mem_usage=True,
|
| 241 |
+
torch_dtype=dtype,
|
| 242 |
+
)
|
| 243 |
+
|
| 244 |
+
print("📦 Loading ControlNeXt...")
|
| 245 |
+
controlnext = ControlNeXtSDVModel()
|
| 246 |
+
controlnext.load_state_dict(load_tensor(args.controlnext_path))
|
| 247 |
+
controlnext = controlnext.to(dtype)
|
| 248 |
+
|
| 249 |
+
# Load UNet weights
|
| 250 |
+
print("📦 Loading UNet weights...")
|
| 251 |
+
unet.load_state_dict(load_tensor(args.unet_path), strict=False)
|
| 252 |
+
|
| 253 |
+
print("📦 Loading other components...")
|
| 254 |
+
image_encoder = CLIPVisionModelWithProjection.from_pretrained(
|
| 255 |
+
args.pretrained_model_name_or_path,
|
| 256 |
+
subfolder="image_encoder",
|
| 257 |
+
torch_dtype=dtype,
|
| 258 |
+
low_cpu_mem_usage=True,
|
| 259 |
+
)
|
| 260 |
+
|
| 261 |
+
vae = AutoencoderKLTemporalDecoder.from_pretrained(
|
| 262 |
+
args.pretrained_model_name_or_path,
|
| 263 |
+
subfolder="vae",
|
| 264 |
+
torch_dtype=dtype,
|
| 265 |
+
low_cpu_mem_usage=True,
|
| 266 |
+
)
|
| 267 |
+
|
| 268 |
+
# Create pipeline
|
| 269 |
+
pipeline = StableVideoDiffusionPipelineControlNeXt.from_pretrained(
|
| 270 |
+
args.pretrained_model_name_or_path,
|
| 271 |
+
controlnext=controlnext,
|
| 272 |
+
unet=unet,
|
| 273 |
+
vae=vae,
|
| 274 |
+
image_encoder=image_encoder,
|
| 275 |
+
torch_dtype=dtype,
|
| 276 |
+
)
|
| 277 |
+
|
| 278 |
+
# Enable optimizations
|
| 279 |
+
if args.enable_xformers:
|
| 280 |
+
try:
|
| 281 |
+
pipeline.enable_xformers_memory_efficient_attention()
|
| 282 |
+
print("✓ Xformers memory efficient attention enabled")
|
| 283 |
+
except:
|
| 284 |
+
print("⚠️ Xformers not available, using default attention")
|
| 285 |
+
|
| 286 |
+
# Enable model CPU offload for memory efficiency
|
| 287 |
+
pipeline.enable_model_cpu_offload()
|
| 288 |
+
|
| 289 |
+
# Optional: Enable VAE slicing for lower memory usage
|
| 290 |
+
# pipeline.enable_vae_slicing()
|
| 291 |
+
|
| 292 |
+
# Optional: Enable VAE tiling for very large images
|
| 293 |
+
# pipeline.enable_vae_tiling()
|
| 294 |
+
|
| 295 |
+
os.makedirs(args.output_dir, exist_ok=True)
|
| 296 |
+
|
| 297 |
+
# Choose preprocessing method based on input
|
| 298 |
+
if args.pose_video_path:
|
| 299 |
+
print("🎬 Loading pre-extracted pose video...")
|
| 300 |
+
validation_control_images, ref_image = preprocess_direct_pose(
|
| 301 |
+
args.pose_video_path,
|
| 302 |
+
args.ref_image_path,
|
| 303 |
+
width=args.width,
|
| 304 |
+
height=args.height,
|
| 305 |
+
max_frame_num=args.max_frame_num,
|
| 306 |
+
sample_stride=args.sample_stride
|
| 307 |
+
)
|
| 308 |
+
elif args.pose_images_dir:
|
| 309 |
+
print("🎬 Loading pose images from directory...")
|
| 310 |
+
validation_control_images, ref_image = load_pose_from_images(
|
| 311 |
+
args.pose_images_dir,
|
| 312 |
+
args.ref_image_path,
|
| 313 |
+
width=args.width,
|
| 314 |
+
height=args.height,
|
| 315 |
+
max_frame_num=args.max_frame_num,
|
| 316 |
+
sample_stride=args.sample_stride
|
| 317 |
+
)
|
| 318 |
+
else:
|
| 319 |
+
print("🎬 Preprocessing video with DWPose extraction...")
|
| 320 |
+
validation_control_images, ref_image = preprocess(
|
| 321 |
+
args.validation_control_video_path,
|
| 322 |
+
args.ref_image_path,
|
| 323 |
+
width=args.width,
|
| 324 |
+
height=args.height,
|
| 325 |
+
max_frame_num=args.max_frame_num,
|
| 326 |
+
sample_stride=args.sample_stride
|
| 327 |
+
)
|
| 328 |
+
|
| 329 |
+
final_result = []
|
| 330 |
+
frames = args.batch_frames
|
| 331 |
+
num_frames = min(args.max_frame_num, len(validation_control_images))
|
| 332 |
+
|
| 333 |
+
for i in range(num_frames):
|
| 334 |
+
validation_control_images[i] = Image.fromarray(np.array(validation_control_images[i]))
|
| 335 |
+
|
| 336 |
+
print(f"🎯 Generating {num_frames} frames...")
|
| 337 |
+
|
| 338 |
+
# Run inference with optimizations
|
| 339 |
+
video_frames = pipeline(
|
| 340 |
+
ref_image,
|
| 341 |
+
validation_control_images[:num_frames],
|
| 342 |
+
decode_chunk_size=args.decode_chunk_size, # Chunked decoding
|
| 343 |
+
num_frames=num_frames,
|
| 344 |
+
motion_bucket_id=127.0,
|
| 345 |
+
fps=7,
|
| 346 |
+
controlnext_cond_scale=1.0,
|
| 347 |
+
width=args.width,
|
| 348 |
+
height=args.height,
|
| 349 |
+
min_guidance_scale=args.guidance_scale,
|
| 350 |
+
max_guidance_scale=args.guidance_scale,
|
| 351 |
+
frames_per_batch=frames,
|
| 352 |
+
num_inference_steps=args.num_inference_steps,
|
| 353 |
+
overlap=args.overlap
|
| 354 |
+
).frames[0]
|
| 355 |
+
|
| 356 |
+
final_result.append(video_frames)
|
| 357 |
+
|
| 358 |
+
# Determine FPS based on input type
|
| 359 |
+
if args.pose_video_path:
|
| 360 |
+
fps = VideoReader(args.pose_video_path).get_avg_fps() // args.sample_stride
|
| 361 |
+
# Extract base filename from pose video path
|
| 362 |
+
base_filename = os.path.splitext(os.path.basename(args.pose_video_path))[0]
|
| 363 |
+
elif args.pose_images_dir:
|
| 364 |
+
fps = 30 // args.sample_stride # Default FPS for image sequences
|
| 365 |
+
# Use directory name as base filename
|
| 366 |
+
base_filename = os.path.basename(args.pose_images_dir.rstrip('/'))
|
| 367 |
+
else:
|
| 368 |
+
fps = VideoReader(args.validation_control_video_path).get_avg_fps() // args.sample_stride
|
| 369 |
+
# Extract base filename from control video path
|
| 370 |
+
base_filename = os.path.splitext(os.path.basename(args.validation_control_video_path))[0]
|
| 371 |
+
|
| 372 |
+
print("💾 Saving results...")
|
| 373 |
+
save_vid_side_by_side(
|
| 374 |
+
final_result,
|
| 375 |
+
validation_control_images[:num_frames],
|
| 376 |
+
args.output_dir,
|
| 377 |
+
fps=fps,
|
| 378 |
+
base_filename=base_filename
|
| 379 |
+
)
|
| 380 |
+
|
| 381 |
+
print(f"✅ Done! Output saved as:")
|
| 382 |
+
print(f" - {os.path.join(args.output_dir, base_filename + '.mp4')}")
|
| 383 |
+
print(f" - {os.path.join(args.output_dir, base_filename + '_combined.mp4')}")
|
ControlNeXt-SVD-v2/utils/__pycache__/pre_process_direct.cpython-310.pyc
ADDED
|
Binary file (5.03 kB). View file
|
|
|
ControlNeXt-SVD-v2/utils/pre_process_direct.py
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import argparse
|
| 3 |
+
import logging
|
| 4 |
+
import math
|
| 5 |
+
from omegaconf import OmegaConf
|
| 6 |
+
from datetime import datetime
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
from PIL import Image
|
| 9 |
+
import numpy as np
|
| 10 |
+
import torch.jit
|
| 11 |
+
from torchvision.datasets.folder import pil_loader
|
| 12 |
+
from torchvision.transforms.functional import pil_to_tensor, resize, center_crop
|
| 13 |
+
from torchvision.transforms.functional import to_pil_image
|
| 14 |
+
from dwpose.preprocess import get_image_pose, get_video_pose
|
| 15 |
+
import cv2
|
| 16 |
+
|
| 17 |
+
ASPECT_RATIO = 9 / 16
|
| 18 |
+
|
| 19 |
+
def preprocess(video_path, image_path, width=576, height=1024, sample_stride=2, max_frame_num=None):
|
| 20 |
+
"""preprocess ref image pose and video pose
|
| 21 |
+
|
| 22 |
+
Args:
|
| 23 |
+
video_path (str): input video pose path
|
| 24 |
+
image_path (str): reference image path
|
| 25 |
+
resolution (int, optional): Defaults to 576.
|
| 26 |
+
sample_stride (int, optional): Defaults to 2.
|
| 27 |
+
"""
|
| 28 |
+
image_pixels = pil_loader(image_path)
|
| 29 |
+
image_pixels = pil_to_tensor(image_pixels) # (c, h, w)
|
| 30 |
+
h, w = image_pixels.shape[-2:]
|
| 31 |
+
############################ compute target h/w according to original aspect ratio ###############################
|
| 32 |
+
# if h>w:
|
| 33 |
+
# w_target, h_target = resolution, int(resolution / ASPECT_RATIO // 64) * 64
|
| 34 |
+
# else:
|
| 35 |
+
# w_target, h_target = int(resolution / ASPECT_RATIO // 64) * 64, resolution
|
| 36 |
+
w_target, h_target = width, height
|
| 37 |
+
h_w_ratio = float(h) / float(w)
|
| 38 |
+
if h_w_ratio < h_target / w_target:
|
| 39 |
+
h_resize, w_resize = h_target, math.ceil(h_target / h_w_ratio)
|
| 40 |
+
else:
|
| 41 |
+
h_resize, w_resize = math.ceil(w_target * h_w_ratio), w_target
|
| 42 |
+
image_pixels = resize(image_pixels, [h_resize, w_resize], antialias=None)
|
| 43 |
+
image_pixels = center_crop(image_pixels, [h_target, w_target])
|
| 44 |
+
image_pixels = image_pixels.permute((1, 2, 0)).numpy()
|
| 45 |
+
##################################### get image&video pose value #################################################
|
| 46 |
+
image_pose = get_image_pose(image_pixels)
|
| 47 |
+
video_pose = get_video_pose(video_path, image_pixels, sample_stride=sample_stride, max_frame_num=max_frame_num)
|
| 48 |
+
pose_pixels = np.concatenate([np.expand_dims(image_pose, 0), video_pose])
|
| 49 |
+
# image_pixels = np.transpose(np.expand_dims(image_pixels, 0), (0, 3, 1, 2))
|
| 50 |
+
image_pixels = Image.fromarray(image_pixels)
|
| 51 |
+
pose_pixels = [Image.fromarray(p.transpose((1,2,0))) for p in pose_pixels]
|
| 52 |
+
# return torch.from_numpy(pose_pixels.copy()) / 127.5 - 1, torch.from_numpy(image_pixels) / 127.5 - 1
|
| 53 |
+
return pose_pixels, image_pixels
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def preprocess_direct_pose(pose_video_path, image_path, width=576, height=1024, sample_stride=2, max_frame_num=None):
|
| 57 |
+
"""Preprocess with pre-extracted pose video (bypass DWPose extraction)
|
| 58 |
+
|
| 59 |
+
Args:
|
| 60 |
+
pose_video_path (str): Path to pre-extracted pose video (MP4 with pose skeleton)
|
| 61 |
+
image_path (str): reference image path
|
| 62 |
+
width (int): target width
|
| 63 |
+
height (int): target height
|
| 64 |
+
sample_stride (int): frame sampling stride
|
| 65 |
+
max_frame_num (int): maximum number of frames to process
|
| 66 |
+
"""
|
| 67 |
+
# Process reference image
|
| 68 |
+
image_pixels = pil_loader(image_path)
|
| 69 |
+
image_pixels = pil_to_tensor(image_pixels) # (c, h, w)
|
| 70 |
+
h, w = image_pixels.shape[-2:]
|
| 71 |
+
|
| 72 |
+
w_target, h_target = width, height
|
| 73 |
+
h_w_ratio = float(h) / float(w)
|
| 74 |
+
if h_w_ratio < h_target / w_target:
|
| 75 |
+
h_resize, w_resize = h_target, math.ceil(h_target / h_w_ratio)
|
| 76 |
+
else:
|
| 77 |
+
h_resize, w_resize = math.ceil(w_target * h_w_ratio), w_target
|
| 78 |
+
image_pixels = resize(image_pixels, [h_resize, w_resize], antialias=None)
|
| 79 |
+
image_pixels = center_crop(image_pixels, [h_target, w_target])
|
| 80 |
+
image_pixels = image_pixels.permute((1, 2, 0)).numpy()
|
| 81 |
+
|
| 82 |
+
# Get pose for reference image
|
| 83 |
+
image_pose = get_image_pose(image_pixels)
|
| 84 |
+
|
| 85 |
+
# Load pre-extracted pose video
|
| 86 |
+
cap = cv2.VideoCapture(pose_video_path)
|
| 87 |
+
pose_frames = []
|
| 88 |
+
frame_count = 0
|
| 89 |
+
|
| 90 |
+
while True:
|
| 91 |
+
ret, frame = cap.read()
|
| 92 |
+
if not ret:
|
| 93 |
+
break
|
| 94 |
+
|
| 95 |
+
# Apply sample stride
|
| 96 |
+
if frame_count % sample_stride == 0:
|
| 97 |
+
# Convert BGR to RGB
|
| 98 |
+
frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
| 99 |
+
|
| 100 |
+
# Resize frame to target size if needed
|
| 101 |
+
if frame_rgb.shape[:2] != (h_target, w_target):
|
| 102 |
+
frame_rgb = cv2.resize(frame_rgb, (w_target, h_target))
|
| 103 |
+
|
| 104 |
+
pose_frames.append(frame_rgb)
|
| 105 |
+
|
| 106 |
+
# Check max frame limit
|
| 107 |
+
if max_frame_num is not None and len(pose_frames) >= max_frame_num:
|
| 108 |
+
break
|
| 109 |
+
|
| 110 |
+
frame_count += 1
|
| 111 |
+
|
| 112 |
+
cap.release()
|
| 113 |
+
|
| 114 |
+
# Convert to numpy array and prepare output
|
| 115 |
+
video_pose = np.array(pose_frames).transpose((0, 3, 1, 2)) # (n, c, h, w)
|
| 116 |
+
pose_pixels = np.concatenate([np.expand_dims(image_pose, 0), video_pose])
|
| 117 |
+
|
| 118 |
+
# Convert to PIL Images
|
| 119 |
+
image_pixels = Image.fromarray(image_pixels)
|
| 120 |
+
pose_pixels = [Image.fromarray(p.transpose((1,2,0))) for p in pose_pixels]
|
| 121 |
+
|
| 122 |
+
return pose_pixels, image_pixels
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
def load_pose_from_images(pose_images_dir, image_path, width=576, height=1024, sample_stride=1, max_frame_num=None):
|
| 126 |
+
"""Load pose from a directory of pose images
|
| 127 |
+
|
| 128 |
+
Args:
|
| 129 |
+
pose_images_dir (str): Directory containing pose images (PNG/JPG files)
|
| 130 |
+
image_path (str): reference image path
|
| 131 |
+
width (int): target width
|
| 132 |
+
height (int): target height
|
| 133 |
+
sample_stride (int): frame sampling stride (1 means use all frames)
|
| 134 |
+
max_frame_num (int): maximum number of frames to process
|
| 135 |
+
"""
|
| 136 |
+
# Process reference image
|
| 137 |
+
image_pixels = pil_loader(image_path)
|
| 138 |
+
image_pixels = pil_to_tensor(image_pixels) # (c, h, w)
|
| 139 |
+
h, w = image_pixels.shape[-2:]
|
| 140 |
+
|
| 141 |
+
w_target, h_target = width, height
|
| 142 |
+
h_w_ratio = float(h) / float(w)
|
| 143 |
+
if h_w_ratio < h_target / w_target:
|
| 144 |
+
h_resize, w_resize = h_target, math.ceil(h_target / h_w_ratio)
|
| 145 |
+
else:
|
| 146 |
+
h_resize, w_resize = math.ceil(w_target * h_w_ratio), w_target
|
| 147 |
+
image_pixels = resize(image_pixels, [h_resize, w_resize], antialias=None)
|
| 148 |
+
image_pixels = center_crop(image_pixels, [h_target, w_target])
|
| 149 |
+
image_pixels = image_pixels.permute((1, 2, 0)).numpy()
|
| 150 |
+
|
| 151 |
+
# Get pose for reference image
|
| 152 |
+
image_pose = get_image_pose(image_pixels)
|
| 153 |
+
|
| 154 |
+
# Load pose images from directory
|
| 155 |
+
pose_files = sorted([f for f in os.listdir(pose_images_dir)
|
| 156 |
+
if f.lower().endswith(('.png', '.jpg', '.jpeg'))])
|
| 157 |
+
|
| 158 |
+
pose_frames = []
|
| 159 |
+
for i, pose_file in enumerate(pose_files):
|
| 160 |
+
if i % sample_stride == 0:
|
| 161 |
+
pose_path = os.path.join(pose_images_dir, pose_file)
|
| 162 |
+
pose_img = Image.open(pose_path).convert('RGB')
|
| 163 |
+
|
| 164 |
+
# Resize if needed
|
| 165 |
+
if pose_img.size != (w_target, h_target):
|
| 166 |
+
pose_img = pose_img.resize((w_target, h_target), Image.LANCZOS)
|
| 167 |
+
|
| 168 |
+
pose_frames.append(np.array(pose_img))
|
| 169 |
+
|
| 170 |
+
# Check max frame limit
|
| 171 |
+
if max_frame_num is not None and len(pose_frames) >= max_frame_num:
|
| 172 |
+
break
|
| 173 |
+
|
| 174 |
+
# Convert to numpy array
|
| 175 |
+
video_pose = np.array(pose_frames).transpose((0, 3, 1, 2)) # (n, c, h, w)
|
| 176 |
+
pose_pixels = np.concatenate([np.expand_dims(image_pose, 0), video_pose])
|
| 177 |
+
|
| 178 |
+
# Convert to PIL Images
|
| 179 |
+
image_pixels = Image.fromarray(image_pixels)
|
| 180 |
+
pose_pixels = [Image.fromarray(p.transpose((1,2,0))) for p in pose_pixels]
|
| 181 |
+
|
| 182 |
+
return pose_pixels, image_pixels
|
README.md
CHANGED
|
@@ -6,6 +6,10 @@ The entire project is divided into two parts: `text_or_gloss2pose` and `pose2vid
|
|
| 6 |
|
| 7 |
- In the pose2video section, we render the visualized poses of the skeletons generated by each word. I used the ControlNext-SVD model for this.
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
# For developers
|
| 10 |
|
| 11 |
1. git clone https://huggingface.co/datasets/FangSen9000/StableSigner
|
|
@@ -33,6 +37,10 @@ The entire project is divided into two parts: `text_or_gloss2pose` and `pose2vid
|
|
| 33 |
## tutorial02 get pose video from text input
|
| 34 |
|
| 35 |
```python
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
# Single gloss
|
| 37 |
python text2pose.py --gloss "hello"
|
| 38 |
|
|
@@ -40,7 +48,7 @@ python text2pose.py --gloss "hello"
|
|
| 40 |
python text2pose.py --gloss "hello world" --smoothing fade --smoothing-frames 5
|
| 41 |
|
| 42 |
# Custom video parameters
|
| 43 |
-
python text2pose.py --gloss "afternoon" --width
|
| 44 |
```
|
| 45 |
|
| 46 |
## tutorial03 render pose video
|
|
@@ -51,9 +59,9 @@ python text2pose.py --gloss "afternoon" --width 640 --height 480 --fps 25
|
|
| 51 |
4. run `pip install -r env/requirements02_controlnext.txt`
|
| 52 |
|
| 53 |
```python
|
| 54 |
-
CUDA_VISIBLE_DEVICES=0 python ControlNeXt-SVD-v2/
|
| 55 |
--pretrained_model_name_or_path stabilityai/stable-video-diffusion-img2vid-xt-1-1 \
|
| 56 |
-
--output_dir
|
| 57 |
--max_frame_num 240 \
|
| 58 |
--guidance_scale 3 \
|
| 59 |
--batch_frames 24 \
|
|
@@ -63,30 +71,10 @@ CUDA_VISIBLE_DEVICES=0 python ControlNeXt-SVD-v2/run_controlnext.py \
|
|
| 63 |
--width 512 \
|
| 64 |
--controlnext_path ControlNeXt-SVD-v2/pretrained/controlnet.bin \
|
| 65 |
--unet_path ControlNeXt-SVD-v2/pretrained/unet.bin \
|
| 66 |
-
--
|
| 67 |
-
--ref_image_path ref_img_dict/03.jpeg
|
|
|
|
|
|
|
|
|
|
| 68 |
```
|
| 69 |
|
| 70 |
-
<!-- official
|
| 71 |
-
```python
|
| 72 |
-
CUDA_VISIBLE_DEVICES=0 python ControlNeXt-SVD-v2/run_controlnext.py \
|
| 73 |
-
--pretrained_model_name_or_path stabilityai/stable-video-diffusion-img2vid-xt-1-1 \
|
| 74 |
-
--output_dir generated_sign_video \
|
| 75 |
-
--max_frame_num 240 \
|
| 76 |
-
--guidance_scale 3 \
|
| 77 |
-
--batch_frames 24 \
|
| 78 |
-
--sample_stride 2 \
|
| 79 |
-
--overlap 6 \
|
| 80 |
-
--height 1024 \
|
| 81 |
-
--width 576 \
|
| 82 |
-
--controlnext_path ControlNeXt-SVD-v2/pretrained/controlnet.bin \
|
| 83 |
-
--unet_path ControlNeXt-SVD-v2/pretrained/unet.bin \
|
| 84 |
-
--validation_control_video_path ControlNeXt-SVD-v2/examples/video/02.mp4 \
|
| 85 |
-
--ref_image_path ControlNeXt-SVD-v2/examples/ref_imgs/01.jpeg
|
| 86 |
-
```
|
| 87 |
-
-->
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
# For Users
|
| 91 |
-
|
| 92 |
-
## start00 just start as a user
|
|
|
|
| 6 |
|
| 7 |
- In the pose2video section, we render the visualized poses of the skeletons generated by each word. I used the ControlNext-SVD model for this.
|
| 8 |
|
| 9 |
+
# For Users
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
|
| 13 |
# For developers
|
| 14 |
|
| 15 |
1. git clone https://huggingface.co/datasets/FangSen9000/StableSigner
|
|
|
|
| 37 |
## tutorial02 get pose video from text input
|
| 38 |
|
| 39 |
```python
|
| 40 |
+
|
| 41 |
+
# Default
|
| 42 |
+
python text2pose.py --gloss "good afternoon" --smoothing fade --smoothing-frames 5 --width 512 --height 768 --fps 30
|
| 43 |
+
|
| 44 |
# Single gloss
|
| 45 |
python text2pose.py --gloss "hello"
|
| 46 |
|
|
|
|
| 48 |
python text2pose.py --gloss "hello world" --smoothing fade --smoothing-frames 5
|
| 49 |
|
| 50 |
# Custom video parameters
|
| 51 |
+
python text2pose.py --gloss "good afternoon" --width 512 --height 768 --fps 30
|
| 52 |
```
|
| 53 |
|
| 54 |
## tutorial03 render pose video
|
|
|
|
| 59 |
4. run `pip install -r env/requirements02_controlnext.txt`
|
| 60 |
|
| 61 |
```python
|
| 62 |
+
CUDA_VISIBLE_DEVICES=0 python ControlNeXt-SVD-v2/run_controlnext_optimized.py \
|
| 63 |
--pretrained_model_name_or_path stabilityai/stable-video-diffusion-img2vid-xt-1-1 \
|
| 64 |
+
--output_dir generated_sign_video_direct \
|
| 65 |
--max_frame_num 240 \
|
| 66 |
--guidance_scale 3 \
|
| 67 |
--batch_frames 24 \
|
|
|
|
| 71 |
--width 512 \
|
| 72 |
--controlnext_path ControlNeXt-SVD-v2/pretrained/controlnet.bin \
|
| 73 |
--unet_path ControlNeXt-SVD-v2/pretrained/unet.bin \
|
| 74 |
+
--pose_video_path generated_pose_video/GOOD_AFTERNOON_25073_01435_20250803_222800.mp4 \
|
| 75 |
+
--ref_image_path ref_img_dict/03.jpeg \
|
| 76 |
+
--precision fp16 \
|
| 77 |
+
--enable_xformers \
|
| 78 |
+
--decode_chunk_size 2
|
| 79 |
```
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
easy_dwpose/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (240 Bytes). View file
|
|
|
easy_dwpose/__pycache__/dwpose.cpython-310.pyc
ADDED
|
Binary file (2.83 kB). View file
|
|
|
easy_dwpose/body_estimation/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (291 Bytes). View file
|
|
|
easy_dwpose/body_estimation/__pycache__/detector.cpython-310.pyc
ADDED
|
Binary file (4.71 kB). View file
|
|
|
easy_dwpose/body_estimation/__pycache__/pose.cpython-310.pyc
ADDED
|
Binary file (10.6 kB). View file
|
|
|
easy_dwpose/body_estimation/__pycache__/utils.cpython-310.pyc
ADDED
|
Binary file (742 Bytes). View file
|
|
|
easy_dwpose/body_estimation/__pycache__/wholebody.cpython-310.pyc
ADDED
|
Binary file (1.94 kB). View file
|
|
|
easy_dwpose/draw/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (245 Bytes). View file
|
|
|
easy_dwpose/draw/__pycache__/controlnext.cpython-310.pyc
ADDED
|
Binary file (7.25 kB). View file
|
|
|
easy_dwpose/draw/__pycache__/openpose.cpython-310.pyc
ADDED
|
Binary file (3.69 kB). View file
|
|
|
generated_pose_video/GOOD_AFTERNOON_25073_01435_20250803_222800.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c09157720812d8c72b29fd76b701f60434ba1e5299aaec2054aa49f5fd97495a
|
| 3 |
+
size 1003827
|
generated_sign_video/output.mp4
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ccdd0d86c5a15ceded93ed45c5c7c5d224edb54292537430c5707760f64e72f5
|
| 3 |
+
size 1608860
|
generated_sign_video/test_1.mp4
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2c15c4d8ceaa750251f5247a29610a1b02678fa3d1a17ebc51385a7ebc545c8b
|
| 3 |
+
size 2229479
|
generated_sign_video_direct/GOOD_AFTERNOON_25073_01435_20250803_222800.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:03ae3f09974b40e1aa8e74feb86b8712060537b8eb69bd24344b5104f4d406fe
|
| 3 |
+
size 585379
|
generated_sign_video_direct/GOOD_AFTERNOON_25073_01435_20250803_222800_combined.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:04d3f48926a2e3b26889f47d176d7a68c157bdb8f17ae9800b19146e3bda3507
|
| 3 |
+
size 815754
|
useless/abandon_cmd.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!--
|
| 2 |
+
cd code/StableSigner3
|
| 3 |
+
|
| 4 |
+
```python 有优化,但是不支持直接以pose video作为输入
|
| 5 |
+
CUDA_VISIBLE_DEVICES=0 python ControlNeXt-SVD-v2/run_controlnext_optimized.py \
|
| 6 |
+
--pretrained_model_name_or_path stabilityai/stable-video-diffusion-img2vid-xt-1-1 \
|
| 7 |
+
--output_dir generated_sign_video \
|
| 8 |
+
--max_frame_num 240 \
|
| 9 |
+
--guidance_scale 3 \
|
| 10 |
+
--batch_frames 24 \
|
| 11 |
+
--sample_stride 2 \
|
| 12 |
+
--overlap 4 \
|
| 13 |
+
--height 768 \
|
| 14 |
+
--width 512 \
|
| 15 |
+
--controlnext_path ControlNeXt-SVD-v2/pretrained/controlnet.bin \
|
| 16 |
+
--unet_path ControlNeXt-SVD-v2/pretrained/unet.bin \
|
| 17 |
+
--validation_control_video_path ControlNeXt-SVD-v2/examples/video/02.mp4 \
|
| 18 |
+
--ref_image_path ref_img_dict/03.jpeg \
|
| 19 |
+
--precision fp16 \
|
| 20 |
+
--enable_xformers \
|
| 21 |
+
--decode_chunk_size 2
|
| 22 |
+
```
|
| 23 |
+
-->
|
| 24 |
+
|
| 25 |
+
<!--
|
| 26 |
+
cd code/StableSigner3
|
| 27 |
+
|
| 28 |
+
CUDA_VISIBLE_DEVICES=0 python ControlNeXt-SVD-v2/run_controlnext_v1(无优化).py \
|
| 29 |
+
--pretrained_model_name_or_path stabilityai/stable-video-diffusion-img2vid-xt-1-1 \
|
| 30 |
+
--output_dir generated_sign_video \
|
| 31 |
+
--max_frame_num 240 \
|
| 32 |
+
--guidance_scale 3 \
|
| 33 |
+
--batch_frames 24 \
|
| 34 |
+
--sample_stride 2 \
|
| 35 |
+
--overlap 4 \
|
| 36 |
+
--height 768 \
|
| 37 |
+
--width 512 \
|
| 38 |
+
--controlnext_path ControlNeXt-SVD-v2/pretrained/controlnet.bin \
|
| 39 |
+
--unet_path ControlNeXt-SVD-v2/pretrained/unet.bin \
|
| 40 |
+
--validation_control_video_path ControlNeXt-SVD-v2/examples/video/02.mp4 \
|
| 41 |
+
--ref_image_path ref_img_dict/03.jpeg
|
| 42 |
+
-->
|
| 43 |
+
|
| 44 |
+
<!-- official
|
| 45 |
+
|
| 46 |
+
cd ControlNeXt-SVD-v2
|
| 47 |
+
|
| 48 |
+
```python
|
| 49 |
+
CUDA_VISIBLE_DEVICES=0 python ControlNeXt-SVD-v2/run_controlnext.py \
|
| 50 |
+
--pretrained_model_name_or_path stabilityai/stable-video-diffusion-img2vid-xt-1-1 \
|
| 51 |
+
--output_dir generated_sign_video \
|
| 52 |
+
--max_frame_num 240 \
|
| 53 |
+
--guidance_scale 3 \
|
| 54 |
+
--batch_frames 24 \
|
| 55 |
+
--sample_stride 2 \
|
| 56 |
+
--overlap 6 \
|
| 57 |
+
--height 1024 \
|
| 58 |
+
--width 576 \
|
| 59 |
+
--controlnext_path ControlNeXt-SVD-v2/pretrained/controlnet.bin \
|
| 60 |
+
--unet_path ControlNeXt-SVD-v2/pretrained/unet.bin \
|
| 61 |
+
--validation_control_video_path ControlNeXt-SVD-v2/examples/video/02.mp4 \
|
| 62 |
+
--ref_image_path ControlNeXt-SVD-v2/examples/ref_imgs/01.jpeg
|
| 63 |
+
```
|
| 64 |
+
-->
|
ControlNeXt-SVD-v2/run_controlnext.py → useless/run_controlnext_v1(无优化.py
RENAMED
|
File without changes
|
useless/run_with_pose_video.sh
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Example 1: Run with pre-extracted pose video (bypass DWPose)
|
| 4 |
+
echo "Running with pre-extracted pose video..."
|
| 5 |
+
CUDA_VISIBLE_DEVICES=0 python ControlNeXt-SVD-v2/run_controlnext_optimized.py \
|
| 6 |
+
--pretrained_model_name_or_path stabilityai/stable-video-diffusion-img2vid-xt-1-1 \
|
| 7 |
+
--output_dir generated_sign_video_direct \
|
| 8 |
+
--max_frame_num 240 \
|
| 9 |
+
--guidance_scale 3 \
|
| 10 |
+
--batch_frames 24 \
|
| 11 |
+
--sample_stride 2 \
|
| 12 |
+
--overlap 4 \
|
| 13 |
+
--height 768 \
|
| 14 |
+
--width 512 \
|
| 15 |
+
--controlnext_path ControlNeXt-SVD-v2/pretrained/controlnet.bin \
|
| 16 |
+
--unet_path ControlNeXt-SVD-v2/pretrained/unet.bin \
|
| 17 |
+
--pose_video_path path/to/your/pose_video.mp4 \
|
| 18 |
+
--ref_image_path ref_img_dict/03.jpeg \
|
| 19 |
+
--precision fp16 \
|
| 20 |
+
--enable_xformers \
|
| 21 |
+
--decode_chunk_size 2
|
| 22 |
+
|
| 23 |
+
# Example 2: Run with pose images directory (bypass DWPose)
|
| 24 |
+
# CUDA_VISIBLE_DEVICES=0 python ControlNeXt-SVD-v2/run_controlnext_optimized.py \
|
| 25 |
+
# --pretrained_model_name_or_path stabilityai/stable-video-diffusion-img2vid-xt-1-1 \
|
| 26 |
+
# --output_dir generated_sign_video_direct \
|
| 27 |
+
# --max_frame_num 240 \
|
| 28 |
+
# --guidance_scale 3 \
|
| 29 |
+
# --batch_frames 24 \
|
| 30 |
+
# --sample_stride 1 \
|
| 31 |
+
# --overlap 4 \
|
| 32 |
+
# --height 768 \
|
| 33 |
+
# --width 512 \
|
| 34 |
+
# --controlnext_path ControlNeXt-SVD-v2/pretrained/controlnet.bin \
|
| 35 |
+
# --unet_path ControlNeXt-SVD-v2/pretrained/unet.bin \
|
| 36 |
+
# --pose_images_dir path/to/pose/images/directory \
|
| 37 |
+
# --ref_image_path ref_img_dict/03.jpeg \
|
| 38 |
+
# --precision fp16 \
|
| 39 |
+
# --enable_xformers \
|
| 40 |
+
# --decode_chunk_size 2
|
| 41 |
+
|
| 42 |
+
# Example 3: Original mode with DWPose extraction
|
| 43 |
+
# CUDA_VISIBLE_DEVICES=0 python ControlNeXt-SVD-v2/run_controlnext_optimized.py \
|
| 44 |
+
# --pretrained_model_name_or_path stabilityai/stable-video-diffusion-img2vid-xt-1-1 \
|
| 45 |
+
# --output_dir generated_sign_video_optimized \
|
| 46 |
+
# --max_frame_num 240 \
|
| 47 |
+
# --guidance_scale 3 \
|
| 48 |
+
# --batch_frames 24 \
|
| 49 |
+
# --sample_stride 2 \
|
| 50 |
+
# --overlap 4 \
|
| 51 |
+
# --height 768 \
|
| 52 |
+
# --width 512 \
|
| 53 |
+
# --controlnext_path ControlNeXt-SVD-v2/pretrained/controlnet.bin \
|
| 54 |
+
# --unet_path ControlNeXt-SVD-v2/pretrained/unet.bin \
|
| 55 |
+
# --validation_control_video_path ControlNeXt-SVD-v2/examples/video/02.mp4 \
|
| 56 |
+
# --ref_image_path ref_img_dict/03.jpeg \
|
| 57 |
+
# --precision fp16 \
|
| 58 |
+
# --enable_xformers \
|
| 59 |
+
# --decode_chunk_size 2
|