Commit Graph

87 Commits (ff0608292deb7158952c59096eeabee2cae68413)

Author SHA1 Message Date
google-labs-jules[bot] 2e617c9401 feat: Add setup and run scripts for macOS
This commit introduces shell scripts to automate the setup process and provide convenient ways to run the application on macOS.

New files added:
- setup_mac.sh: Checks for Python 3.9+ and ffmpeg, creates a virtual environment, installs pip dependencies from requirements.txt.
- run_mac.sh: Runs the application with the CPU execution provider by default.
- run_mac_cpu.sh: Explicitly runs with the CPU execution provider.
- run_mac_coreml.sh: Runs with the CoreML execution provider.
- run_mac_mps.sh: Runs with the MPS execution provider.

The README.md has also been updated with a new section detailing how to use these scripts for macOS users.

These scripts aim to simplify the initial setup and execution of the project on macOS, similar to the .bat files available for Windows.
2025-05-25 17:03:27 +00:00
google-labs-jules[bot] 37486f03e7 feat: Implement hair swapping and enhance realism
This commit introduces the capability to swap hair along with the face from a source image to a target image/video or live webcam feed.

Key changes include:

1.  **Hair Segmentation:**
    - Integrated the `isjackwild/segformer-b0-finetuned-segments-skin-hair-clothing` model from Hugging Face using the `transformers` library.
    - Added `modules/hair_segmenter.py` with a `segment_hair` function to produce a binary hair mask from an image.
    - Updated `requirements.txt` with `transformers`.

2.  **Combined Face-Hair Mask:**
    - Implemented `create_face_and_hair_mask` in `modules/processors/frame/face_swapper.py` to generate a unified mask for both face (from landmarks) and segmented hair from the source image.

3.  **Enhanced Swapping Logic:**
    - Modified `swap_face` and related processing functions (`process_frame`, `process_frame_v2`, `process_frames`, `process_image`) to utilize the full source image (`source_frame_full`).
    - The `swap_face` function now performs the standard face swap and then:
        - Segments hair from the `source_frame_full`.
        - Warps the hair and its mask to the target face's position using an affine transformation estimated from facial landmarks.
        - Applies color correction (`apply_color_transfer`) to the warped hair.
        - Blends the hair onto the target frame, preferably using `cv2.seamlessClone` for improved realism.
    - Existing mouth mask logic is preserved and applied to the final composited frame.

4.  **Webcam Integration:**
    - Updated the webcam processing loop in `modules/ui.py` (`create_webcam_preview`) to correctly load and pass the `source_frame_full` to the frame processors.
    - This enables hair swapping in live webcam mode.
    - Added error handling for source image loading in webcam mode.

