TODO
Project description
Person Swap
Info how to use system and how models works
Changing the photo (face)
4 models (files) are used to change the face:
- Detector - checks if a face exists in a given photo and cuts it out if it does;
- Recogniser - extracts the facial features from the cropped photo to be used for the change;
- Generator - Creates a new face from the facial features of the source face to the facial expression of the target;
- Mask detector - extracts the facial contour mask during the face change in the source photo (you can use libraries in CV2 anyway), but the model is more accurate as far as I have noticed.
Generator operation - the recognition model extracts the identity of the face in the photo (Ts for source or Tt for target).
The face change itself is performed by the generator, which consists of:
- The encoder - extracts the features of the target face;
- Identity Change Module - transfers the identity extracted from the source image to target photo features;
- Decoder - reconstructs a modified image of target photo features and source identity.
Changing the sound (voice)
The paddlespeech library is used, which can use existing or newly developed models for voice replacement. The models used for voice replacement in the project are:
- Speech to text:
- Transformer - text is extracted from the source audio;
- Text to speech
- Phonetics class - converts text to phonetic data;
- Encoder - extracts features of the target voice;
- Acoustic model - matches the features of the source text with the features of the target sound;
- Vocoder - text features converted to voice by the target voice features.
Changing the video (face and/or voice):
- Separates the audio of the target video (if it exists);
- If the source is a video, the first frame containing the person is taken (if the source is a photo, nothing is done);
- Changes the face in the video (if the source is a photo or video):
- Repeat over each frame;
- changing the face in the frame (photo) (as in an ordinary photo);
- the new frame (target photo with the face of the source) is saved in the list);
- after iteration, the list of frames is converted into a video;
- Voice in the video is changed (if the source is a video or audio file):
- If the target or source did not have a voice - do nothing
- If there is only the voice of the target, it is added to the created video;
- If there is both a source and a target voice - the source's voice is replaced by the target's voice (as in voice replacement).
MIT License
Copyright (c) 2023 Segal011
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file person_swap-1.0.0.tar.gz
.
File metadata
- Download URL: person_swap-1.0.0.tar.gz
- Upload date:
- Size: 37.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46a3a0f430edaaad5997e5f82c4b15cf0f12348ecf2eafca3346fe5e07303397 |
|
MD5 | 4a4fb6211f63fd02f9a2ce343cdc66c6 |
|
BLAKE2b-256 | 84b4afbc3a8641c505e8beab70cebd1add4f50dfd6c9135eb850effe526006ed |
File details
Details for the file person_swap-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: person_swap-1.0.0-py3-none-any.whl
- Upload date:
- Size: 47.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6460d5a08374581123a24d7c79e282efb8f62160700abf17447546113c69c8a9 |
|
MD5 | a51331dacfee0342888683312e605a53 |
|
BLAKE2b-256 | b5c34c83691155f5098761ad0bd15da03b4bb897a3d04fed5185169e6438ca95 |