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 (Sourcery refactored) #3

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open

Next (Sourcery refactored) #3

wants to merge 1 commit into from

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Nov 25, 2023

Pull Request #2 refactored by Sourcery.

Since the original Pull Request was opened as a fork in a contributor's
repository, we are unable to create a Pull Request branching from it.

To incorporate these changes, you can either:

  1. Merge this Pull Request instead of the original, or

  2. Ask your contributor to locally incorporate these commits and push them to
    the original Pull Request

    Incorporate changes via command line
    git fetch https://github.com/hacksider/masterfusion-unlocked pull/2/head
    git merge --ff-only FETCH_HEAD
    git push

NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from hacksider November 25, 2023 07:57
if frame_hash in FACES_CACHE:
return FACES_CACHE[frame_hash]
return None
return FACES_CACHE[frame_hash] if frame_hash in FACES_CACHE else None
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_faces_cache refactored with the following changes:

Comment on lines -17 to +15
frame_hash = create_frame_hash(frame)
if frame_hash:
if frame_hash := create_frame_hash(frame):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function set_faces_cache refactored with the following changes:

Comment on lines -61 to +74
subprocess.call([ 'pip', 'install', '-r', 'requirements.txt', '--extra-index-url', 'https://download.pytorch.org/whl/' + torch_wheel ])
subprocess.call(
[
'pip',
'install',
'-r',
'requirements.txt',
'--extra-index-url',
f'https://download.pytorch.org/whl/{torch_wheel}',
]
)
subprocess.call([ 'pip', 'uninstall', 'onnxruntime', onnxruntime_name, '-y' ])
subprocess.call([ 'pip', 'install', onnxruntime_name + '==' + onnxruntime_version ])
subprocess.call(
['pip', 'install', f'{onnxruntime_name}=={onnxruntime_version}']
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function run refactored with the following changes:

commands = [ 'ffmpeg', '-hide_banner', '-loglevel', 'error' ]
commands.extend(args)
commands = ['ffmpeg', '-hide_banner', '-loglevel', 'error', *args]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function run_ffmpeg refactored with the following changes:

Comment on lines -40 to +39
commands = [ 'ffmpeg', '-hide_banner', '-loglevel', 'error' ]
commands.extend(args)
commands = ['ffmpeg', '-hide_banner', '-loglevel', 'error', *args]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function open_ffmpeg refactored with the following changes:

Comment on lines -197 to +202
if model_type == 'blendface':
frame_processor_inputs[frame_processor_input.name] = prepare_source_frame(source_face)
else:
frame_processor_inputs[frame_processor_input.name] = prepare_source_embedding(source_face)
if frame_processor_input.name == 'target':
frame_processor_inputs[frame_processor_input.name] = (
prepare_source_frame(source_face)
if model_type == 'blendface'
else prepare_source_embedding(source_face)
)
elif frame_processor_input.name == 'target':
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function swap_face refactored with the following changes:

  • Simplify conditional into switch-like form [×3] (switch)
  • Replace if statement with if expression (assign-if-exp)

Comment on lines -248 to +258
similar_faces = find_similar_faces(temp_frame, reference_face, facefusion.globals.reference_face_distance)
if similar_faces:
if similar_faces := find_similar_faces(
temp_frame, reference_face, facefusion.globals.reference_face_distance
):
for similar_face in similar_faces:
temp_frame = swap_face(source_face, similar_face, temp_frame)
if 'one' in facefusion.globals.face_selector_mode:
target_face = get_one_face(temp_frame)
if target_face:
if target_face := get_one_face(temp_frame):
temp_frame = swap_face(source_face, target_face, temp_frame)
if 'many' in facefusion.globals.face_selector_mode:
many_faces = get_many_faces(temp_frame)
if many_faces:
if many_faces := get_many_faces(temp_frame):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function process_frame refactored with the following changes:

component = get_ui_component(component_name)
if component:
if component := get_ui_component(component_name):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function listen refactored with the following changes:

source_image = get_ui_component('source_image')
if source_image:
if source_image := get_ui_component('source_image'):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function listen refactored with the following changes:

Comment on lines -145 to +144
commands.extend([ '-f', 'v4l2', '/dev/' + device_name ])
commands.extend(['-f', 'v4l2', f'/dev/{device_name}'])
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function open_stream refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants