Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next #734

Merged
merged 39 commits into from
Jul 19, 2023
Merged

Next #734

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c6a1387
Fix video frames lower than threads
henryruhs Jun 28, 2023
eca4f0f
Skip target audio (#656)
henryruhs Jun 29, 2023
b104741
Improve return typing
henryruhs Jun 30, 2023
b710cc8
Use face enhancer device according to execution provider
henryruhs Jul 1, 2023
a81e172
Lock face by reference (#679)
henryruhs Jul 2, 2023
542f119
Use sys.exit() over quit()
henryruhs Jul 4, 2023
fb26fbb
Split frame processor error to reduce confusion
henryruhs Jul 4, 2023
89ee0bc
Improve face reference by introducing more CLI args
henryruhs Jul 8, 2023
fb31af0
Prevent AttributeError if face is None
henryruhs Jul 9, 2023
d59c55d
Update dependencies
henryruhs Jul 9, 2023
7529ba6
Move reference creation to process_video
henryruhs Jul 9, 2023
0b178d5
Allow to initialize UI with source path and target path
henryruhs Jul 12, 2023
5d6d438
Allow to initialize UI with source path and target path
henryruhs Jul 12, 2023
a722c3f
Allow to initialize UI with source path and target path
henryruhs Jul 12, 2023
868ea7a
Use onnxruntime-coreml for old MacOS
henryruhs Jul 15, 2023
25b4b6e
Fix typing
henryruhs Jul 15, 2023
98c2869
Fix typing
henryruhs Jul 15, 2023
9869b96
Fix typing
henryruhs Jul 15, 2023
ead12e3
Temp fix for enhancer
henryruhs Jul 15, 2023
a01dd98
Temp fix for enhancer
henryruhs Jul 15, 2023
671a5c8
Keyboard bindings to change reference face via Up/Down
henryruhs Jul 15, 2023
f38239e
Fix slow preview
henryruhs Jul 15, 2023
9aa5023
ignore
henryruhs Jul 15, 2023
0bb4f7f
Update README and ISSUE TEMPLATES
henryruhs Jul 16, 2023
855b8e2
Right/Left to update frames by +10/-10
henryruhs Jul 16, 2023
e1d7f00
Fix fps mismatch
henryruhs Jul 16, 2023
77cd226
Add fps parameter to extract_frames()
henryruhs Jul 16, 2023
14208e8
Minor wording cosmetics
henryruhs Jul 16, 2023
56dbf66
Improve enhancer performance by using cropped face
henryruhs Jul 17, 2023
663439f
Fix suggested threads and memory
henryruhs Jul 17, 2023
61b5090
Extract frames with FPS output
henryruhs Jul 18, 2023
a93af16
Remove default max-memory
henryruhs Jul 18, 2023
fffdef9
Remove release_resources() as it does not work
henryruhs Jul 18, 2023
b343214
Ignore torch import
henryruhs Jul 18, 2023
5cfa5a1
Add drag and drop for source and target
henryruhs Jul 19, 2023
c3d922f
Fix typing
henryruhs Jul 19, 2023
7c63281
Bump version
henryruhs Jul 19, 2023
2117292
Limit Left/Right binding to videos
henryruhs Jul 19, 2023
0822848
Add key binding hits to preview
henryruhs Jul 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Allow to initialize UI with source path and target path
  • Loading branch information
henryruhs committed Jul 12, 2023
commit 0b178d5f0eec0ba95907603eeac43f960839a01e
2 changes: 1 addition & 1 deletion roop/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ def parse_args() -> None:
roop.globals.source_path = args.source_path
roop.globals.target_path = args.target_path
roop.globals.output_path = normalize_output_path(roop.globals.source_path, roop.globals.target_path, args.output_path)
roop.globals.headless = roop.globals.source_path and roop.globals.target_path and roop.globals.output_path
roop.globals.frame_processors = args.frame_processor
roop.globals.headless = args.source_path or args.target_path or args.output_path
roop.globals.keep_fps = args.keep_fps
roop.globals.keep_frames = args.keep_frames
roop.globals.skip_audio = args.skip_audio
Expand Down
2 changes: 1 addition & 1 deletion roop/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
source_path = None
target_path = None
output_path = None
headless = None
frame_processors: List[str] = []
keep_fps = None
keep_frames = None
Expand All @@ -16,5 +17,4 @@
max_memory = None
execution_providers: List[str] = []
execution_threads = None
headless = None
log_level = 'error'
20 changes: 14 additions & 6 deletions roop/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C

source_label = ctk.CTkLabel(root, text=None)
source_label.place(relx=0.1, rely=0.1, relwidth=0.3, relheight=0.25)
if roop.globals.source_path:
select_source_path(roop.globals.source_path)

target_label = ctk.CTkLabel(root, text=None)
target_label.place(relx=0.6, rely=0.1, relwidth=0.3, relheight=0.25)
if roop.globals.target_path:
select_target_path(roop.globals.target_path)

source_button = ctk.CTkButton(root, text='Select a face', cursor='hand2', command=lambda: select_source_path())
source_button.place(relx=0.1, rely=0.4, relwidth=0.3, relheight=0.1)
Expand Down Expand Up @@ -127,11 +131,13 @@ def update_status(text: str) -> None:
ROOT.update()


def select_source_path() -> None:
def select_source_path(source_path: str = None) -> None:
global RECENT_DIRECTORY_SOURCE

PREVIEW.withdraw()
source_path = ctk.filedialog.askopenfilename(title='select an source image', initialdir=RECENT_DIRECTORY_SOURCE)
if PREVIEW:
PREVIEW.withdraw()
if source_path is None:
source_path = ctk.filedialog.askopenfilename(title='select an source image', initialdir=RECENT_DIRECTORY_SOURCE)
if is_image(source_path):
roop.globals.source_path = source_path
RECENT_DIRECTORY_SOURCE = os.path.dirname(roop.globals.source_path)
Expand All @@ -142,12 +148,14 @@ def select_source_path() -> None:
source_label.configure(image=None)


def select_target_path() -> None:
def select_target_path(target_path: str = None) -> None:
global RECENT_DIRECTORY_TARGET

PREVIEW.withdraw()
if PREVIEW:
PREVIEW.withdraw()
clear_face_reference()
target_path = ctk.filedialog.askopenfilename(title='select an target image or video', initialdir=RECENT_DIRECTORY_TARGET)
if target_path is None:
target_path = ctk.filedialog.askopenfilename(title='select an target image or video', initialdir=RECENT_DIRECTORY_TARGET)
if is_image(target_path):
roop.globals.target_path = target_path
RECENT_DIRECTORY_TARGET = os.path.dirname(roop.globals.target_path)
Expand Down
6 changes: 3 additions & 3 deletions roop/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import subprocess
import urllib
from pathlib import Path
from typing import List, Any
from typing import List, Optional
from tqdm import tqdm

import roop.globals
Expand Down Expand Up @@ -76,8 +76,8 @@ def get_temp_output_path(target_path: str) -> str:
return os.path.join(temp_directory_path, TEMP_FILE)


def normalize_output_path(source_path: str, target_path: str, output_path: str) -> Any:
if source_path and target_path:
def normalize_output_path(source_path: str, target_path: str, output_path: str) -> Optional[str]:
if source_path and target_path and output_path:
source_name, _ = os.path.splitext(os.path.basename(source_path))
target_name, target_extension = os.path.splitext(os.path.basename(target_path))
if os.path.isdir(output_path):
Expand Down
Loading