Skip to content

Commit

Permalink
Different way to handle THIS
Browse files Browse the repository at this point in the history
  • Loading branch information
henryruhs committed Aug 15, 2023
1 parent 1462039 commit 9bfeb95
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
6 changes: 3 additions & 3 deletions roop/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def parse_args() -> None:
program.add_argument('--face-analyser-age', help='age used for the face analyser', dest='face_analyser_age', choices=['child', 'teen', 'adult', 'senior'])
program.add_argument('--face-analyser-gender', help='gender used for the face analyser', dest='face_analyser_gender', choices=['male', 'female'])
program.add_argument('--reference-face-position', help='position of the reference face', dest='reference_face_position', type=int, default=0)
program.add_argument('--reference-face-distance', help='distance between reference face and target face', dest='reference_face_distance', type=float, default=0.85)
program.add_argument('--reference-face-distance', help='distance between reference face and target face', dest='reference_face_distance', type=float, default=1.5)
program.add_argument('--reference-frame-number', help='number of the reference frame', dest='reference_frame_number', type=int, default=0)
program.add_argument('--trim-frame-start', help='start frame use for extraction', dest='trim_frame_start', type=int)
program.add_argument('--trim-frame-end', help='end frame use for extraction', dest='trim_frame_end', type=int)
Expand Down Expand Up @@ -151,7 +151,7 @@ def start() -> None:
# process image to image
if has_image_extension(roop.globals.target_path):
if predict_image(roop.globals.target_path):
destroy()
return
shutil.copy2(roop.globals.target_path, roop.globals.output_path)
# process frame
for frame_processor_module in get_frame_processors_modules(roop.globals.frame_processors):
Expand All @@ -166,7 +166,7 @@ def start() -> None:
return
# process image to videos
if predict_video(roop.globals.target_path):
destroy()
return
update_status('Creating temporary resources...')
create_temp(roop.globals.target_path)
# extract frames
Expand Down
2 changes: 1 addition & 1 deletion roop/predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

PREDICTOR = None
THREAD_LOCK = threading.Lock()
MAX_PROBABILITY = 0.85
MAX_PROBABILITY = 0.75


def get_predictor() -> Model:
Expand Down
2 changes: 1 addition & 1 deletion roop/uis/__components__/face_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def render() -> None:
REFERENCE_FACE_DISTANCE_SLIDER = gradio.Slider(
label='REFERENCE FACE DISTANCE',
value=roop.globals.reference_face_distance,
maximum=2,
maximum=3,
step=0.05,
visible='reference' in roop.globals.face_recognition
)
Expand Down
7 changes: 3 additions & 4 deletions roop/uis/__components__/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import roop.globals
from roop.core import start
from roop.uis.typing import Update
from roop.utilities import has_image_extension, has_video_extension, normalize_output_path

from roop.utilities import is_image, is_video, normalize_output_path

START_BUTTON: Optional[gradio.Button] = None
CLEAR_BUTTON: Optional[gradio.Button] = None
Expand Down Expand Up @@ -42,9 +41,9 @@ def update() -> Tuple[Update, Update]:
roop.globals.output_path = normalize_output_path(roop.globals.source_path, roop.globals.target_path, '..')
if roop.globals.output_path:
start()
if has_image_extension(roop.globals.output_path):
if is_image(roop.globals.output_path):
return gradio.update(value=roop.globals.output_path, visible=True), gradio.update(value=None, visible=False)
if has_video_extension(roop.globals.output_path):
if is_video(roop.globals.output_path):
return gradio.update(value=None, visible=False), gradio.update(value=roop.globals.output_path, visible=True)
return gradio.update(value=None, visible=False), gradio.update(value=None, visible=False)

Expand Down
3 changes: 1 addition & 2 deletions roop/uis/__components__/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import roop.globals
from roop.capturer import get_video_frame, get_video_frame_total
from roop.core import destroy
from roop.face_analyser import get_one_face
from roop.face_reference import get_face_reference, set_face_reference
from roop.predictor import predict_frame
Expand Down Expand Up @@ -91,7 +90,7 @@ def update(frame_number: int = 0) -> Tuple[Update, Update]:

def extract_preview_frame(temp_frame: Frame) -> Frame:
if predict_frame(temp_frame):
destroy()
return cv2.GaussianBlur(temp_frame, (99, 99), 0)
source_face = get_one_face(cv2.imread(roop.globals.source_path)) if roop.globals.source_path else None
temp_frame = reduce_preview_frame(temp_frame)
if 'reference' in roop.globals.face_recognition and not get_face_reference():
Expand Down

0 comments on commit 9bfeb95

Please sign in to comment.