This set of changes addresses your request for more realistic face swaps that include hair. Further testing and refinement of blending parameters may be beneficial for optimal results across all scenarios.
2025-05-21 18:47:31 +00:00
Gordon Böer bdbd7dcfbc
fix typos in ui.py 2025-05-07 13:23:31 +02:00
Kenneth Estanislao 28c4b34db1
Merge pull request #911 from nimishgautam/main
Fix cv2 size errors on first run in ui.py
2025-02-05 12:51:39 +08:00
Soul Lee 513e413956 fix: typo souce_target_map → source_target_map 2025-02-03 20:33:44 +09:00
Nimish Gåtam ccc04983cf
Update ui.py
removed unnecessary code as per AI code review (which is a thing now because of course it is)
2025-02-01 12:38:37 +01:00
Nimish Gåtam 2506c5a261
Update ui.py
Some checks for first run when models are missing, so it doesn't error out with inv_scale_x > 0 in cv2
2025-02-01 11:52:49 +01:00
qitian 6e29e4061b merge from the source and little change 2025-01-07 13:46:17 +08:00
Makaru d07d4a6a26 Update ui.py
I pushed it to premain
2025-01-07 01:15:05 +08:00
Kenneth Estanislao b38831dfdf Revert "Merge pull request #868 from kier007/main"
This reverts commit c03f697729, reversing
changes made to d8a5cdbc19.
2025-01-06 14:14:21 +08:00
Kenneth Estanislao b518f4337d Revert "Merge pull request #869 from kier007/patch-1"
This reverts commit b38ef62447, reversing
changes made to c03f697729.
2025-01-06 14:14:04 +08:00
Makaru a3469b7bd4
Update ui.py
Added:
- If you happen to turn off the map faces switch while the Source x Target Mapper window is open, the Source x Target Mapper window will close.
2025-01-06 00:10:53 +08:00
Makaru 742bcab130
Update ui.py
Added:
- try-finally Block: This makes sure the camera.release() is called no matter how the while loops end.
- Resource Cleanup: The finally block takes care of cleaning up resources to keep the application stable.
2025-01-05 20:19:36 +08:00
Makaru 22940d1b99
Update ui.py
The following changes have been implemented:
-A "clear" button has been incorporated.
-The Source x Target Mapper window has been retained following the submission of data via the "submit" button.
2025-01-05 18:29:01 +08:00
KRSHH 8be7368949
Added URL to official website 2024-12-30 15:51:46 +05:30
KRSHH 77c19d1073 FaceTime Camera Index to 0 2024-12-23 14:58:43 +05:30
KRSHH 5ce991651d Formatting
Moved Windows only modules, to top too.
2024-12-23 09:46:59 +05:30
KRSHH 432984b3b6 Mac Fix
Pygrabber Module import only on windows
2024-12-23 09:41:17 +05:30
KRSHH a9e8f27360 Pygrabber only for Windows 2024-12-16 18:41:39 +05:30
KRSHH c72582506d Adding Pygrabber as Cam manager 2024-12-13 19:49:11 +05:30
theogbob 916c2f82d8
Fix ui.py
Add command to "mouth_mask": modules.globals.mouth_mask which fixes the error "SyntaxError: invalid syntax. Perhaps you forgot a comma?"
2024-10-26 14:40:03 -04:00
KRSHH 80f6ea9e65
Save Mouth Mask Switch states 2024-10-26 17:54:45 +05:30
KRSHH 29c9c119d3 Add Mouth Mask Feature 2024-10-25 20:59:30 +05:30
KRSHH ab26413ce8 on/off enhancer during inference and improve FPS counter 2024-10-13 13:16:21 +05:30
KRSHH 53d473164b
remember/save switch states 2024-10-09 19:51:04 +05:30
KRSHH 88164c6303
Show FPS Switch 2024-10-05 17:39:41 +05:30
KRSHH a49d3fc6e5
Face Mapping fix 2024-10-05 15:00:00 +05:30
KRSHH 5812ef3cc9 Webcam selection 2024-10-05 01:37:19 +08:00
KRSHH 75decc5838
Hotswap Source image - switch faces without closing live 2024-10-04 18:17:22 +05:30
Kenneth Estanislao f38ebb485a Update ui.py
removed opacity, will work on it later to optimize
2024-10-04 15:39:08 +08:00
Kenneth Estanislao 95742c8fd5 Merge pull request #686 from GhoulBoii/main
BOUNTY - Webcam Merged (tested)
2024-10-04 14:46:06 +08:00
Kenneth Estanislao 60e27f4755 Revert "Merge pull request #685 from KRSHH/main"
This reverts commit d4e5b8078d, reversing
changes made to c08bec22e3.
2024-10-03 14:51:38 +08:00
KRSHH 61b51fc5d4
Move the slider from live to root 2024-10-02 14:37:19 +05:30
KRSHH f19e425143
Update ui.py 2024-10-02 14:20:56 +05:30
KRSHH 12c0a7ac86
Faceswap live opacity slider 2024-10-02 13:23:39 +05:30
KRSHH dff6cec2f9
Comment Indention fix 2024-09-27 20:59:48 +05:30
KRSHH 4d1d2c86af
Preview video Frame by Frame using left and right arrow keys 2024-09-27 20:40:32 +05:30
KRSHH 6d1238212a
New Fixed UI 2024-09-25 17:36:50 +05:30
Kenneth Estanislao fd4e3f546d reverted to the old version
fixing the issue #597
2024-09-19 17:38:02 +08:00
Kenneth Estanislao 5bcd6dabde Update ui.py 2024-09-19 15:54:57 +08:00
KRSHH 4067d24c26 Fix Popup Live width 2024-09-17 20:18:59 +08:00
Kenneth Estanislao ea7bbd49fe Revert "Merge pull request #592 from KRSHH/main"
This reverts commit 2f29d323d9.
2024-09-16 23:34:35 +08:00
Kenneth Estanislao 2f29d323d9 Merge pull request #592 from KRSHH/main
Better UI
2024-09-16 23:32:39 +08:00
Kenneth Estanislao c6e00796c8 Merge pull request #588 from KRSHH/main
Enhance UI with drag and drop, modern look using customtkinter, and improved webcam mapping
2024-09-16 23:30:12 +08:00
Kenneth Estanislao 9bf2080ac8 Revert "Merge pull request #588 from KRSHH/main"
This reverts commit 8c6d0134a8, reversing
changes made to 621c3f035e.
2024-09-16 22:18:59 +08:00
Kenneth Estanislao 5ab00388b7 Revert "Merge pull request #592 from KRSHH/main"
This reverts commit 4768488653, reversing
changes made to 8c6d0134a8.
2024-09-16 22:18:53 +08:00
KRSHH 569c9ca25a
Resizable Root window 2024-09-16 19:13:54 +05:30
KRSHH c9f8537a15
Switch alignment 2024-09-16 18:53:19 +05:30
KRSHH 2d99e392ff
Vertical switches 2024-09-16 18:48:05 +05:30
KRSHH 2b9d10f182
Donation button, close option button 2024-09-16 16:54:49 +05:30