Merge pull request #26 from storytold/rerender-lora

Rerender lora
This commit is contained in:
ArEnSc
2023-12-13 02:16:55 -05:00
committed by GitHub
8 changed files with 50 additions and 3 deletions
+9
View File
@@ -7,3 +7,12 @@
[submodule "animation/Rerender_A_Video/deps/gmflow"]
path = animation/Rerender_A_Video/deps/gmflow
url = https://github.com/haofeixu/gmflow.git
[submodule "animation/rerender-lora/deps/ControlNet"]
path = animation/rerender-lora/deps/ControlNet
url = https://github.com/lllyasviel/ControlNet.git
[submodule "animation/rerender-lora/deps/ebsynth"]
path = animation/rerender-lora/deps/ebsynth
url = https://github.com/SingleZombie/ebsynth.git
[submodule "animation/rerender-lora/deps/gmflow"]
path = animation/rerender-lora/deps/gmflow
url = https://github.com/haofeixu/gmflow.git
+1
View File
@@ -71,6 +71,7 @@ def download_vae():
download(url, 'models')
print("Before installing, make sure you have initialized the submodules! (git submodule init)")
build_ebsynth()
download_gmflow_ckpt()
download_controlnet_canny()
+12 -2
View File
@@ -1,6 +1,8 @@
import argparse
import os
import random
import subprocess
import sys
import cv2
import einops
@@ -402,12 +404,20 @@ def postprocess(cfg: RerenderConfig, ne: bool, max_process: int, tmp: bool,
use_ps = '-ps' if ps else ''
o_video_cmd = f'--output {o_video}'
python_executable = sys.executable
cmd = (
f'python video_blend.py {video_base_dir} --beg 1 --end {end_frame} '
f'{python_executable} video_blend.py {video_base_dir} --beg 1 --end {end_frame} '
f'--itv {interval} --key {key_dir} {use_e} {o_video_cmd} --fps {fps} '
f'--n_proc {max_process} {use_tmp} {use_ps}')
print(cmd)
os.system(cmd)
completed_process = subprocess.run(cmd, shell=True, stdout=sys.stdout, stderr=sys.stderr)
# Check if the command was executed successfully
if completed_process.returncode == 0:
print("Command executed successfully")
else:
print(f"Command failed with return code {completed_process.returncode}")
if __name__ == '__main__':
+2 -1
View File
@@ -2,6 +2,7 @@
# CrossAttn precision handling
import os
import sys
import einops
import numpy as np
@@ -290,7 +291,7 @@ class DDIMVSampler(object):
else timesteps.shape[0]
print(f'Running DDIM Sampling with {total_steps} timesteps')
iterator = tqdm(time_range, desc='DDIM Sampler', total=total_steps)
iterator = tqdm(time_range, desc='DDIM Sampler', total=total_steps, file=sys.stdout)
if controller is not None:
controller.set_total_step(total_steps)
if mask is None:
+23
View File
@@ -4,6 +4,7 @@ import platform
import struct
import subprocess
import time
from collections import namedtuple
from typing import List
import cv2
@@ -272,6 +273,28 @@ def main(args):
video_sequence.remove_out_and_tmp()
def process_video(name, output=None, fps=30, beg=1, end=101, itv=10, key='keys0', n_proc=8, ps=False, ne=False, tmp=False):
"""
Process a video with the specified parameters.
:param name: Path to input video.
:param output: Path to output video.
:param fps: The FPS of output video.
:param beg: The index of the first frame to be stylized.
:param end: The index of the last frame to be stylized.
:param itv: The interval of key frame.
:param key: The subfolder name of stylized key frames.
:param n_proc: The max process count.
:param ps: Use poisson gradient blending if True.
:param ne: Do not run ebsynth if True (use previous ebsynth output).
:param tmp: Keep temporary output if True.
"""
Args = namedtuple('Args', ['name', 'output', 'fps', 'beg', 'end', 'itv', 'key', 'n_proc', 'ps', 'ne', 'tmp'])
args = Args(name, output, fps, beg, end, itv, key, n_proc, ps, ne, tmp)
main(args)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('name', type=str, help='Path to input video')