Commit Graph

140 Commits (585f58fbada14124d6a0e1fb9ec0a6500031884d)

Author SHA1 Message Date
rehanbgmi ea59ef7635 Enforce 90% face similarity for live webcam swaps; only swap if match is high. Improves accuracy and prevents mismatched swaps. 2025-05-26 16:18:56 +00:00
rehanbgmi ba008e72eb Improve FPS, blending, maintainability, and UI/UX for Deep-Live-Cam; address all review and Sourcery feedback; ready for deployment 2025-05-26 15:37:02 +00:00
rehanbgmi 348e6c424e Improve face swap FPS and blending, add profiling and config options 2025-05-26 15:17:31 +00:00
google-labs-jules[bot] d2794038f7 Okay, I've made a change to prioritize AVFoundation for macOS camera access.
I modified `modules/video_capture.py` so that it will explicitly try using `cv2.CAP_AVFOUNDATION` when initializing `cv2.VideoCapture` on macOS. If AVFoundation fails to open the camera, it will then fall back to the default OpenCV backend.

This adjustment should improve camera compatibility and stability on macOS, especially in situations where the default backend might not be working as expected.
2025-05-25 18:26:15 +00:00
google-labs-jules[bot] 521cad145d fix: Update type hints for Python 3.9 compatibility
Replaces Python 3.10+ type hint syntax (e.g., Frame | None)
with Python 3.9 compatible syntax (e.g., Optional[Frame])
in modules/processors/frame/face_swapper.py.

This resolves a TypeError encountered when running on Python 3.9.
Specifically, the return type of _prepare_warped_source_material_and_mask
was updated.
2025-05-25 18:10:43 +00:00
google-labs-jules[bot] 3d8af5180d fix: Correct IndentationError in modules/ui.py
Removes a duplicated 'if not modules.globals.map_faces:' line within the create_webcam_preview function. This error was causing a syntax issue and preventing the application from running correctly, particularly in webcam mode.
2025-05-25 17:57:58 +00:00
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
Teo Jia Cheng 9690070399 Update __init__.py 2025-05-13 00:14:49 +08:00
Kenneth Estanislao f3e83b985c
Merge pull request #1210 from KunjShah01/main
Update __init__.py
2025-05-12 15:14:58 +08:00
Gordon Böer bdbd7dcfbc
fix typos in ui.py 2025-05-07 13:23:31 +02:00
KUNJ SHAH a64940def7 update 2025-05-05 13:19:46 +00:00
KUNJ SHAH fe4a87e8f2 update 2025-05-05 13:19:29 +00:00
KUNJ SHAH 9ecd2dab83 changes 2025-05-05 13:10:00 +00:00
KUNJ SHAH c9f36eb350
Update __init__.py 2025-05-05 18:29:44 +05:30
NeuroDonu 890beb0eae
fix & add trt support 2025-04-19 16:03:49 +03:00
NeuroDonu 75b5b096d6
fix 2025-04-19 16:03:24 +03:00
Kenneth Estanislao 01900dcfb5 Revert "Update metadata.py"
This reverts commit 90d5c28542.
2025-04-17 02:39:05 +08:00
Kenneth Estanislao 07e30fe781 Revert "Update face_swapper.py"
This reverts commit 104d8cf4d6.
2025-04-17 02:03:34 +08:00
Kenneth Estanislao 90d5c28542 Update metadata.py
- 40% faster than 1.8
- compatible with 50xx GPU
- onnxruntime 1.21
2025-04-13 03:34:10 +08:00
Kenneth Estanislao 104d8cf4d6 Update face_swapper.py
compatibility with inswapper 1.21
2025-04-13 01:13:40 +08:00
Adrian Zimbran c728994e6b fixed import and log message 2025-03-10 23:41:28 +02:00
Adrian Zimbran 65da3be2a4 Fix face swapping crash due to None face embeddings
- Add explicit checks for face detection results (source and target faces).
- Handle cases when face embeddings are not available, preventing AttributeError.
- Provide meaningful log messages for easier debugging in future scenarios.
2025-03-10 23:31:56 +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 5132f86cdc add mutil language 2025-01-07 14:04:18 +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
Kenneth Estanislao 28513d6c1f
Update metadata.py 2025-01-06 00:27:45 +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
Mehdi Mousavi 81da9a23ca Fix mouth mask description 2024-12-24 09:51:32 +03:30
Mehdi Mousavi 007867a6f6 Add support for --mouth-mask argument 2024-12-24 09:40:06 +03:30
KRSHH b17e52dea2
Mac Webcam Serial No. Management 2024-12-23 22:45:41 +05:30
KRSHH 77c19d1073 FaceTime Camera Index to 0 2024-12-23 14:58:43 +05:30
Pedro Santos 7472dfb694 fix: add match statement
Added for optimization

Co-Authored-By: Zephira <zephira58@protonmail.com>
2024-12-23 06:29:36 +00:00
Pedro Santos 41c6916273 Revert "Update face_enhancer.py"
This reverts commit ed7a21687c.
2024-12-23 06:08:45 +00:00
Kenneth Estanislao ed7a21687c Update face_enhancer.py
change if from before statement to elif, also fix conditional ladder
2024-12-23 12:45:53 +08:00
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 76b94ac034
Changed Metadata to GitHub Edition 2024-12-22 18:28:38 +05:30
KRSHH 84ca1dc2f2 Make Face Enhancer Model device Conditional
Added Co-Author

Co-Authored-By: Rishon <rishon@rishon.me>
2024-12-19 21:18:28 +05:30
KRSHH 681c20dbbd Revert "Make Face Enhancer Model device Conditional"
This reverts commit c240f6e31c.
2024-12-19 21:16:56 +05:30
KRSHH c240f6e31c Make Face Enhancer Model device Conditional 2024-12-19 21:12:57 +05:30
KRSHH 4bb979faf0
Update metadata.py 2024-12-18 22:45:58 +05:30