mirror of
https://github.com/s0md3v/roop.git
synced 2025-12-06 18:08:29 +00:00
Merge branch 'next' into issue_377_rethink
This commit is contained in:
commit
2aeaf0b244
10
.github/workflows/ci.yml
vendored
10
.github/workflows/ci.yml
vendored
@ -8,10 +8,10 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up Python 3.10
|
||||
- name: Set up Python 3.9
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.10'
|
||||
python-version: 3.9
|
||||
- run: pip install flake8
|
||||
- run: flake8 run.py roop
|
||||
test:
|
||||
@ -21,11 +21,11 @@ jobs:
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up ffmpeg
|
||||
uses: FedericoCarboni/setup-ffmpeg@v2
|
||||
- name: Set up Python 3.10
|
||||
- name: Set up Python 3.9
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.10'
|
||||
- run: pip install -r requirements.txt
|
||||
python-version: 3.9
|
||||
- run: pip install -r requirements-ci.txt
|
||||
- run: python run.py -s=.github/examples/source.jpg -t=.github/examples/target.mp4 -o=.github/examples/output.mp4
|
||||
- run: ffmpeg -i .github/examples/snapshot.mp4 -i .github/examples/output.mp4 -filter_complex psnr -f null -
|
||||
|
||||
|
||||
14
requirements-ci.txt
Normal file
14
requirements-ci.txt
Normal file
@ -0,0 +1,14 @@
|
||||
numpy==1.23.5
|
||||
opencv-python==4.7.0.72
|
||||
onnx==1.14.0
|
||||
insightface==0.7.3
|
||||
psutil==5.9.5
|
||||
tk==0.1.0
|
||||
customtkinter==5.1.3
|
||||
torch==2.0.1
|
||||
torchvision==0.15.2
|
||||
onnxruntime==1.15.0
|
||||
tensorflow==2.12.0
|
||||
opennsfw2==0.10.2
|
||||
protobuf==4.23.2
|
||||
tqdm==4.65.0
|
||||
@ -71,7 +71,7 @@ def parse_args() -> None:
|
||||
roop.globals.execution_providers = decode_execution_providers(args.execution_provider)
|
||||
roop.globals.execution_threads = args.execution_threads
|
||||
|
||||
# warn and cast deprecated args
|
||||
# translate deprecated args
|
||||
if args.source_path_deprecated:
|
||||
print('\033[33mArgument -f and --face are deprecated. Use -s and --source instead.\033[0m')
|
||||
roop.globals.source_path = args.source_path_deprecated
|
||||
|
||||
@ -19,7 +19,7 @@ NAME = 'ROOP.FACE-ENHANCER'
|
||||
|
||||
def pre_check() -> bool:
|
||||
download_directory_path = resolve_relative_path('../models')
|
||||
conditional_download(download_directory_path, ['https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth'])
|
||||
conditional_download(download_directory_path, ['https://huggingface.co/henryruhs/roop/resolve/main/GFPGANv1.3.pth'])
|
||||
return True
|
||||
|
||||
|
||||
@ -39,8 +39,7 @@ def get_face_enhancer() -> None:
|
||||
# todo: set models path https://github.com/TencentARC/GFPGAN/issues/399
|
||||
FACE_ENHANCER = gfpgan.GFPGANer(
|
||||
model_path=model_path,
|
||||
channel_multiplier=2,
|
||||
upscale=2
|
||||
channel_multiplier=2
|
||||
)
|
||||
return FACE_ENHANCER
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ NAME = 'ROOP.FACE-SWAPPER'
|
||||
|
||||
def pre_check() -> bool:
|
||||
download_directory_path = resolve_relative_path('../models')
|
||||
conditional_download(download_directory_path, ['https://huggingface.co/deepinsight/inswapper/resolve/main/inswapper_128.onnx'])
|
||||
conditional_download(download_directory_path, ['https://huggingface.co/henryruhs/roop/resolve/main/inswapper_128.onnx'])
|
||||
return True
|
||||
|
||||
|
||||
|
||||
@ -199,13 +199,13 @@ def init_preview() -> None:
|
||||
|
||||
def update_preview(frame_number: int = 0) -> None:
|
||||
if roop.globals.source_path and roop.globals.target_path:
|
||||
video_frame = None
|
||||
temp_frame = get_video_frame(roop.globals.target_path, frame_number)
|
||||
for frame_processor in get_frame_processors_modules(roop.globals.frame_processors):
|
||||
video_frame = frame_processor.process_frame(
|
||||
temp_frame = frame_processor.process_frame(
|
||||
get_one_face(cv2.imread(roop.globals.source_path)),
|
||||
get_video_frame(roop.globals.target_path, frame_number)
|
||||
temp_frame
|
||||
)
|
||||
image = Image.fromarray(cv2.cvtColor(video_frame, cv2.COLOR_BGR2RGB))
|
||||
image = Image.fromarray(cv2.cvtColor(temp_frame, cv2.COLOR_BGR2RGB))
|
||||
image = ImageOps.contain(image, (PREVIEW_MAX_WIDTH, PREVIEW_MAX_HEIGHT), Image.LANCZOS)
|
||||
image = ctk.CTkImage(image, size=image.size)
|
||||
preview_label.configure(image=image)
|
||||
|
||||
@ -21,13 +21,15 @@ if platform.system().lower() == 'darwin':
|
||||
ssl._create_default_https_context = ssl._create_unverified_context
|
||||
|
||||
|
||||
def run_ffmpeg(args: List[str]) -> None:
|
||||
def run_ffmpeg(args: List[str]) -> bool:
|
||||
commands = ['ffmpeg', '-hide_banner', '-hwaccel', 'auto', '-loglevel', roop.globals.log_level]
|
||||
commands.extend(args)
|
||||
try:
|
||||
subprocess.check_output(commands, stderr=subprocess.STDOUT)
|
||||
return True
|
||||
except Exception:
|
||||
pass
|
||||
return False
|
||||
|
||||
|
||||
def detect_fps(target_path: str) -> float:
|
||||
@ -54,8 +56,8 @@ def create_video(target_path: str, fps: float = 30.0) -> None:
|
||||
|
||||
def restore_audio(target_path: str, output_path: str) -> None:
|
||||
temp_output_path = get_temp_output_path(target_path)
|
||||
run_ffmpeg(['-i', temp_output_path, '-i', target_path, '-c:v', 'copy', '-map', '0:v:0', '-map', '1:a:0', '-y', output_path])
|
||||
if not os.path.isfile(output_path):
|
||||
done = run_ffmpeg(['-i', temp_output_path, '-i', target_path, '-c:v', 'copy', '-map', '0:v:0', '-map', '1:a:0', '-y', output_path])
|
||||
if not done:
|
||||
move_temp(target_path, output_path)
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user