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

Add batch face swap option #1050

Closed
wants to merge 1 commit into from
Closed

Conversation

lead8964878
Copy link

@lead8964878 lead8964878 commented Jan 7, 2025

Batch Face Swap Feature

I have the same requirement as issue #957, so I have implemented a batch face swap feature.
圖片
When this toggle box is checked, the feature will loop through all input faces, apply face swapping to all target files (including images and videos), and save the output files with the input face's filename as a prefix.

Note: This feature does not support situations with multiple target faces, such as "Selected Face" mode with multiple targets or "All Input/All Random Faces" mode.


Implementation Details

This feature operates differently for images and videos:

1. Images

  • The current selected face index is ignored.
  • All faces are combined with all images and submitted to the swapping queue, starting from face 0.
  • The main implementation for this part is located in ProcessMgr.process_frame().

2. Videos

  • Processing starts from the user's currently selected face and loops through the faces sequentially.
  • For example, if there are three faces and two videos, and the user selects face 1, the processing sequence will be:
    face1_video0, face2_video0, face0_video0, face1_video1, face2_video1, face0_video1
  • The main implementation for this part is located in core.py.

I have made minimal modifications to the code structure to maintain clarity.

Please review and let me know if there is a better way to approach this feature.
Thank you very much for this fabulous work!

@C0untFloyd
Copy link
Owner

Honestly, your PR is clean and concise and there's nothing bad about it. Despite this, I feel that I need to reject it because it's a (albeit neat) workaround for something it wasn't meant for. You see, many people wished for batch processing in many different forms over the time. I recently implemented some sort of hack with the all input faces and random faces mode. I'm not proud of it either but at least this is a specific mode you can choose among other options.
Your PR however pushed me to try and create this myself, I've announced it right here: #1051

@C0untFloyd C0untFloyd closed this Jan 9, 2025
@lead8964878
Copy link
Author

Thank you for your reply and affirmation. You're absolutely right—my approach does have its limitations and shortcomings. I think your idea is excellent and offers a much cleaner and more efficient solution for handling this batch processing functionality. Look forward to seeing it completed!

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.

2 participants