Skip to main content

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:

  1. Detector - checks if a face exists in a given photo and cuts it out if it does;
  2. Recogniser - extracts the facial features from the cropped photo to be used for the change;
  3. Generator - Creates a new face from the facial features of the source face to the facial expression of the target;
  4. 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. 
![](docs/img.png)

 

 

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:
  1. Transformer - text is extracted from the source audio;
  • Text to speech
  1. Phonetics class - converts text to phonetic data;
  2. Encoder - extracts features of the target voice;
  3. Acoustic model - matches the features of the source text with the features of the target sound;
  4. Vocoder - text features converted to voice by the target voice features.
![](docs/voice_schema.png)

 

Changing the video (face and/or voice):

  1. Separates the audio of the target video (if it exists);
  2. If the source is a video, the first frame containing the person is taken (if the source is a photo, nothing is done);
  3. Changes the face in the video (if the source is a photo or video):
    1. Repeat over each frame;
    2. changing the face in the frame (photo) (as in an ordinary photo);
    3. the new frame (target photo with the face of the source) is saved in the list);
    4. after iteration, the list of frames is converted into a video;
  4. Voice in the video is changed (if the source is a video or audio file):
    1. If the target or source did not have a voice - do nothing
    2. If there is only the voice of the target, it is added to the created video;
    3. 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).
![](docs/video_schema.png)

 

 

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

person_swap-1.0.0.tar.gz (37.3 kB view details)

Uploaded Source

Built Distribution

person_swap-1.0.0-py3-none-any.whl (47.6 kB view details)

Uploaded Python 3

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

Hashes for person_swap-1.0.0.tar.gz
Algorithm Hash digest
SHA256 46a3a0f430edaaad5997e5f82c4b15cf0f12348ecf2eafca3346fe5e07303397
MD5 4a4fb6211f63fd02f9a2ce343cdc66c6
BLAKE2b-256 84b4afbc3a8641c505e8beab70cebd1add4f50dfd6c9135eb850effe526006ed

See more details on using hashes here.

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

Hashes for person_swap-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6460d5a08374581123a24d7c79e282efb8f62160700abf17447546113c69c8a9
MD5 a51331dacfee0342888683312e605a53
BLAKE2b-256 b5c34c83691155f5098761ad0bd15da03b4bb897a3d04fed5185169e6438ca95

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page