Upload 204 files
Browse filesThis view is limited to 50 files because it contains too many changes. Β See raw diff
Files changed (50)
- .gitattributes+81
- SimSwap/.gitattributesAdded+2
- SimSwap/.gitignoreAdded+145
- SimSwap/LICENSEAdded+399
- SimSwap/MultiSpecific.ipynbAdded+1
- SimSwap/README.mdAdded+247
- SimSwap/SimSwap colab.ipynbAdded+579
- SimSwap/arcface_model/arcface_checkpoint.tarAdded+3
- SimSwap/checkpoints/people/iter.txtAdded+2
- SimSwap/checkpoints/people/latest_net_D1.pthAdded+3
- SimSwap/checkpoints/people/latest_net_D2.pthAdded+3
- SimSwap/checkpoints/people/latest_net_G.pthAdded+3
- SimSwap/checkpoints/people/loss_log.txtAdded
- SimSwap/checkpoints/people/opt.txtAdded+72
- SimSwap/cog.yamlAdded+20
- SimSwap/data/data_loader_Swapping.pyAdded+125
- SimSwap/docs/css/bootstrap-theme.min.cssAdded+6
- SimSwap/docs/css/bootstrap.min.cssAdded
- SimSwap/docs/css/ie10-viewport-bug-workaround.cssAdded+13
- SimSwap/docs/css/jumbotron.cssAdded+5
- SimSwap/docs/css/page.cssAdded+49
- SimSwap/docs/favicon.icoAdded
- SimSwap/docs/fonts/glyphicons-halflings-regular.eotAdded
- SimSwap/docs/fonts/glyphicons-halflings-regular.svgAdded
- SimSwap/docs/fonts/glyphicons-halflings-regular.ttfAdded
- SimSwap/docs/fonts/glyphicons-halflings-regular.woffAdded
- SimSwap/docs/fonts/glyphicons-halflings-regular.woff2Added
- SimSwap/docs/guidance/preparation.mdAdded+37
- SimSwap/docs/guidance/usage.mdAdded+115
- SimSwap/docs/img/LRGT_201110059_201110091.webpAdded
- SimSwap/docs/img/anni.webpAdded
- SimSwap/docs/img/chenglong.webpAdded
- SimSwap/docs/img/girl2-RGB.pngAdded
- SimSwap/docs/img/girl2.gifAdded
- SimSwap/docs/img/id/Iron_man.jpgAdded
- SimSwap/docs/img/id/anni.jpgAdded
- SimSwap/docs/img/id/chenglong.jpgAdded
- SimSwap/docs/img/id/wuyifan.pngAdded
- SimSwap/docs/img/id/zhoujielun.jpgAdded
- SimSwap/docs/img/id/zhuyin.jpgAdded
- SimSwap/docs/img/logo.pngAdded
- SimSwap/docs/img/logo1.pngAdded
- SimSwap/docs/img/logo2.pngAdded
- SimSwap/docs/img/mama_mask_short.webpAdded
- SimSwap/docs/img/mama_mask_wuyifan_short.webpAdded
- SimSwap/docs/img/multi_face_comparison.pngAdded
- SimSwap/docs/img/new.gifAdded
- SimSwap/docs/img/nrsig.pngAdded
- SimSwap/docs/img/result_whole_swap_multispecific_512.jpgAdded
- SimSwap/docs/img/results1.PNGAdded
105 unmodified lines106107108105 unmodified linesWav2Lip-HD/Real-ESRGAN/tests/data/gt.lmdb/data.mdb filter=lfs diff=lfs merge=lfs -textWav2Lip-HD/Real-ESRGAN/tests/data/gt/baboon.png filter=lfs diff=lfs merge=lfs -textWav2Lip-HD/Real-ESRGAN/tests/data/gt/comic.png filter=lfs diff=lfs merge=lfs -text105 unmodified lines106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189105 unmodified linesWav2Lip-HD/Real-ESRGAN/tests/data/gt.lmdb/data.mdb filter=lfs diff=lfs merge=lfs -textWav2Lip-HD/Real-ESRGAN/tests/data/gt/baboon.png filter=lfs diff=lfs merge=lfs -textWav2Lip-HD/Real-ESRGAN/tests/data/gt/comic.png filter=lfs diff=lfs merge=lfs -textSimSwap/docs/img/anni.webp filter=lfs diff=lfs merge=lfs -textSimSwap/docs/img/chenglong.webp filter=lfs diff=lfs merge=lfs -textSimSwap/docs/img/girl2-RGB.png filter=lfs diff=lfs merge=lfs -textSimSwap/docs/img/girl2.gif filter=lfs diff=lfs merge=lfs -textSimSwap/docs/img/id/wuyifan.png filter=lfs diff=lfs merge=lfs -textSimSwap/docs/img/id/zhuyin.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/docs/img/LRGT_201110059_201110091.webp filter=lfs diff=lfs merge=lfs -textSimSwap/docs/img/mama_mask_short.webp filter=lfs diff=lfs merge=lfs -textSimSwap/docs/img/mama_mask_wuyifan_short.webp filter=lfs diff=lfs merge=lfs -textSimSwap/docs/img/multi_face_comparison.png filter=lfs diff=lfs merge=lfs -textSimSwap/docs/img/nrsig.png filter=lfs diff=lfs merge=lfs -textSimSwap/docs/img/result_whole_swap_multispecific_512.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/docs/img/results1.PNG filter=lfs diff=lfs merge=lfs -textSimSwap/docs/img/title.png filter=lfs diff=lfs merge=lfs -textSimSwap/docs/img/total.PNG filter=lfs diff=lfs merge=lfs -textSimSwap/docs/img/vggface2_hq_compare.png filter=lfs diff=lfs merge=lfs -textSimSwap/docs/img/video.webp filter=lfs diff=lfs merge=lfs -textSimSwap/docs/img/zhoujielun.webp filter=lfs diff=lfs merge=lfs -textSimSwap/docs/img/zhuyin.webp filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000000.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000001.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000002.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000003.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000004.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000005.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000006.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000007.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000008.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000009.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000010.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000011.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000012.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000013.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000014.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000015.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000016.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000017.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000018.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000019.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000020.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000021.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000022.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000023.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000024.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000025.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000026.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000027.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000028.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000029.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000030.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000031.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000032.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000033.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000034.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000035.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000036.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000037.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000038.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000039.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000040.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000041.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000042.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000043.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000044.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000045.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000046.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000047.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000048.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000049.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000050.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000051.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000052.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000053.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000054.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000055.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000056.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000057.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000058.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000059.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000060.jpg filter=lfs diff=lfs merge=lfs -textSimSwap/temp_results/frame_0000061.jpg filter=lfs diff=lfs merge=lfs -text
12# Auto detect text files and perform LF normalization* text=auto123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145# Byte-compiled / optimized / DLL files__pycache__/*.py[cod]*$py.class
# C extensions*.so
# Distribution / packaging.Pythonbuild/develop-eggs/dist/downloads/eggs/.eggs/lib/lib64/parts/sdist/var/wheels/pip-wheel-metadata/share/python-wheels/*.egg-info/.installed.cfg*.eggMANIFEST
# PyInstaller# Usually these files are written by a python script from a template# before PyInstaller builds the exe, so as to inject date/other infos into it.*.manifest*.spec
# Installer logspip-log.txtpip-delete-this-directory.txt
# Unit test / coverage reportshtmlcov/.tox/.nox/.coverage.coverage.*.cachenosetests.xmlcoverage.xml*.cover*.py,cover.hypothesis/.pytest_cache/
# Translations*.mo*.pot
# Django stuff:*.loglocal_settings.pydb.sqlite3db.sqlite3-journal
# Flask stuff:instance/.webassets-cache
# Scrapy stuff:.scrapy
# Sphinx documentationdocs/_build/
# PyBuildertarget/
# Jupyter Notebook.ipynb_checkpoints
# IPythonprofile_default/ipython_config.py
# pyenv.python-version
# pipenv# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.# However, in case of collaboration, if having platform-specific dependencies or dependencies# having no cross-platform support, pipenv may install dependencies that don't work, or not# install all needed dependencies.#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow__pypackages__/
# Celery stuffcelerybeat-schedulecelerybeat.pid
# SageMath parsed files*.sage.py
# Environments.env.venvenv/venv/ENV/env.bak/venv.bak/
# Spyder project settings.spyderproject.spyproject
# Rope project settings.ropeproject
# mkdocs documentation/site
# mypy.mypy_cache/.dmypy.jsondmypy.json
# Pyre type checker.pyre/
docs/ppt/checkpoints/*.tar*.patch*.zip*.avi*.pdf*.pptx
*.pth*.onnxwandb/temp_results/output/*.*/cr123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399Attribution-NonCommercial 4.0 International
=======================================================================
Creative Commons Corporation ("Creative Commons") is not a law firm anddoes not provide legal services or legal advice. Distribution ofCreative Commons public licenses does not create a lawyer-client orother relationship. Creative Commons makes its licenses and relatedinformation available on an "as-is" basis. Creative Commons gives nowarranties regarding its licenses, any material licensed under theirterms and conditions, or any related information. Creative Commonsdisclaims all liability for damages resulting from their use to thefullest extent possible.
Using Creative Commons Public Licenses
Creative Commons public licenses provide a standard set of terms andconditions that creators and other rights holders may use to shareoriginal works of authorship and other material subject to copyrightand certain other rights specified in the public license below. Thefollowing considerations are for informational purposes only, are notexhaustive, and do not form part of our licenses.
Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC- licensed material, or material used under an exception or limitation to copyright. More considerations for licensors: wiki.creativecommons.org/Considerations_for_licensors
Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor's permission is not necessary for any reason--for example, because of any applicable exception or limitation to copyright--then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More_considerations for the public: wiki.creativecommons.org/Considerations_for_licensees
=======================================================================
Creative Commons Attribution-NonCommercial 4.0 International PublicLicense
By exercising the Licensed Rights (defined below), You accept and agreeto be bound by the terms and conditions of this Creative CommonsAttribution-NonCommercial 4.0 International Public License ("PublicLicense"). To the extent this Public License may be interpreted as acontract, You are granted the Licensed Rights in consideration of Youracceptance of these terms and conditions, and the Licensor grants Yousuch rights in consideration of benefits the Licensor receives frommaking the Licensed Material available under these terms andconditions.
Section 1 -- Definitions.
a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. d. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
e. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
f. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
g. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
h. Licensor means the individual(s) or entity(ies) granting rights under this Public License.
i. NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
j. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
k. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
l. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
Section 2 -- Scope.
a. License grant.
1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
a. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and
b. produce, reproduce, and Share Adapted Material for NonCommercial purposes only.
2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
3. Term. The term of this Public License is specified in Section 6(a).
4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a) (4) never produces Adapted Material.
5. Downstream recipients.
a. Offer from the Licensor -- Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
b. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
b. Other rights.
1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
2. Patent and trademark rights are not licensed under this Public License.
3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes.
Section 3 -- License Conditions.
Your exercise of the Licensed Rights is expressly made subject to thefollowing conditions.
a. Attribution.
1. If You Share the Licensed Material (including in modified form), You must:
a. retain the following if it is supplied by the Licensor with the Licensed Material:
i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of warranties;
v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
b. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
c. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License.
Section 4 -- Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights thatapply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only;
b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and
c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does notreplace Your obligations under this Public License where the LicensedRights include other Copyright and Similar Rights.
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
Section 6 -- Term and Termination.
a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
2. upon express reinstatement by the Licensor.
For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
Section 7 -- Other Terms and Conditions.
a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
Section 8 -- Interpretation.
a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
=======================================================================
Creative Commons is not a party to its publiclicenses. Notwithstanding, Creative Commons may elect to apply one ofits public licenses to material it publishes and in those instanceswill be considered the βLicensor.β The text of the Creative Commonspublic licenses is dedicated to the public domain under the CC0 PublicDomain Dedication. Except for the limited purpose of indicating thatmaterial is shared under a Creative Commons public license or asotherwise permitted by the Creative Commons policies published atcreativecommons.org/policies, Creative Commons does not authorize theuse of the trademark "Creative Commons" or any other trademark or logoof Creative Commons without its prior written consent including,without limitation, in connection with any unauthorized modificationsto any of its public licenses or any other arrangements,understandings, or agreements concerning use of licensed material. Forthe avoidance of doubt, this paragraph does not form part of thepublic licenses.
Creative Commons may be contacted at creativecommons.org.1{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"MultiSpecific.ipynb","provenance":[],"collapsed_sections":[],"authorship_tag":"ABX9TyNw8SfPWhG77cf/e7YZd178"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"},"accelerator":"GPU"},"cells":[{"cell_type":"markdown","metadata":{"id":"7_gtFoV8BuRx"},"source":["This is an example of SimSwap on processing video with multiple faces with designated sources.\n","\n","Code path: https://github.com/neuralchen/SimSwap\n","Paper path: https://arxiv.org/pdf/2106.06340v1.pdf."]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"0Y1RfpzsCAl9","executionInfo":{"status":"ok","timestamp":1625380781426,"user_tz":-480,"elapsed":586,"user":{"displayName":"JosΓ© Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"2a897b34-72f1-4515-ac6f-2f0e2d4ea4f7"},"source":["## make sure you are using a runtime with GPU\n","## you can check at Runtime/Change runtime type in the top bar.\n","!nvidia-smi"],"execution_count":1,"outputs":[{"output_type":"stream","text":["Sun Jul 4 06:39:39 2021 \n","+-----------------------------------------------------------------------------+\n","| NVIDIA-SMI 465.27 Driver Version: 460.32.03 CUDA Version: 11.2 |\n","|-------------------------------+----------------------+----------------------+\n","| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\n","| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\n","| | | MIG M. |\n","|===============================+======================+======================|\n","| 0 Tesla T4 Off | 00000000:00:04.0 Off | 0 |\n","| N/A 45C P8 9W / 70W | 0MiB / 15109MiB | 0% Default |\n","| | | N/A |\n","+-------------------------------+----------------------+----------------------+\n"," \n","+-----------------------------------------------------------------------------+\n","| Processes: |\n","| GPU GI CI PID Type Process name GPU Memory |\n","| ID ID Usage |\n","|=============================================================================|\n","| No running processes found |\n","+-----------------------------------------------------------------------------+\n"],"name":"stdout"}]},{"cell_type":"markdown","metadata":{"id":"0Qzzx2UpDkqw"},"source":["All file changes make by this notebook are temporary. \n","You can try to mount your own google drive to store files if you wang.\n"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"VA_4CeWZCHLP","executionInfo":{"status":"ok","timestamp":1625380786661,"user_tz":-480,"elapsed":4693,"user":{"displayName":"JosΓ© Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"d0665552-be92-45b0-aab2-f84c619a51fb"},"source":["!git clone https://github.com/neuralchen/SimSwap\n","!cd SimSwap && git pull"],"execution_count":2,"outputs":[{"output_type":"stream","text":["Cloning into 'SimSwap'...\n","remote: Enumerating objects: 667, done.\u001b[K\n","remote: Counting objects: 100% (48/48), done.\u001b[K\n","remote: Compressing objects: 100% (35/35), done.\u001b[K\n","remote: Total 667 (delta 19), reused 28 (delta 13), pack-reused 619\u001b[K\n","Receiving objects: 100% (667/667), 132.14 MiB | 44.44 MiB/s, done.\n","Resolving deltas: 100% (292/292), done.\n","Already up to date.\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"Y5K4au_UCkKn","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1625380797906,"user_tz":-480,"elapsed":11253,"user":{"displayName":"JosΓ© Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"7429f153-bc6d-48c2-eb3c-21f1f02fede9"},"source":["!pip install insightface==0.2.1 onnxruntime moviepy\n","!pip install googledrivedownloader\n","!pip install imageio==2.4.1"],"execution_count":3,"outputs":[{"output_type":"stream","text":["Collecting insightface==0.2.1\n"," Downloading https://files.pythonhosted.org/packages/ee/1e/6395bbe0db665f187c8e49266cda54fcf661f182192370d409423e4943e4/insightface-0.2.1-py2.py3-none-any.whl\n","Collecting onnxruntime\n","\u001b[?25l Downloading https://files.pythonhosted.org/packages/f9/76/3d0f8bb2776961c7335693df06eccf8d099e48fa6fb552c7546867192603/onnxruntime-1.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.5MB)\n","\u001b[K |ββββββββββββββββββββββββββββββββ| 4.5MB 37.5MB/s \n","\u001b[?25hRequirement already satisfied: moviepy in /usr/local/lib/python3.7/dist-packages (0.2.3.5)\n","Requirement already satisfied: scikit-learn in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (0.22.2.post1)\n","Requirement already satisfied: requests in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (2.23.0)\n","Collecting onnx\n","\u001b[?25l Downloading https://files.pythonhosted.org/packages/3f/9b/54c950d3256e27f970a83cd0504efb183a24312702deed0179453316dbd0/onnx-1.9.0-cp37-cp37m-manylinux2010_x86_64.whl (12.2MB)\n","\u001b[K |ββββββββββββββββββββββββββββββββ| 12.2MB 32.2MB/s \n","\u001b[?25hRequirement already satisfied: matplotlib in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (3.2.2)\n","Requirement already satisfied: Pillow in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (7.1.2)\n","Requirement already satisfied: scikit-image in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (0.16.2)\n","Requirement already satisfied: opencv-python in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (4.1.2.30)\n","Requirement already satisfied: tqdm in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (4.41.1)\n","Requirement already satisfied: scipy in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (1.4.1)\n","Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (1.19.5)\n","Requirement already satisfied: easydict in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (1.9)\n","Requirement already satisfied: flatbuffers in /usr/local/lib/python3.7/dist-packages (from onnxruntime) (1.12)\n","Requirement already satisfied: protobuf in /usr/local/lib/python3.7/dist-packages (from onnxruntime) (3.12.4)\n","Requirement already satisfied: imageio<3.0,>=2.1.2 in /usr/local/lib/python3.7/dist-packages (from moviepy) (2.4.1)\n","Requirement already satisfied: decorator<5.0,>=4.0.2 in /usr/local/lib/python3.7/dist-packages (from moviepy) (4.4.2)\n","Requirement already satisfied: joblib>=0.11 in /usr/local/lib/python3.7/dist-packages (from scikit-learn->insightface==0.2.1) (1.0.1)\n","Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests->insightface==0.2.1) (3.0.4)\n","Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests->insightface==0.2.1) (1.24.3)\n","Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests->insightface==0.2.1) (2021.5.30)\n","Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests->insightface==0.2.1) (2.10)\n","Requirement already satisfied: typing-extensions>=3.6.2.1 in /usr/local/lib/python3.7/dist-packages (from onnx->insightface==0.2.1) (3.7.4.3)\n","Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from onnx->insightface==0.2.1) (1.15.0)\n","Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->insightface==0.2.1) (2.8.1)\n","Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.7/dist-packages (from matplotlib->insightface==0.2.1) (0.10.0)\n","Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->insightface==0.2.1) (2.4.7)\n","Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->insightface==0.2.1) (1.3.1)\n","Requirement already satisfied: networkx>=2.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image->insightface==0.2.1) (2.5.1)\n","Requirement already satisfied: PyWavelets>=0.4.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image->insightface==0.2.1) (1.1.1)\n","Requirement already satisfied: setuptools in /usr/local/lib/python3.7/dist-packages (from protobuf->onnxruntime) (57.0.0)\n","Installing collected packages: onnx, insightface, onnxruntime\n","Successfully installed insightface-0.2.1 onnx-1.9.0 onnxruntime-1.8.0\n","Requirement already satisfied: googledrivedownloader in /usr/local/lib/python3.7/dist-packages (0.4)\n","Requirement already satisfied: imageio==2.4.1 in /usr/local/lib/python3.7/dist-packages (2.4.1)\n","Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from imageio==2.4.1) (1.19.5)\n","Requirement already satisfied: pillow in /usr/local/lib/python3.7/dist-packages (from imageio==2.4.1) (7.1.2)\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"gQ7ZoIbLFCye","executionInfo":{"status":"ok","timestamp":1625380798405,"user_tz":-480,"elapsed":533,"user":{"displayName":"JosΓ© Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"8448a0a3-a19e-44c2-a044-f4d3f9152e91"},"source":["import os\n","os.chdir(\"SimSwap\")\n","!ls"],"execution_count":4,"outputs":[{"output_type":"stream","text":[" crop_224\t simswaplogo\n"," data\t\t test_one_image.py\n"," demo_file\t test_video_swapmulti.py\n"," docs\t\t test_video_swap_multispecific.py\n"," insightface_func test_video_swapsingle.py\n"," LICENSE\t test_video_swapspecific.py\n"," models\t\t test_wholeimage_swapmulti.py\n"," options\t test_wholeimage_swap_multispecific.py\n"," output\t\t test_wholeimage_swapsingle.py\n"," README.md\t test_wholeimage_swapspecific.py\n","'SimSwap colab.ipynb' util\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"ZvGp-p0nOmKE","executionInfo":{"status":"ok","timestamp":1625380798407,"user_tz":-480,"elapsed":17,"user":{"displayName":"JosΓ© Lampreia","photoUrl":"","userId":"16015278604201270582"}}},"source":["## You can upload filed manually\n","# from google.colab import drive\n","# drive.mount('/content/gdrive')"],"execution_count":5,"outputs":[]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"gLti1J0pEFjJ","executionInfo":{"status":"ok","timestamp":1625380813268,"user_tz":-480,"elapsed":14876,"user":{"displayName":"JosΓ© Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"99dc9306-9b9a-475d-cc7d-a3f423bd1e81"},"source":["from google_drive_downloader import GoogleDriveDownloader\n","\n","### it seems that google drive link may not be permenant, you can find this ID from our open url.\n","# GoogleDriveDownloader.download_file_from_google_drive(file_id='1TLNdIufzwesDbyr_nVTR7Zrx9oRHLM_N',\n","# dest_path='./arcface_model/arcface_checkpoint.tar')\n","# GoogleDriveDownloader.download_file_from_google_drive(file_id='1PXkRiBUYbu1xWpQyDEJvGKeqqUFthJcI',\n","# dest_path='./checkpoints.zip')\n","\n","!wget -P ./arcface_model https://github.com/neuralchen/SimSwap/releases/download/1.0/arcface_checkpoint.tar\n","!wget https://github.com/neuralchen/SimSwap/releases/download/1.0/checkpoints.zip\n","!unzip ./checkpoints.zip -d ./checkpoints\n","!wget -P ./parsing_model/checkpoint https://github.com/neuralchen/SimSwap/releases/download/1.0/79999_iter.pth"],"execution_count":6,"outputs":[{"output_type":"stream","text":["--2021-07-04 06:39:56-- https://github.com/neuralchen/SimSwap/releases/download/1.0/arcface_checkpoint.tar\n","Resolving github.com (github.com)... 140.82.114.3\n","Connecting to github.com (github.com)|140.82.114.3|:443... connected.\n","HTTP request sent, awaiting response... 302 Found\n","Location: https://github-releases.githubusercontent.com/374891081/e17b9d00-dcb8-11eb-8c4f-1412bcea78a6?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210704%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210704T063956Z&X-Amz-Expires=300&X-Amz-Signature=b6d431c65405e894ddc994061c5fe8fe87db4e71e702513aec01f398a1004825&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=374891081&response-content-disposition=attachment%3B%20filename%3Darcface_checkpoint.tar&response-content-type=application%2Foctet-stream [following]\n","--2021-07-04 06:39:56-- https://github-releases.githubusercontent.com/374891081/e17b9d00-dcb8-11eb-8c4f-1412bcea78a6?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210704%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210704T063956Z&X-Amz-Expires=300&X-Amz-Signature=b6d431c65405e894ddc994061c5fe8fe87db4e71e702513aec01f398a1004825&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=374891081&response-content-disposition=attachment%3B%20filename%3Darcface_checkpoint.tar&response-content-type=application%2Foctet-stream\n","Resolving github-releases.githubusercontent.com (github-releases.githubusercontent.com)... 185.199.108.154, 185.199.109.154, 185.199.110.154, ...\n","Connecting to github-releases.githubusercontent.com (github-releases.githubusercontent.com)|185.199.108.154|:443... connected.\n","HTTP request sent, awaiting response... 200 OK\n","Length: 766871429 (731M) [application/octet-stream]\n","Saving to: β./arcface_model/arcface_checkpoint.tarβ\n","\n","arcface_checkpoint. 100%[===================>] 731.34M 64.4MB/s in 11s \n","\n","2021-07-04 06:40:07 (68.4 MB/s) - β./arcface_model/arcface_checkpoint.tarβ saved [766871429/766871429]\n","\n","--2021-07-04 06:40:07-- https://github.com/neuralchen/SimSwap/releases/download/1.0/checkpoints.zip\n","Resolving github.com (github.com)... 140.82.113.3\n","Connecting to github.com (github.com)|140.82.113.3|:443... connected.\n","HTTP request sent, awaiting response... 302 Found\n","Location: https://github-releases.githubusercontent.com/374891081/a8dac400-dcb6-11eb-933f-977cd7f5f554?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210704%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210704T063831Z&X-Amz-Expires=300&X-Amz-Signature=3fd2850d03abb9301bf5ba5969d82eb73cb0b940b85e45de2e1e34f1ba2eaf09&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=374891081&response-content-disposition=attachment%3B%20filename%3Dcheckpoints.zip&response-content-type=application%2Foctet-stream [following]\n","--2021-07-04 06:40:07-- https://github-releases.githubusercontent.com/374891081/a8dac400-dcb6-11eb-933f-977cd7f5f554?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210704%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210704T063831Z&X-Amz-Expires=300&X-Amz-Signature=3fd2850d03abb9301bf5ba5969d82eb73cb0b940b85e45de2e1e34f1ba2eaf09&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=374891081&response-content-disposition=attachment%3B%20filename%3Dcheckpoints.zip&response-content-type=application%2Foctet-stream\n","Resolving github-releases.githubusercontent.com (github-releases.githubusercontent.com)... 185.199.108.154, 185.199.109.154, 185.199.110.154, ...\n","Connecting to github-releases.githubusercontent.com (github-releases.githubusercontent.com)|185.199.108.154|:443... connected.\n","HTTP request sent, awaiting response... 200 OK\n","Length: 256461775 (245M) [application/octet-stream]\n","Saving to: βcheckpoints.zipβ\n","\n","checkpoints.zip 100%[===================>] 244.58M 219MB/s in 1.1s \n","\n","2021-07-04 06:40:08 (219 MB/s) - βcheckpoints.zipβ saved [256461775/256461775]\n","\n","Archive: ./checkpoints.zip\n"," creating: ./checkpoints/people/\n"," inflating: ./checkpoints/people/iter.txt \n"," inflating: ./checkpoints/people/latest_net_D1.pth \n"," inflating: ./checkpoints/people/latest_net_D2.pth \n"," inflating: ./checkpoints/people/latest_net_G.pth \n"," inflating: ./checkpoints/people/loss_log.txt \n"," inflating: ./checkpoints/people/opt.txt \n"," creating: ./checkpoints/people/web/\n"," creating: ./checkpoints/people/web/images/\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"fJ9DYRrCPIUL","executionInfo":{"status":"ok","timestamp":1625380821122,"user_tz":-480,"elapsed":7869,"user":{"displayName":"JosΓ© Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"a3d1d841-440c-4244-8045-cb0ce3cc81fd"},"source":["!wget --no-check-certificate \"https://sh23tw.dm.files.1drv.com/y4mmGiIkNVigkSwOKDcV3nwMJulRGhbtHdkheehR5TArc52UjudUYNXAEvKCii2O5LAmzGCGK6IfleocxuDeoKxDZkNzDRSt4ZUlEt8GlSOpCXAFEkBwaZimtWGDRbpIGpb_pz9Nq5jATBQpezBS6G_UtspWTkgrXHHxhviV2nWy8APPx134zOZrUIbkSF6xnsqzs3uZ_SEX_m9Rey0ykpx9w\" -O antelope.zip\n","!unzip ./antelope.zip -d ./insightface_func/models/"],"execution_count":7,"outputs":[{"output_type":"stream","text":["--2021-07-04 06:40:11-- https://sh23tw.dm.files.1drv.com/y4mmGiIkNVigkSwOKDcV3nwMJulRGhbtHdkheehR5TArc52UjudUYNXAEvKCii2O5LAmzGCGK6IfleocxuDeoKxDZkNzDRSt4ZUlEt8GlSOpCXAFEkBwaZimtWGDRbpIGpb_pz9Nq5jATBQpezBS6G_UtspWTkgrXHHxhviV2nWy8APPx134zOZrUIbkSF6xnsqzs3uZ_SEX_m9Rey0ykpx9w\n","Resolving sh23tw.dm.files.1drv.com (sh23tw.dm.files.1drv.com)... 13.107.42.12\n","Connecting to sh23tw.dm.files.1drv.com (sh23tw.dm.files.1drv.com)|13.107.42.12|:443... connected.\n","HTTP request sent, awaiting response... 200 OK\n","Length: 248024513 (237M) [application/zip]\n","Saving to: βantelope.zipβ\n","\n","antelope.zip 100%[===================>] 236.53M 52.4MB/s in 4.7s \n","\n","2021-07-04 06:40:16 (49.9 MB/s) - βantelope.zipβ saved [248024513/248024513]\n","\n","Archive: ./antelope.zip\n"," creating: ./insightface_func/models/antelope/\n"," inflating: ./insightface_func/models/antelope/glintr100.onnx \n"," inflating: ./insightface_func/models/antelope/scrfd_10g_bnkps.onnx \n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"PfSsND36EMvn","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1625380827902,"user_tz":-480,"elapsed":6811,"user":{"displayName":"JosΓ© Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"8130e97d-b4a0-4988-85fb-e2bc3e755259"},"source":["import cv2\n","import torch\n","import fractions\n","import numpy as np\n","from PIL import Image\n","import torch.nn.functional as F\n","from torchvision import transforms\n","from models.models import create_model\n","from options.test_options import TestOptions\n","from insightface_func.face_detect_crop_multi import Face_detect_crop\n","from util.videoswap_multispecific import video_swap\n","import os\n","import glob"],"execution_count":8,"outputs":[{"output_type":"stream","text":["Imageio: 'ffmpeg-linux64-v3.3.1' was not found on your computer; downloading it now.\n","Try 1. Download from https://github.com/imageio/imageio-binaries/raw/master/ffmpeg/ffmpeg-linux64-v3.3.1 (43.8 MB)\n","Downloading: 8192/45929032 bytes (0.0%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b3432448/45929032 bytes (7.5%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b7036928/45929032 bytes (15.3%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b10641408/45929032 bytes (23.2%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b14278656/45929032 bytes (31.1%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b18104320/45929032 bytes (39.4%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b21954560/45929032 bytes (47.8%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b25780224/45929032 bytes (56.1%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b29736960/45929032 bytes (64.7%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b33488896/45929032 bytes (72.9%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b37093376/45929032 bytes (80.8%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b40689664/45929032 bytes (88.6%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b44392448/45929032 bytes (96.7%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b45929032/45929032 bytes (100.0%)\n"," Done\n","File saved as /root/.imageio/ffmpeg/ffmpeg-linux64-v3.3.1.\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"rxSbZ2EDNDlf","executionInfo":{"status":"ok","timestamp":1625380827903,"user_tz":-480,"elapsed":12,"user":{"displayName":"JosΓ© Lampreia","photoUrl":"","userId":"16015278604201270582"}}},"source":["def lcm(a, b): return abs(a * b) / fractions.gcd(a, b) if a and b else 0\n","\n","transformer = transforms.Compose([\n"," transforms.ToTensor(),\n"," #transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])\n"," ])\n","\n","transformer_Arcface = transforms.Compose([\n"," transforms.ToTensor(),\n"," transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])\n"," ])\n"],"execution_count":9,"outputs":[]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"ye8iS0UVPMRg","executionInfo":{"status":"ok","timestamp":1625380828574,"user_tz":-480,"elapsed":680,"user":{"displayName":"JosΓ© Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"cb5a4b02-b1d0-4ff8-f542-5c1b3c9703d9"},"source":["!ls ./checkpoints"],"execution_count":10,"outputs":[{"output_type":"stream","text":["people\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"wwJOwR9LNKRz","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1625380828576,"user_tz":-480,"elapsed":13,"user":{"displayName":"JosΓ© Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"0f92f785-4d9c-4130-b24d-76871b2dafba"},"source":["opt = TestOptions()\n","opt.initialize()\n","opt.parser.add_argument('-f') ## dummy arg to avoid bug\n","opt = opt.parse()\n","opt.multisepcific_dir = './demo_file/multispecific' ## or replace it with folder from your own google drive\n"," ## and remember to follow the dir structure in usage.md\n","opt.video_path = './demo_file/multi_people_1080p.mp4' ## or replace it with video from your own google drive\n","opt.output_path = './output/multi_test_multispecific.mp4'\n","opt.temp_path = './tmp'\n","opt.Arc_path = './arcface_model/arcface_checkpoint.tar'\n","opt.name = 'people'\n","opt.isTrain = False\n","opt.use_mask = True ## new feature up-to-date\n","\n","crop_size = opt.crop_size\n"],"execution_count":11,"outputs":[{"output_type":"stream","text":["------------ Options -------------\n","Arc_path: models/BEST_checkpoint.tar\n","aspect_ratio: 1.0\n","batchSize: 8\n","checkpoints_dir: ./checkpoints\n","cluster_path: features_clustered_010.npy\n","data_type: 32\n","dataroot: ./datasets/cityscapes/\n","display_winsize: 512\n","engine: None\n","export_onnx: None\n","f: /root/.local/share/jupyter/runtime/kernel-19937219-895d-4d02-9a72-5cfa0e889adf.json\n","feat_num: 3\n","fineSize: 512\n","fp16: False\n","gpu_ids: [0]\n","how_many: 50\n","id_thres: 0.03\n","image_size: 224\n","input_nc: 3\n","instance_feat: False\n","isTrain: False\n","label_feat: False\n","label_nc: 0\n","latent_size: 512\n","loadSize: 1024\n","load_features: False\n","local_rank: 0\n","max_dataset_size: inf\n","model: pix2pixHD\n","multisepcific_dir: ./demo_file/multispecific\n","nThreads: 2\n","n_blocks_global: 6\n","n_blocks_local: 3\n","n_clusters: 10\n","n_downsample_E: 4\n","n_downsample_global: 3\n","n_local_enhancers: 1\n","name: people\n","nef: 16\n","netG: global\n","ngf: 64\n","niter_fix_global: 0\n","no_flip: False\n","no_instance: False\n","no_simswaplogo: False\n","norm: batch\n","norm_G: spectralspadesyncbatch3x3\n","ntest: inf\n","onnx: None\n","output_nc: 3\n","output_path: ./output/\n","phase: test\n","pic_a_path: ./crop_224/gdg.jpg\n","pic_b_path: ./crop_224/zrf.jpg\n","pic_specific_path: ./crop_224/zrf.jpg\n","resize_or_crop: scale_width\n","results_dir: ./results/\n","semantic_nc: 3\n","serial_batches: False\n","temp_path: ./temp_results\n","tf_log: False\n","use_dropout: False\n","use_encoded_image: False\n","verbose: False\n","video_path: ./demo_file/multi_people_1080p.mp4\n","which_epoch: latest\n","-------------- End ----------------\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"UFt8zQrAMq9F","executionInfo":{"status":"ok","timestamp":1625381428564,"user_tz":-480,"elapsed":599996,"user":{"displayName":"JosΓ© Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"46188013-3f6d-4174-9959-d1fd203dcc0d"},"source":["pic_specific = opt.pic_specific_path\n","crop_size = opt.crop_size\n","multisepcific_dir = opt.multisepcific_dir\n","\n","torch.nn.Module.dump_patches = True\n","model = create_model(opt)\n","model.eval()\n","\n","app = Face_detect_crop(name='antelope', root='./insightface_func/models')\n","app.prepare(ctx_id= 0, det_thresh=0.6, det_size=(640,640))\n","# The specific person to be swapped(source)\n","source_specific_id_nonorm_list = []\n","source_path = os.path.join(multisepcific_dir,'SRC_*')\n","source_specific_images_path = sorted(glob.glob(source_path))\n","\n","with torch.no_grad():\n"," for source_specific_image_path in source_specific_images_path:\n"," specific_person_whole = cv2.imread(source_specific_image_path)\n"," specific_person_align_crop, _ = app.get(specific_person_whole,crop_size)\n"," specific_person_align_crop_pil = Image.fromarray(cv2.cvtColor(specific_person_align_crop[0],cv2.COLOR_BGR2RGB)) \n"," specific_person = transformer_Arcface(specific_person_align_crop_pil)\n"," specific_person = specific_person.view(-1, specific_person.shape[0], specific_person.shape[1], specific_person.shape [2])\n"," # convert numpy to tensor\n"," specific_person = specific_person.cuda()\n"," #create latent id\n"," specific_person_downsample = F.interpolate(specific_person, size=(112,112))\n"," specific_person_id_nonorm = model.netArc(specific_person_downsample)\n"," source_specific_id_nonorm_list.append(specific_person_id_nonorm.clone())\n","\n"," # The person who provides id information (list)\n"," target_id_norm_list = []\n"," target_path = os.path.join(multisepcific_dir,'DST_*')\n"," target_images_path = sorted(glob.glob(target_path))\n","\n"," for target_image_path in target_images_path:\n"," img_a_whole = cv2.imread(target_image_path)\n"," img_a_align_crop, _ = app.get(img_a_whole,crop_size)\n"," img_a_align_crop_pil = Image.fromarray(cv2.cvtColor(img_a_align_crop[0],cv2.COLOR_BGR2RGB)) \n"," img_a = transformer_Arcface(img_a_align_crop_pil)\n"," img_id = img_a.view(-1, img_a.shape[0], img_a.shape[1], img_a.shape[2])\n"," # convert numpy to tensor\n"," img_id = img_id.cuda()\n"," #create latent id\n"," img_id_downsample = F.interpolate(img_id, size=(112,112))\n"," latend_id = model.netArc(img_id_downsample)\n"," latend_id = F.normalize(latend_id, p=2, dim=1)\n"," target_id_norm_list.append(latend_id.clone())\n"," \n"," assert len(target_id_norm_list) == len(source_specific_id_nonorm_list), \"The number of images in source and target directory must be same !!!\"\n"," video_swap(opt.video_path, target_id_norm_list,source_specific_id_nonorm_list, opt.id_thres, \\\n"," model, app, opt.output_path,temp_results_dir=opt.temp_path,no_simswaplogo=opt.no_simswaplogo,use_mask=opt.use_mask)"],"execution_count":12,"outputs":[{"output_type":"stream","text":["input mean and std: 127.5 127.5\n","find model: ./insightface_func/models/antelope/glintr100.onnx recognition\n","find model: ./insightface_func/models/antelope/scrfd_10g_bnkps.onnx detection\n","set det-size: (640, 640)\n"],"name":"stdout"},{"output_type":"stream","text":["\r 0%| | 0/594 [00:00<?, ?it/s]"],"name":"stderr"},{"output_type":"stream","text":["(142, 366, 4)\n"],"name":"stdout"},{"output_type":"stream","text":["100%|ββββββββββ| 594/594 [08:28<00:00, 1.17it/s]\n"],"name":"stderr"},{"output_type":"stream","text":["[MoviePy] >>>> Building video ./output/multi_test_multispecific.mp4\n","[MoviePy] Writing audio in multi_test_multispecificTEMP_MPY_wvf_snd.mp3\n"],"name":"stdout"},{"output_type":"stream","text":["100%|ββββββββββ| 438/438 [00:00<00:00, 832.16it/s]"],"name":"stderr"},{"output_type":"stream","text":["[MoviePy] Done.\n","[MoviePy] Writing video ./output/multi_test_multispecific.mp4\n"],"name":"stdout"},{"output_type":"stream","text":["\n","100%|ββββββββββ| 595/595 [00:53<00:00, 11.11it/s]\n"],"name":"stderr"},{"output_type":"stream","text":["[MoviePy] Done.\n","[MoviePy] >>>> Video ready: ./output/multi_test_multispecific.mp4 \n","\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"Rty2GsyZZrI6"},"source":[],"execution_count":null,"outputs":[]}]}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247# SimSwap: An Efficient Framework For High Fidelity Face Swapping## Proceedings of the 28th ACM International Conference on Multimedia**The official repository with Pytorch**
**Our method can realize **arbitrary face swapping** on images and videos with **one single trained model**.**
***We are recruiting full-time engineers. If you are interested, please send an [email](mailto:chen19910528@sjtu.edu.cn?subject=[GitHub]%20Source%20Han%20Sans) to my team. Please refer to the website for specific recruitment conditions: [Requirements](https://join.sjtu.edu.cn/Admin/QsPreview.aspx?qsid=44f5413a90974114b8f5e643177ef32d)***
Training and test code are now available
We are working with our incoming paper SimSwap++, keeping expecting!
The high resolution version of ***SimSwap-HQ*** is supported!
[](https://github.com/neuralchen/SimSwap)
Our paper can be downloaded from [[Arxiv]](https://arxiv.org/pdf/2106.06340v1.pdf) [[ACM DOI]](https://dl.acm.org/doi/10.1145/3394171.3413630)
### This project also received support from [SocialBook](https://socialbook.io).<!-- [](https://socialbook.io) --><img width=30% src="./simswaplogo/socialbook_logo.2020.357eed90add7705e54a8.svg"/>
<!-- [[Google Drive]](https://drive.google.com/file/d/1fcfWOGt1mkBo7F0gXVKitf8GJMAXQxZD/view?usp=sharing) [[Baidu Drive ]](https://pan.baidu.com/s/1-TKFuycRNUKut8hn4IimvA) Password: ```ummt``` -->
## Attention***This project is for technical and academic use only. Please do not apply it to illegal and unethical scenarios.***
***In the event of violation of the legal and ethical requirements of the user's country or region, this code repository is exempt from liability***
***Please do not ignore the content at the end of this README!***
If you find this project useful, please star it. It is the greatest appreciation of our work.
## Top News <img width=8% src="./docs/img/new.gif"/>
**`2023-09-26`**: We fixed bugs in colab!
**`2023-04-25`**: We fixed the "AttributeError: 'SGD' object has no attribute 'defaults' now" bug. If you have already downloaded **arcface_checkpoint.tar**, please **download it again**. Also, you also need to update the scripts in ```./models/```.
**`2022-04-21`**: For resource limited users, we provide the cropped VGGFace2-224 dataset [[Google Driver] VGGFace2-224 (10.8G)](https://drive.google.com/file/d/19pWvdEHS-CEG6tW3PdxdtZ5QEymVjImc/view?usp=sharing) [[Baidu Driver]](https://pan.baidu.com/s/1OiwLJHVBSYB4AY2vEcfN0A) [Password: lrod].
**`2022-04-20`**: Training scripts are now available. We highly recommend that you guys train the simswap model with our released high quality dataset [VGGFace2-HQ](https://github.com/NNNNAI/VGGFace2-HQ).
**`2021-11-24`**: We have trained a beta version of ***SimSwap-HQ*** on [VGGFace2-HQ](https://github.com/NNNNAI/VGGFace2-HQ) and open sourced the checkpoint of this model (if you think the Simswap 512 is cool, please star our [VGGFace2-HQ](https://github.com/NNNNAI/VGGFace2-HQ) repo). Please donβt forget to go to [Preparation](./docs/guidance/preparation.md) and [Inference for image or video face swapping](./docs/guidance/usage.md) to check the latest set up.
**`2021-11-23`**: The google drive link of [VGGFace2-HQ](https://github.com/NNNNAI/VGGFace2-HQ) is released.
**`2021-11-17`**: We released a high resolution face dataset [VGGFace2-HQ](https://github.com/NNNNAI/VGGFace2-HQ) and the method to generate this dataset. This dataset is for research purpose.
**`2021-08-30`**: Docker has been supported, please refer [here](https://replicate.ai/neuralchen/simswap-image) for details.
**`2021-08-17`**: We have updated the [Preparation](./docs/guidance/preparation.md), The main change is that the gpu version of onnx is now installed by default, Now the time to process a video is greatly reduced.
**`2021-07-19`**: ***Obvious border abruptness has been resolved***. We add the ability to using mask and upgrade the old algorithm for better visual effect, please go to [Inference for image or video face swapping](./docs/guidance/usage.md) for details. Please donβt forget to go to [Preparation](./docs/guidance/preparation.md) to check the latest set up. (Thanks for the help from [@woctezuma](https://github.com/woctezuma) and [@instant-high](https://github.com/instant-high))
## The first open source high resolution dataset for face swapping!!!## High Resolution Dataset [VGGFace2-HQ](https://github.com/NNNNAI/VGGFace2-HQ)
[](https://github.com/NNNNAI/VGGFace2-HQ)
## Dependencies- python3.6+- pytorch1.5+- torchvision- opencv- pillow- numpy- imageio- moviepy- insightface- ***timm==0.5.4***
## Training
[Preparation](./docs/guidance/preparation.md)
The training script is slightly different from the original version, e.g., we replace the patch discriminator with the projected discriminator, which saves a lot of hardware overhead and achieves slightly better results.
In order to ensure the normal training, the batch size must be greater than 1.
Friendly reminder, due to the difference in training settings, the user-trained model will have subtle differences in visual effects from the pre-trained model we provide.
- Train 224 models with VGGFace2 224*224 [[Google Driver] VGGFace2-224 (10.8G)](https://drive.google.com/file/d/19pWvdEHS-CEG6tW3PdxdtZ5QEymVjImc/view?usp=sharing) [[Baidu Driver] ](https://pan.baidu.com/s/1OiwLJHVBSYB4AY2vEcfN0A) [Password: lrod]
For faster convergence and better results, a large batch size (more than 16) is recommended!
***We recommend training more than 400K iterations (batch size is 16), 600K~800K will be better, more iterations will not be recommended.***
```python train.py --name simswap224_test --batchSize 8 --gpu_ids 0 --dataset /path/to/VGGFace2HQ --Gdeep False```
[Colab demo for training 224 model][ <a href="https://colab.research.google.com/github/neuralchen/SimSwap/blob/main/train.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="google colab logo"></a>](https://colab.research.google.com/github/neuralchen/SimSwap/blob/main/train.ipynb)
For faster convergence and better results, a large batch size (more than 16) is recommended!
- Train 512 models with VGGFace2-HQ 512*512 [VGGFace2-HQ](https://github.com/NNNNAI/VGGFace2-HQ).```python train.py --name simswap512_test --batchSize 16 --gpu_ids 0 --dataset /path/to/VGGFace2HQ --Gdeep True```
## Inference with a pretrained SimSwap model[Preparation](./docs/guidance/preparation.md)
[Inference for image or video face swapping](./docs/guidance/usage.md)
[Colab demo](https://colab.research.google.com/github/neuralchen/SimSwap/blob/main/SimSwap%20colab.ipynb)
<div style="background: yellow; width:140px; font-weight:bold;font-family: sans-serif;">Stronger feature</div>
[Colab for switching specific faces in multi-face videos][ <a href="https://colab.research.google.com/github/neuralchen/SimSwap/blob/main/MultiSpecific.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="google colab logo"></a>](https://colab.research.google.com/github/neuralchen/SimSwap/blob/main/MultiSpecific.ipynb)
[Image face swapping demo & Docker image on Replicate](https://replicate.ai/neuralchen/simswap-image)
## Video<img src="./docs/img/video.webp"/><div><img width=24% src="./docs/img/anni.webp"/><img width=24% src="./docs/img/chenglong.webp"/><img width=24% src="./docs/img/zhoujielun.webp"/><img width=24% src="./docs/img/zhuyin.webp"/></div><div><img width=49% src="./docs/img/mama_mask_short.webp"/><img width=49% src="./docs/img/mama_mask_wuyifan_short.webp"/></div>
## Results

<!--  -->
**High-quality videos can be found in the link below:**
[[Mama(video) 1080p]](https://drive.google.com/file/d/1mnSlwzz7f4H2O7UwApAHo64mgK4xSNyK/view?usp=sharing)
[[Google Drive link for video 1]](https://drive.google.com/file/d/1hdne7Gw39d34zt3w1NYV3Ln5cT8PfCNm/view?usp=sharing)
[[Google Drive link for video 2]](https://drive.google.com/file/d/1bDEg_pVeFYLnf9QLSMuG8bsjbRPk0X5_/view?usp=sharing)
[[Google Drive link for video 3]](https://drive.google.com/file/d/1oftHAnLmgFis4XURcHTccGSWbWSXYKK1/view?usp=sharing)
[[Baidu Drive link for video]](https://pan.baidu.com/s/1WTS6jm2TY17bYJurw57LUg ) Password: ```b26n```
[[Online Video]](https://www.bilibili.com/video/BV12v411p7j5/)
## User caseIf you have some interesting results after using our project and are willing to share, you can contact us by email or share directly on the issue. Later, we may make a separate section to show these results, which should be cool.
At the same time, if you have suggestions for our project, please feel free to ask questions in the issue, or contact us directly via email: [email1](mailto:chenxuanhongzju@outlook.com), [email2](mailto:nicklau26@foxmail.com), [email3](mailto:ziangliu824@gmail.com). (All three can be contacted, just choose any one)
## LicenseFor academic and non-commercial use only.The whole project is under the CC-BY-NC 4.0 license. See [LICENSE](https://github.com/neuralchen/SimSwap/blob/main/LICENSE) for additional details.
## To cite our papers```@inproceedings{DBLP:conf/mm/ChenCNG20, author = {Renwang Chen and Xuanhong Chen and Bingbing Ni and Yanhao Ge}, title = {SimSwap: An Efficient Framework For High Fidelity Face Swapping}, booktitle = {{MM} '20: The 28th {ACM} International Conference on Multimedia}, year = {2020}}``````@Article{simswapplusplus, author = {Xuanhong Chen and Bingbing Ni and Yutian Liu and Naiyuan Liu and Zhilin Zeng and Hang Wang}, title = {SimSwap++: Towards Faster and High-Quality Identity Swapping}, journal = {{IEEE} Trans. Pattern Anal. Mach. Intell.}, volume = {46}, number = {1}, pages = {576--592}, year = {2024}}```
## Related Projects
**Please visit our another ACMMM2020 high-quality style transfer project**
[](https://github.com/neuralchen/ASMAGAN)
[](https://github.com/neuralchen/ASMAGAN)
**Please visit our AAAI2021 sketch based rendering project**
[](https://github.com/TZYSJTU/Sketch-Generation-with-Drawing-Process-Guided-by-Vector-Flow-and-Grayscale)[](https://github.com/TZYSJTU/Sketch-Generation-with-Drawing-Process-Guided-by-Vector-Flow-and-Grayscale)
**Please visit our high resolution face dataset VGGFace2-HQ**
[](https://github.com/NNNNAI/VGGFace2-HQ)
Learn about our other projects
[[VGGFace2-HQ]](https://github.com/NNNNAI/VGGFace2-HQ);
[[RainNet]](https://neuralchen.github.io/RainNet);
[[Sketch Generation]](https://github.com/TZYSJTU/Sketch-Generation-with-Drawing-Process-Guided-by-Vector-Flow-and-Grayscale);
[[CooGAN]](https://github.com/neuralchen/CooGAN);
[[Knowledge Style Transfer]](https://github.com/AceSix/Knowledge_Transfer);
[[SimSwap]](https://github.com/neuralchen/SimSwap);
[[ASMA-GAN]](https://github.com/neuralchen/ASMAGAN);
[[SNGAN-Projection-pytorch]](https://github.com/neuralchen/SNGAN_Projection)
[[Pretrained_VGG19]](https://github.com/neuralchen/Pretrained_VGG19).
## Acknowledgements
<!--ts-->* [Deepfacelab](https://github.com/iperov/DeepFaceLab)* [Insightface](https://github.com/deepinsight/insightface)* [Face-parsing.PyTorch](https://github.com/zllrunning/face-parsing.PyTorch)* [BiSeNet](https://github.com/CoinCheung/BiSeNet)<!--te-->123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "SimSwap colab.ipynb", "provenance": [], "collapsed_sections": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" }, "accelerator": "GPU" }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "7_gtFoV8BuRx" }, "source": [ "This is a simple example of SimSwap on processing video with multiple faces. You can change the codes for inference based on our other scripts for image or single face swapping.\n", "\n", "Code path: https://github.com/neuralchen/SimSwap\n", "\n", "Paper path: https://arxiv.org/pdf/2106.06340v1.pdf or https://dl.acm.org/doi/10.1145/3394171.3413630" ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "0Y1RfpzsCAl9", "outputId": "a39470a0-9689-409d-a0a4-e2afd5d3b5dd" }, "source": [ "## make sure you are using a runtime with GPU\n", "## you can check at Runtime/Change runtime type in the top bar.\n", "!nvidia-smi" ], "execution_count": 1, "outputs": [ { "output_type": "stream", "text": [ "Mon Jun 21 02:13:20 2021 \n", "+-----------------------------------------------------------------------------+\n", "| NVIDIA-SMI 465.27 Driver Version: 460.32.03 CUDA Version: 11.2 |\n", "|-------------------------------+----------------------+----------------------+\n", "| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\n", "| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\n", "| | | MIG M. |\n", "|===============================+======================+======================|\n", "| 0 Tesla T4 Off | 00000000:00:04.0 Off | 0 |\n", "| N/A 45C P8 10W / 70W | 0MiB / 15109MiB | 0% Default |\n", "| | | N/A |\n", "+-------------------------------+----------------------+----------------------+\n", " \n", "+-----------------------------------------------------------------------------+\n", "| Processes: |\n", "| GPU GI CI PID Type Process name GPU Memory |\n", "| ID ID Usage |\n", "|=============================================================================|\n", "| No running processes found |\n", "+-----------------------------------------------------------------------------+\n" ], "name": "stdout" } ] }, { "cell_type": "markdown", "metadata": { "id": "0Qzzx2UpDkqw" }, "source": [ "## Installation\n", "\n", "All file changes made by this notebook are temporary. \n", "You can try to mount your own google drive to store files if you want.\n" ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "VA_4CeWZCHLP", "outputId": "4b0f176f-87e7-4772-8b47-c2098d8f3bf6" }, "source": [ "!git clone https://github.com/neuralchen/SimSwap\n", "!cd SimSwap && git pull" ], "execution_count": 2, "outputs": [ { "output_type": "stream", "text": [ "Cloning into 'SimSwap'...\n", "remote: Enumerating objects: 362, done.\u001b[K\n", "remote: Counting objects: 100% (362/362), done.\u001b[K\n", "remote: Compressing objects: 100% (281/281), done.\u001b[K\n", "remote: Total 362 (delta 149), reused 272 (delta 67), pack-reused 0\u001b[K\n", "Receiving objects: 100% (362/362), 101.31 MiB | 32.47 MiB/s, done.\n", "Resolving deltas: 100% (149/149), done.\n", "Already up to date.\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "Y5K4au_UCkKn", "colab": { "base_uri": "https://localhost:8080/" }, "outputId": "9691a7a4-192e-4ec2-c3c1-1f2c933d7b6a" }, "source": [ "!pip install insightface==0.2.1 onnxruntime moviepy\n", "!pip install googledrivedownloader\n", "!pip install imageio==2.4.1" ], "execution_count": 3, "outputs": [ { "output_type": "stream", "text": [ "Collecting insightface==0.2.1\n", " Downloading https://files.pythonhosted.org/packages/ee/1e/6395bbe0db665f187c8e49266cda54fcf661f182192370d409423e4943e4/insightface-0.2.1-py2.py3-none-any.whl\n", "Collecting onnxruntime\n", "\u001b[?25l Downloading https://files.pythonhosted.org/packages/f9/76/3d0f8bb2776961c7335693df06eccf8d099e48fa6fb552c7546867192603/onnxruntime-1.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.5MB)\n", "\u001b[K |ββββββββββββββββββββββββββββββββ| 4.5MB 10.2MB/s \n", "\u001b[?25hRequirement already satisfied: moviepy in /usr/local/lib/python3.7/dist-packages (0.2.3.5)\n", "Collecting onnx\n", "\u001b[?25l Downloading https://files.pythonhosted.org/packages/3f/9b/54c950d3256e27f970a83cd0504efb183a24312702deed0179453316dbd0/onnx-1.9.0-cp37-cp37m-manylinux2010_x86_64.whl (12.2MB)\n", "\u001b[K |ββββββββββββββββββββββββββββββββ| 12.2MB 51.4MB/s \n", "\u001b[?25hRequirement already satisfied: matplotlib in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (3.2.2)\n", "Requirement already satisfied: tqdm in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (4.41.1)\n", "Requirement already satisfied: Pillow in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (7.1.2)\n", "Requirement already satisfied: scikit-image in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (0.16.2)\n", "Requirement already satisfied: requests in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (2.23.0)\n", "Requirement already satisfied: scikit-learn in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (0.22.2.post1)\n", "Requirement already satisfied: opencv-python in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (4.1.2.30)\n", "Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (1.19.5)\n", "Requirement already satisfied: easydict in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (1.9)\n", "Requirement already satisfied: scipy in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (1.4.1)\n", "Requirement already satisfied: flatbuffers in /usr/local/lib/python3.7/dist-packages (from onnxruntime) (1.12)\n", "Requirement already satisfied: protobuf in /usr/local/lib/python3.7/dist-packages (from onnxruntime) (3.12.4)\n", "Requirement already satisfied: decorator<5.0,>=4.0.2 in /usr/local/lib/python3.7/dist-packages (from moviepy) (4.4.2)\n", "Requirement already satisfied: imageio<3.0,>=2.1.2 in /usr/local/lib/python3.7/dist-packages (from moviepy) (2.4.1)\n", "Requirement already satisfied: typing-extensions>=3.6.2.1 in /usr/local/lib/python3.7/dist-packages (from onnx->insightface==0.2.1) (3.7.4.3)\n", "Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from onnx->insightface==0.2.1) (1.15.0)\n", "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->insightface==0.2.1) (1.3.1)\n", "Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->insightface==0.2.1) (2.8.1)\n", "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.7/dist-packages (from matplotlib->insightface==0.2.1) (0.10.0)\n", "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->insightface==0.2.1) (2.4.7)\n", "Requirement already satisfied: networkx>=2.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image->insightface==0.2.1) (2.5.1)\n", "Requirement already satisfied: PyWavelets>=0.4.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image->insightface==0.2.1) (1.1.1)\n", "Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests->insightface==0.2.1) (2.10)\n", "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests->insightface==0.2.1) (2021.5.30)\n", "Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests->insightface==0.2.1) (3.0.4)\n", "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests->insightface==0.2.1) (1.24.3)\n", "Requirement already satisfied: joblib>=0.11 in /usr/local/lib/python3.7/dist-packages (from scikit-learn->insightface==0.2.1) (1.0.1)\n", "Requirement already satisfied: setuptools in /usr/local/lib/python3.7/dist-packages (from protobuf->onnxruntime) (57.0.0)\n", "Installing collected packages: onnx, insightface, onnxruntime\n", "Successfully installed insightface-0.2.1 onnx-1.9.0 onnxruntime-1.8.0\n", "Requirement already satisfied: googledrivedownloader in /usr/local/lib/python3.7/dist-packages (0.4)\n", "Requirement already satisfied: imageio==2.4.1 in /usr/local/lib/python3.7/dist-packages (2.4.1)\n", "Requirement already satisfied: pillow in /usr/local/lib/python3.7/dist-packages (from imageio==2.4.1) (7.1.2)\n", "Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from imageio==2.4.1) (1.19.5)\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "gQ7ZoIbLFCye", "outputId": "bb35e7e2-14b7-4f36-d62a-499ba041cf64" }, "source": [ "import os\n", "os.chdir(\"SimSwap\")\n", "!ls" ], "execution_count": 4, "outputs": [ { "output_type": "stream", "text": [ " crop_224\t models\t\t test_one_image.py\n", " data\t\t options\t\t test_video_swapmulti.py\n", " demo_file\t output\t\t test_video_swapsingle.py\n", " doc\t\t README.md\t\t test_wholeimage_swapmulti.py\n", " insightface_func 'SimSwap colab.ipynb' test_wholeimage_swapsingle.py\n", " LICENSE\t simswaplogo\t\t util\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "gLti1J0pEFjJ", "outputId": "e93c3f98-01df-458e-b791-c32f7343e705" }, "source": [ "from google_drive_downloader import GoogleDriveDownloader\n", "\n", "### it seems that google drive link may not be permenant, you can find this ID from our open url.\n", "# GoogleDriveDownloader.download_file_from_google_drive(file_id='1TLNdIufzwesDbyr_nVTR7Zrx9oRHLM_N',\n", "# dest_path='./arcface_model/arcface_checkpoint.tar')\n", "# GoogleDriveDownloader.download_file_from_google_drive(file_id='1PXkRiBUYbu1xWpQyDEJvGKeqqUFthJcI',\n", "# dest_path='./checkpoints.zip')\n", "\n", "!wget -P ./arcface_model https://github.com/neuralchen/SimSwap/releases/download/1.0/arcface_checkpoint.tar\n", "!wget https://github.com/neuralchen/SimSwap/releases/download/1.0/checkpoints.zip\n", "!unzip ./checkpoints.zip -d ./checkpoints\n", "!wget -P ./parsing_model/checkpoint https://github.com/neuralchen/SimSwap/releases/download/1.0/79999_iter.pth" ], "execution_count": 5, "outputs": [ { "output_type": "stream", "text": [ "Downloading 1TLNdIufzwesDbyr_nVTR7Zrx9oRHLM_N into ./arcface_model/arcface_checkpoint.tar... Done.\n", "Downloading 1PXkRiBUYbu1xWpQyDEJvGKeqqUFthJcI into ./checkpoints.zip... Done.\n", "Archive: ./checkpoints.zip\n", " creating: ./checkpoints/people/\n", " inflating: ./checkpoints/people/iter.txt \n", " inflating: ./checkpoints/people/latest_net_D1.pth \n", " inflating: ./checkpoints/people/latest_net_D2.pth \n", " inflating: ./checkpoints/people/latest_net_G.pth \n", " inflating: ./checkpoints/people/loss_log.txt \n", " inflating: ./checkpoints/people/opt.txt \n", " creating: ./checkpoints/people/web/\n", " creating: ./checkpoints/people/web/images/\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "aSRnK5V4HI-k", "outputId": "e688746c-c33a-485c-808c-54a7370f0c53" }, "source": [ "## You can upload filed manually\n", "# from google.colab import drive\n", "# drive.mount('/content/gdrive')\n", "\n", "### Now onedrive file can be downloaded in Colab directly!\n", "### If the link blow is not permanent, you can just download it from the \n", "### open url(can be found at [our repo]/doc/guidance/preparation.md) and copy the assigned download link here.\n", "### many thanks to woctezuma for this very useful help\n", "!wget --no-check-certificate \"https://sh23tw.dm.files.1drv.com/y4mmGiIkNVigkSwOKDcV3nwMJulRGhbtHdkheehR5TArc52UjudUYNXAEvKCii2O5LAmzGCGK6IfleocxuDeoKxDZkNzDRSt4ZUlEt8GlSOpCXAFEkBwaZimtWGDRbpIGpb_pz9Nq5jATBQpezBS6G_UtspWTkgrXHHxhviV2nWy8APPx134zOZrUIbkSF6xnsqzs3uZ_SEX_m9Rey0ykpx9w\" -O antelope.zip\n", "!unzip ./antelope.zip -d ./insightface_func/models/\n" ], "execution_count": 6, "outputs": [ { "output_type": "stream", "text": [ "--2021-06-21 02:14:17-- https://sh23tw.dm.files.1drv.com/y4mmGiIkNVigkSwOKDcV3nwMJulRGhbtHdkheehR5TArc52UjudUYNXAEvKCii2O5LAmzGCGK6IfleocxuDeoKxDZkNzDRSt4ZUlEt8GlSOpCXAFEkBwaZimtWGDRbpIGpb_pz9Nq5jATBQpezBS6G_UtspWTkgrXHHxhviV2nWy8APPx134zOZrUIbkSF6xnsqzs3uZ_SEX_m9Rey0ykpx9w\n", "Resolving sh23tw.dm.files.1drv.com (sh23tw.dm.files.1drv.com)... 13.107.42.12\n", "Connecting to sh23tw.dm.files.1drv.com (sh23tw.dm.files.1drv.com)|13.107.42.12|:443... connected.\n", "HTTP request sent, awaiting response... 200 OK\n", "Length: 248024513 (237M) [application/zip]\n", "Saving to: βantelope.zipβ\n", "\n", "antelope.zip 100%[===================>] 236.53M 6.16MB/s in 31s \n", "\n", "2021-06-21 02:14:48 (7.66 MB/s) - βantelope.zipβ saved [248024513/248024513]\n", "\n", "Archive: ./antelope.zip\n", " creating: ./insightface_func/models/antelope/\n", " inflating: ./insightface_func/models/antelope/glintr100.onnx \n", " inflating: ./insightface_func/models/antelope/scrfd_10g_bnkps.onnx \n" ], "name": "stdout" } ] }, { "cell_type": "markdown", "metadata": { "id": "BsGmIMxLVxyO" }, "source": [ "## Inference" ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "PfSsND36EMvn", "outputId": "f28c98fd-4c6d-40fa-e3c7-99b606c7492a" }, "source": [ "import cv2\n", "import torch\n", "import fractions\n", "import numpy as np\n", "from PIL import Image\n", "import torch.nn.functional as F\n", "from torchvision import transforms\n", "from models.models import create_model\n", "from options.test_options import TestOptions\n", "from insightface_func.face_detect_crop_multi import Face_detect_crop\n", "from util.videoswap import video_swap\n", "from util.add_watermark import watermark_image" ], "execution_count": 7, "outputs": [ { "output_type": "stream", "text": [ "Imageio: 'ffmpeg-linux64-v3.3.1' was not found on your computer; downloading it now.\n", "Try 1. Download from https://github.com/imageio/imageio-binaries/raw/master/ffmpeg/ffmpeg-linux64-v3.3.1 (43.8 MB)\n", "Downloading: 8192/45929032 bytes (0.0%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b1286144/45929032 bytes (2.8%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b3653632/45929032 bytes (8.0%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b7479296/45929032 bytes (16.3%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b11526144/45929032 bytes (25.1%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b15171584/45929032 bytes (33.0%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b18997248/45929032 bytes (41.4%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b22724608/45929032 bytes (49.5%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b26673152/45929032 bytes (58.1%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b30728192/45929032 bytes (66.9%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b34725888/45929032 bytes (75.6%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b38879232/45929032 bytes (84.7%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b42680320/45929032 bytes (92.9%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b45929032/45929032 bytes (100.0%)\n", " Done\n", "File saved as /root/.imageio/ffmpeg/ffmpeg-linux64-v3.3.1.\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "rxSbZ2EDNDlf" }, "source": [ "transformer = transforms.Compose([\n", " transforms.ToTensor(),\n", " #transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])\n", " ])\n", "\n", "transformer_Arcface = transforms.Compose([\n", " transforms.ToTensor(),\n", " transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])\n", " ])\n", "\n", "detransformer = transforms.Compose([\n", " transforms.Normalize([0, 0, 0], [1/0.229, 1/0.224, 1/0.225]),\n", " transforms.Normalize([-0.485, -0.456, -0.406], [1, 1, 1])\n", " ])" ], "execution_count": 8, "outputs": [] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "wwJOwR9LNKRz", "outputId": "bdc82f7b-21c4-403f-94d1-b92911698b4a" }, "source": [ "opt = TestOptions()\n", "opt.initialize()\n", "opt.parser.add_argument('-f') ## dummy arg to avoid bug\n", "opt = opt.parse()\n", "opt.pic_a_path = './demo_file/Iron_man.jpg' ## or replace it with image from your own google drive\n", "opt.video_path = './demo_file/multi_people_1080p.mp4' ## or replace it with video from your own google drive\n", "opt.output_path = './output/demo.mp4'\n", "opt.temp_path = './tmp'\n", "opt.Arc_path = './arcface_model/arcface_checkpoint.tar'\n", "opt.isTrain = False\n", "opt.use_mask = True ## new feature up-to-date\n", "\n", "crop_size = opt.crop_size\n", "\n", "torch.nn.Module.dump_patches = True\n", "model = create_model(opt)\n", "model.eval()\n", "\n", "app = Face_detect_crop(name='antelope', root='./insightface_func/models')\n", "app.prepare(ctx_id= 0, det_thresh=0.6, det_size=(640,640))\n", "\n", "with torch.no_grad():\n", " pic_a = opt.pic_a_path\n", " # img_a = Image.open(pic_a).convert('RGB')\n", " img_a_whole = cv2.imread(pic_a)\n", " img_a_align_crop, _ = app.get(img_a_whole,crop_size)\n", " img_a_align_crop_pil = Image.fromarray(cv2.cvtColor(img_a_align_crop[0],cv2.COLOR_BGR2RGB)) \n", " img_a = transformer_Arcface(img_a_align_crop_pil)\n", " img_id = img_a.view(-1, img_a.shape[0], img_a.shape[1], img_a.shape[2])\n", "\n", " # convert numpy to tensor\n", " img_id = img_id.cuda()\n", "\n", " #create latent id\n", " img_id_downsample = F.interpolate(img_id, size=(112,112))\n", " latend_id = model.netArc(img_id_downsample)\n", " latend_id = latend_id.detach().to('cpu')\n", " latend_id = latend_id/np.linalg.norm(latend_id,axis=1,keepdims=True)\n", " latend_id = latend_id.to('cuda')\n", "\n", " video_swap(opt.video_path, latend_id, model, app, opt.output_path, temp_results_dir=opt.temp_path, use_mask=opt.use_mask)" ], "execution_count": 9, "outputs": [ { "output_type": "stream", "text": [ "------------ Options -------------\n", "Arc_path: models/BEST_checkpoint.tar\n", "aspect_ratio: 1.0\n", "batchSize: 8\n", "checkpoints_dir: ./checkpoints\n", "cluster_path: features_clustered_010.npy\n", "data_type: 32\n", "dataroot: ./datasets/cityscapes/\n", "display_winsize: 512\n", "engine: None\n", "export_onnx: None\n", "f: /root/.local/share/jupyter/runtime/kernel-6d955151-4911-464a-824d-f0806d8071f6.json\n", "feat_num: 3\n", "fineSize: 512\n", "fp16: False\n", "gpu_ids: [0]\n", "how_many: 50\n", "image_size: 224\n", "input_nc: 3\n", "instance_feat: False\n", "isTrain: False\n", "label_feat: False\n", "label_nc: 0\n", "latent_size: 512\n", "loadSize: 1024\n", "load_features: False\n", "local_rank: 0\n", "max_dataset_size: inf\n", "model: pix2pixHD\n", "nThreads: 2\n", "n_blocks_global: 6\n", "n_blocks_local: 3\n", "n_clusters: 10\n", "n_downsample_E: 4\n", "n_downsample_global: 3\n", "n_local_enhancers: 1\n", "name: people\n", "nef: 16\n", "netG: global\n", "ngf: 64\n", "niter_fix_global: 0\n", "no_flip: False\n", "no_instance: False\n", "norm: batch\n", "norm_G: spectralspadesyncbatch3x3\n", "ntest: inf\n", "onnx: None\n", "output_nc: 3\n", "output_path: ./output/\n", "phase: test\n", "pic_a_path: ./crop_224/gdg.jpg\n", "pic_b_path: ./crop_224/zrf.jpg\n", "resize_or_crop: scale_width\n", "results_dir: ./results/\n", "semantic_nc: 3\n", "serial_batches: False\n", "temp_path: ./temp_results\n", "tf_log: False\n", "use_dropout: False\n", "use_encoded_image: False\n", "verbose: False\n", "video_path: ./demo_file/multi_people_1080p.mp4\n", "which_epoch: latest\n", "-------------- End ----------------\n", "input mean and std: 127.5 127.5\n", "find model: ./insightface_func/models/antelope/glintr100.onnx recognition\n", "find model: ./insightface_func/models/antelope/scrfd_10g_bnkps.onnx detection\n", "set det-size: (640, 640)\n" ], "name": "stdout" }, { "output_type": "stream", "text": [ "\r 0%| | 0/594 [00:00<?, ?it/s]" ], "name": "stderr" }, { "output_type": "stream", "text": [ "(142, 366, 4)\n" ], "name": "stdout" }, { "output_type": "stream", "text": [ "100%|ββββββββββ| 594/594 [08:45<00:00, 1.13it/s]\n" ], "name": "stderr" }, { "output_type": "stream", "text": [ "[MoviePy] >>>> Building video ./output/demo.mp4\n", "[MoviePy] Writing audio in demoTEMP_MPY_wvf_snd.mp3\n" ], "name": "stdout" }, { "output_type": "stream", "text": [ "100%|ββββββββββ| 438/438 [00:00<00:00, 877.18it/s]\n" ], "name": "stderr" }, { "output_type": "stream", "text": [ "[MoviePy] Done.\n", "[MoviePy] Writing video ./output/demo.mp4\n" ], "name": "stdout" }, { "output_type": "stream", "text": [ "100%|ββββββββββ| 595/595 [00:53<00:00, 11.15it/s]\n" ], "name": "stderr" }, { "output_type": "stream", "text": [ "[MoviePy] Done.\n", "[MoviePy] >>>> Video ready: ./output/demo.mp4 \n", "\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "Rty2GsyZZrI6" }, "source": [], "execution_count": null, "outputs": [] } ]}123version https://git-lfs.github.com/spec/v1oid sha256:52ea5ce4902017b77a2bb811dd9a82f57dee3883e06c18a42d288437263c7a20size 209280521125194062123version https://git-lfs.github.com/spec/v1oid sha256:42903e7cb7d8e250f96ad62efa00e6b8a8c2c507588d8e5e3f264a4dc4d925desize 27865618123version https://git-lfs.github.com/spec/v1oid sha256:e17ba6e4198ea06e5428079a14b3e2106627f2786e14a55d89b0ae3c647111bcsize 27865618123version https://git-lfs.github.com/spec/v1oid sha256:24caf144e9aabd5acd1127b06f13ed3528240adb9e747d77a94ac3f33e672330size 220243703123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172------------ Options -------------
batchSize: 8
beta1: 0.5
checkpoints_dir: ./checkpoints
continue_train: False
data_type: 32
dataroot: ./datasets/cityscapes/
debug: False
display_freq: 99
display_winsize: 512
feat_num: 3
fineSize: 512
fp16: False
gan_mode: hinge
gpu_ids: [0]
image_size: 224
input_nc: 3
instance_feat: False
isTrain: True
label_feat: False
label_nc: 0
lambda_GP: 10.0
lambda_feat: 10.0
lambda_id: 20.0
lambda_rec: 10.0
latent_size: 512
loadSize: 1024
load_features: False
load_pretrain:
local_rank: 0
lr: 0.0002
max_dataset_size: inf
model: pix2pixHD
nThreads: 2
n_blocks_global: 6
n_blocks_local: 3
n_clusters: 10
n_downsample_E: 4
n_downsample_global: 3
n_layers_D: 4
n_local_enhancers: 1
name: people
ndf: 64
nef: 16
netG: global
ngf: 64
niter: 10000
niter_decay: 10000
niter_fix_global: 0
no_flip: False
no_ganFeat_loss: False
no_html: False
no_instance: False
no_vgg_loss: False
norm: batch
norm_G: spectralspadesyncbatch3x3
num_D: 2
output_nc: 3
phase: train
pool_size: 0
print_freq: 100
resize_or_crop: scale_width
save_epoch_freq: 10000
save_latest_freq: 10000
semantic_nc: 3
serial_batches: False
tf_log: False
times_G: 1
use_dropout: False
verbose: False
which_epoch: latest
-------------- End ----------------1234567891011121314151617181920build: gpu: true python_version: "3.8" system_packages: - "libgl1-mesa-glx" - "libglib2.0-0" python_packages: - "imageio==2.9.0" - "torch==1.8.0" - "torchvision==0.9.0" - "numpy==1.21.1" - "insightface==0.2.1" - "ipython==7.21.0" - "Pillow==8.3.1" - "opencv-python==4.5.3.56" - "Fraction==1.5.1" - "onnxruntime-gpu==1.8.1" - "moviepy==1.0.3"
predict: "predict.py:Predictor"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125import osimport globimport torchimport randomfrom PIL import Imagefrom torch.utils import datafrom torchvision import transforms as T
class data_prefetcher(): def __init__(self, loader): self.loader = loader self.dataiter = iter(loader) self.stream = torch.cuda.Stream() self.mean = torch.tensor([0.485, 0.456, 0.406]).cuda().view(1,3,1,1) self.std = torch.tensor([0.229, 0.224, 0.225]).cuda().view(1,3,1,1) # With Amp, it isn't necessary to manually convert data to half. # if args.fp16: # self.mean = self.mean.half() # self.std = self.std.half() self.num_images = len(loader) self.preload()
def preload(self): try: self.src_image1, self.src_image2 = next(self.dataiter) except StopIteration: self.dataiter = iter(self.loader) self.src_image1, self.src_image2 = next(self.dataiter) with torch.cuda.stream(self.stream): self.src_image1 = self.src_image1.cuda(non_blocking=True) self.src_image1 = self.src_image1.sub_(self.mean).div_(self.std) self.src_image2 = self.src_image2.cuda(non_blocking=True) self.src_image2 = self.src_image2.sub_(self.mean).div_(self.std)
def next(self): torch.cuda.current_stream().wait_stream(self.stream) src_image1 = self.src_image1 src_image2 = self.src_image2 self.preload() return src_image1, src_image2 def __len__(self): """Return the number of images.""" return self.num_images
class SwappingDataset(data.Dataset): """Dataset class for the Artworks dataset and content dataset."""
def __init__(self, image_dir, img_transform, subffix='jpg', random_seed=1234): """Initialize and preprocess the Swapping dataset.""" self.image_dir = image_dir self.img_transform = img_transform self.subffix = subffix self.dataset = [] self.random_seed = random_seed self.preprocess() self.num_images = len(self.dataset)
def preprocess(self): """Preprocess the Swapping dataset.""" print("processing Swapping dataset images...")
temp_path = os.path.join(self.image_dir,'*/') pathes = glob.glob(temp_path) self.dataset = [] for dir_item in pathes: join_path = glob.glob(os.path.join(dir_item,'*.jpg')) print("processing %s"%dir_item,end='\r') temp_list = [] for item in join_path: temp_list.append(item) self.dataset.append(temp_list) random.seed(self.random_seed) random.shuffle(self.dataset) print('Finished preprocessing the Swapping dataset, total dirs number: %d...'%len(self.dataset)) def __getitem__(self, index): """Return two src domain images and two dst domain images.""" dir_tmp1 = self.dataset[index] dir_tmp1_len = len(dir_tmp1)
filename1 = dir_tmp1[random.randint(0,dir_tmp1_len-1)] filename2 = dir_tmp1[random.randint(0,dir_tmp1_len-1)] image1 = self.img_transform(Image.open(filename1)) image2 = self.img_transform(Image.open(filename2)) return image1, image2 def __len__(self): """Return the number of images.""" return self.num_images
def GetLoader( dataset_roots, batch_size=16, dataloader_workers=8, random_seed = 1234 ): """Build and return a data loader.""" num_workers = dataloader_workers data_root = dataset_roots random_seed = random_seed c_transforms = [] c_transforms.append(T.ToTensor()) c_transforms = T.Compose(c_transforms)
content_dataset = SwappingDataset( data_root, c_transforms, "jpg", random_seed) content_data_loader = data.DataLoader(dataset=content_dataset,batch_size=batch_size, drop_last=True,shuffle=True,num_workers=num_workers,pin_memory=True) prefetcher = data_prefetcher(content_data_loader) return prefetcher
def denorm(x): out = (x + 1) / 2 return out.clamp_(0, 1)123456/*! * Bootstrap v3.3.7 (http://getbootstrap.com) * Copyright 2011-2016 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) */.btn-danger,.btn-default,.btn-info,.btn-primary,.btn-success,.btn-warning{text-shadow:0 -1px 0 rgba(0,0,0,.2);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.15),0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 0 rgba(255,255,255,.15),0 1px 1px rgba(0,0,0,.075)}.btn-danger.active,.btn-danger:active,.btn-default.active,.btn-default:active,.btn-info.active,.btn-info:active,.btn-primary.active,.btn-primary:active,.btn-success.active,.btn-success:active,.btn-warning.active,.btn-warning:active{-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,.125);box-shadow:inset 0 3px 5px rgba(0,0,0,.125)}.btn-danger.disabled,.btn-danger[disabled],.btn-default.disabled,.btn-default[disabled],.btn-info.disabled,.btn-info[disabled],.btn-primary.disabled,.btn-primary[disabled],.btn-success.disabled,.btn-success[disabled],.btn-warning.disabled,.btn-warning[disabled],fieldset[disabled] .btn-danger,fieldset[disabled] .btn-default,fieldset[disabled] .btn-info,fieldset[disabled] .btn-primary,fieldset[disabled] .btn-success,fieldset[disabled] .btn-warning{-webkit-box-shadow:none;box-shadow:none}.btn-danger .badge,.btn-default .badge,.btn-info .badge,.btn-primary .badge,.btn-success .badge,.btn-warning .badge{text-shadow:none}.btn.active,.btn:active{background-image:none}.btn-default{text-shadow:0 1px 0 #fff;background-image:-webkit-linear-gradient(top,#fff 0,#e0e0e0 100%);background-image:-o-linear-gradient(top,#fff 0,#e0e0e0 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#fff),to(#e0e0e0));background-image:linear-gradient(to bottom,#fff 0,#e0e0e0 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe0e0e0', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#dbdbdb;border-color:#ccc}.btn-default:focus,.btn-default:hover{background-color:#e0e0e0;background-position:0 -15px}.btn-default.active,.btn-default:active{background-color:#e0e0e0;border-color:#dbdbdb}.btn-default.disabled,.btn-default.disabled.active,.btn-default.disabled.focus,.btn-default.disabled:active,.btn-default.disabled:focus,.btn-default.disabled:hover,.btn-default[disabled],.btn-default[disabled].active,.btn-default[disabled].focus,.btn-default[disabled]:active,.btn-default[disabled]:focus,.btn-default[disabled]:hover,fieldset[disabled] .btn-default,fieldset[disabled] .btn-default.active,fieldset[disabled] .btn-default.focus,fieldset[disabled] .btn-default:active,fieldset[disabled] .btn-default:focus,fieldset[disabled] .btn-default:hover{background-color:#e0e0e0;background-image:none}.btn-primary{background-image:-webkit-linear-gradient(top,#337ab7 0,#265a88 100%);background-image:-o-linear-gradient(top,#337ab7 0,#265a88 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#265a88));background-image:linear-gradient(to bottom,#337ab7 0,#265a88 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff265a88', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#245580}.btn-primary:focus,.btn-primary:hover{background-color:#265a88;background-position:0 -15px}.btn-primary.active,.btn-primary:active{background-color:#265a88;border-color:#245580}.btn-primary.disabled,.btn-primary.disabled.active,.btn-primary.disabled.focus,.btn-primary.disabled:active,.btn-primary.disabled:focus,.btn-primary.disabled:hover,.btn-primary[disabled],.btn-primary[disabled].active,.btn-primary[disabled].focus,.btn-primary[disabled]:active,.btn-primary[disabled]:focus,.btn-primary[disabled]:hover,fieldset[disabled] .btn-primary,fieldset[disabled] .btn-primary.active,fieldset[disabled] .btn-primary.focus,fieldset[disabled] .btn-primary:active,fieldset[disabled] .btn-primary:focus,fieldset[disabled] .btn-primary:hover{background-color:#265a88;background-image:none}.btn-success{background-image:-webkit-linear-gradient(top,#5cb85c 0,#419641 100%);background-image:-o-linear-gradient(top,#5cb85c 0,#419641 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#5cb85c),to(#419641));background-image:linear-gradient(to bottom,#5cb85c 0,#419641 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c', endColorstr='#ff419641', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#3e8f3e}.btn-success:focus,.btn-success:hover{background-color:#419641;background-position:0 -15px}.btn-success.active,.btn-success:active{background-color:#419641;border-color:#3e8f3e}.btn-success.disabled,.btn-success.disabled.active,.btn-success.disabled.focus,.btn-success.disabled:active,.btn-success.disabled:focus,.btn-success.disabled:hover,.btn-success[disabled],.btn-success[disabled].active,.btn-success[disabled].focus,.btn-success[disabled]:active,.btn-success[disabled]:focus,.btn-success[disabled]:hover,fieldset[disabled] .btn-success,fieldset[disabled] .btn-success.active,fieldset[disabled] .btn-success.focus,fieldset[disabled] .btn-success:active,fieldset[disabled] .btn-success:focus,fieldset[disabled] .btn-success:hover{background-color:#419641;background-image:none}.btn-info{background-image:-webkit-linear-gradient(top,#5bc0de 0,#2aabd2 100%);background-image:-o-linear-gradient(top,#5bc0de 0,#2aabd2 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#5bc0de),to(#2aabd2));background-image:linear-gradient(to bottom,#5bc0de 0,#2aabd2 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff2aabd2', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#28a4c9}.btn-info:focus,.btn-info:hover{background-color:#2aabd2;background-position:0 -15px}.btn-info.active,.btn-info:active{background-color:#2aabd2;border-color:#28a4c9}.btn-info.disabled,.btn-info.disabled.active,.btn-info.disabled.focus,.btn-info.disabled:active,.btn-info.disabled:focus,.btn-info.disabled:hover,.btn-info[disabled],.btn-info[disabled].active,.btn-info[disabled].focus,.btn-info[disabled]:active,.btn-info[disabled]:focus,.btn-info[disabled]:hover,fieldset[disabled] .btn-info,fieldset[disabled] .btn-info.active,fieldset[disabled] .btn-info.focus,fieldset[disabled] .btn-info:active,fieldset[disabled] .btn-info:focus,fieldset[disabled] .btn-info:hover{background-color:#2aabd2;background-image:none}.btn-warning{background-image:-webkit-linear-gradient(top,#f0ad4e 0,#eb9316 100%);background-image:-o-linear-gradient(top,#f0ad4e 0,#eb9316 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f0ad4e),to(#eb9316));background-image:linear-gradient(to bottom,#f0ad4e 0,#eb9316 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e', endColorstr='#ffeb9316', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#e38d13}.btn-warning:focus,.btn-warning:hover{background-color:#eb9316;background-position:0 -15px}.btn-warning.active,.btn-warning:active{background-color:#eb9316;border-color:#e38d13}.btn-warning.disabled,.btn-warning.disabled.active,.btn-warning.disabled.focus,.btn-warning.disabled:active,.btn-warning.disabled:focus,.btn-warning.disabled:hover,.btn-warning[disabled],.btn-warning[disabled].active,.btn-warning[disabled].focus,.btn-warning[disabled]:active,.btn-warning[disabled]:focus,.btn-warning[disabled]:hover,fieldset[disabled] .btn-warning,fieldset[disabled] .btn-warning.active,fieldset[disabled] .btn-warning.focus,fieldset[disabled] .btn-warning:active,fieldset[disabled] .btn-warning:focus,fieldset[disabled] .btn-warning:hover{background-color:#eb9316;background-image:none}.btn-danger{background-image:-webkit-linear-gradient(top,#d9534f 0,#c12e2a 100%);background-image:-o-linear-gradient(top,#d9534f 0,#c12e2a 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#d9534f),to(#c12e2a));background-image:linear-gradient(to bottom,#d9534f 0,#c12e2a 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f', endColorstr='#ffc12e2a', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#b92c28}.btn-danger:focus,.btn-danger:hover{background-color:#c12e2a;background-position:0 -15px}.btn-danger.active,.btn-danger:active{background-color:#c12e2a;border-color:#b92c28}.btn-danger.disabled,.btn-danger.disabled.active,.btn-danger.disabled.focus,.btn-danger.disabled:active,.btn-danger.disabled:focus,.btn-danger.disabled:hover,.btn-danger[disabled],.btn-danger[disabled].active,.btn-danger[disabled].focus,.btn-danger[disabled]:active,.btn-danger[disabled]:focus,.btn-danger[disabled]:hover,fieldset[disabled] .btn-danger,fieldset[disabled] .btn-danger.active,fieldset[disabled] .btn-danger.focus,fieldset[disabled] .btn-danger:active,fieldset[disabled] .btn-danger:focus,fieldset[disabled] .btn-danger:hover{background-color:#c12e2a;background-image:none}.img-thumbnail,.thumbnail{-webkit-box-shadow:0 1px 2px rgba(0,0,0,.075);box-shadow:0 1px 2px rgba(0,0,0,.075)}.dropdown-menu>li>a:focus,.dropdown-menu>li>a:hover{background-color:#e8e8e8;background-image:-webkit-linear-gradient(top,#f5f5f5 0,#e8e8e8 100%);background-image:-o-linear-gradient(top,#f5f5f5 0,#e8e8e8 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f5f5f5),to(#e8e8e8));background-image:linear-gradient(to bottom,#f5f5f5 0,#e8e8e8 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#ffe8e8e8', GradientType=0);background-repeat:repeat-x}.dropdown-menu>.active>a,.dropdown-menu>.active>a:focus,.dropdown-menu>.active>a:hover{background-color:#2e6da4;background-image:-webkit-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-o-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#2e6da4));background-image:linear-gradient(to bottom,#337ab7 0,#2e6da4 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0);background-repeat:repeat-x}.navbar-default{background-image:-webkit-linear-gradient(top,#fff 0,#f8f8f8 100%);background-image:-o-linear-gradient(top,#fff 0,#f8f8f8 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#fff),to(#f8f8f8));background-image:linear-gradient(to bottom,#fff 0,#f8f8f8 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#fff8f8f8', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-radius:4px;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.15),0 1px 5px rgba(0,0,0,.075);box-shadow:inset 0 1px 0 rgba(255,255,255,.15),0 1px 5px rgba(0,0,0,.075)}.navbar-default .navbar-nav>.active>a,.navbar-default .navbar-nav>.open>a{background-image:-webkit-linear-gradient(top,#dbdbdb 0,#e2e2e2 100%);background-image:-o-linear-gradient(top,#dbdbdb 0,#e2e2e2 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#dbdbdb),to(#e2e2e2));background-image:linear-gradient(to bottom,#dbdbdb 0,#e2e2e2 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdbdbdb', endColorstr='#ffe2e2e2', GradientType=0);background-repeat:repeat-x;-webkit-box-shadow:inset 0 3px 9px rgba(0,0,0,.075);box-shadow:inset 0 3px 9px rgba(0,0,0,.075)}.navbar-brand,.navbar-nav>li>a{text-shadow:0 1px 0 rgba(255,255,255,.25)}.navbar-inverse{background-image:-webkit-linear-gradient(top,#3c3c3c 0,#222 100%);background-image:-o-linear-gradient(top,#3c3c3c 0,#222 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#3c3c3c),to(#222));background-image:linear-gradient(to bottom,#3c3c3c 0,#222 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff3c3c3c', endColorstr='#ff222222', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-radius:4px}.navbar-inverse .navbar-nav>.active>a,.navbar-inverse .navbar-nav>.open>a{background-image:-webkit-linear-gradient(top,#080808 0,#0f0f0f 100%);background-image:-o-linear-gradient(top,#080808 0,#0f0f0f 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#080808),to(#0f0f0f));background-image:linear-gradient(to bottom,#080808 0,#0f0f0f 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff080808', endColorstr='#ff0f0f0f', GradientType=0);background-repeat:repeat-x;-webkit-box-shadow:inset 0 3px 9px rgba(0,0,0,.25);box-shadow:inset 0 3px 9px rgba(0,0,0,.25)}.navbar-inverse .navbar-brand,.navbar-inverse .navbar-nav>li>a{text-shadow:0 -1px 0 rgba(0,0,0,.25)}.navbar-fixed-bottom,.navbar-fixed-top,.navbar-static-top{border-radius:0}@media (max-width:767px){.navbar .navbar-nav .open .dropdown-menu>.active>a,.navbar .navbar-nav .open .dropdown-menu>.active>a:focus,.navbar .navbar-nav .open .dropdown-menu>.active>a:hover{color:#fff;background-image:-webkit-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-o-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#2e6da4));background-image:linear-gradient(to bottom,#337ab7 0,#2e6da4 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0);background-repeat:repeat-x}}.alert{text-shadow:0 1px 0 rgba(255,255,255,.2);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 2px rgba(0,0,0,.05)}.alert-success{background-image:-webkit-linear-gradient(top,#dff0d8 0,#c8e5bc 100%);background-image:-o-linear-gradient(top,#dff0d8 0,#c8e5bc 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#dff0d8),to(#c8e5bc));background-image:linear-gradient(to bottom,#dff0d8 0,#c8e5bc 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffc8e5bc', GradientType=0);background-repeat:repeat-x;border-color:#b2dba1}.alert-info{background-image:-webkit-linear-gradient(top,#d9edf7 0,#b9def0 100%);background-image:-o-linear-gradient(top,#d9edf7 0,#b9def0 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#d9edf7),to(#b9def0));background-image:linear-gradient(to bottom,#d9edf7 0,#b9def0 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffb9def0', GradientType=0);background-repeat:repeat-x;border-color:#9acfea}.alert-warning{background-image:-webkit-linear-gradient(top,#fcf8e3 0,#f8efc0 100%);background-image:-o-linear-gradient(top,#fcf8e3 0,#f8efc0 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#fcf8e3),to(#f8efc0));background-image:linear-gradient(to bottom,#fcf8e3 0,#f8efc0 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fff8efc0', GradientType=0);background-repeat:repeat-x;border-color:#f5e79e}.alert-danger{background-image:-webkit-linear-gradient(top,#f2dede 0,#e7c3c3 100%);background-image:-o-linear-gradient(top,#f2dede 0,#e7c3c3 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f2dede),to(#e7c3c3));background-image:linear-gradient(to bottom,#f2dede 0,#e7c3c3 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffe7c3c3', GradientType=0);background-repeat:repeat-x;border-color:#dca7a7}.progress{background-image:-webkit-linear-gradient(top,#ebebeb 0,#f5f5f5 100%);background-image:-o-linear-gradient(top,#ebebeb 0,#f5f5f5 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#ebebeb),to(#f5f5f5));background-image:linear-gradient(to bottom,#ebebeb 0,#f5f5f5 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffebebeb', endColorstr='#fff5f5f5', GradientType=0);background-repeat:repeat-x}.progress-bar{background-image:-webkit-linear-gradient(top,#337ab7 0,#286090 100%);background-image:-o-linear-gradient(top,#337ab7 0,#286090 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#286090));background-image:linear-gradient(to bottom,#337ab7 0,#286090 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff286090', GradientType=0);background-repeat:repeat-x}.progress-bar-success{background-image:-webkit-linear-gradient(top,#5cb85c 0,#449d44 100%);background-image:-o-linear-gradient(top,#5cb85c 0,#449d44 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#5cb85c),to(#449d44));background-image:linear-gradient(to bottom,#5cb85c 0,#449d44 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c', endColorstr='#ff449d44', GradientType=0);background-repeat:repeat-x}.progress-bar-info{background-image:-webkit-linear-gradient(top,#5bc0de 0,#31b0d5 100%);background-image:-o-linear-gradient(top,#5bc0de 0,#31b0d5 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#5bc0de),to(#31b0d5));background-image:linear-gradient(to bottom,#5bc0de 0,#31b0d5 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff31b0d5', GradientType=0);background-repeat:repeat-x}.progress-bar-warning{background-image:-webkit-linear-gradient(top,#f0ad4e 0,#ec971f 100%);background-image:-o-linear-gradient(top,#f0ad4e 0,#ec971f 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f0ad4e),to(#ec971f));background-image:linear-gradient(to bottom,#f0ad4e 0,#ec971f 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e', endColorstr='#ffec971f', GradientType=0);background-repeat:repeat-x}.progress-bar-danger{background-image:-webkit-linear-gradient(top,#d9534f 0,#c9302c 100%);background-image:-o-linear-gradient(top,#d9534f 0,#c9302c 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#d9534f),to(#c9302c));background-image:linear-gradient(to bottom,#d9534f 0,#c9302c 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f', endColorstr='#ffc9302c', GradientType=0);background-repeat:repeat-x}.progress-bar-striped{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent)}.list-group{border-radius:4px;-webkit-box-shadow:0 1px 2px rgba(0,0,0,.075);box-shadow:0 1px 2px rgba(0,0,0,.075)}.list-group-item.active,.list-group-item.active:focus,.list-group-item.active:hover{text-shadow:0 -1px 0 #286090;background-image:-webkit-linear-gradient(top,#337ab7 0,#2b669a 100%);background-image:-o-linear-gradient(top,#337ab7 0,#2b669a 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#2b669a));background-image:linear-gradient(to bottom,#337ab7 0,#2b669a 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2b669a', GradientType=0);background-repeat:repeat-x;border-color:#2b669a}.list-group-item.active .badge,.list-group-item.active:focus .badge,.list-group-item.active:hover .badge{text-shadow:none}.panel{-webkit-box-shadow:0 1px 2px rgba(0,0,0,.05);box-shadow:0 1px 2px rgba(0,0,0,.05)}.panel-default>.panel-heading{background-image:-webkit-linear-gradient(top,#f5f5f5 0,#e8e8e8 100%);background-image:-o-linear-gradient(top,#f5f5f5 0,#e8e8e8 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f5f5f5),to(#e8e8e8));background-image:linear-gradient(to bottom,#f5f5f5 0,#e8e8e8 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#ffe8e8e8', GradientType=0);background-repeat:repeat-x}.panel-primary>.panel-heading{background-image:-webkit-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-o-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#2e6da4));background-image:linear-gradient(to bottom,#337ab7 0,#2e6da4 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0);background-repeat:repeat-x}.panel-success>.panel-heading{background-image:-webkit-linear-gradient(top,#dff0d8 0,#d0e9c6 100%);background-image:-o-linear-gradient(top,#dff0d8 0,#d0e9c6 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#dff0d8),to(#d0e9c6));background-image:linear-gradient(to bottom,#dff0d8 0,#d0e9c6 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffd0e9c6', GradientType=0);background-repeat:repeat-x}.panel-info>.panel-heading{background-image:-webkit-linear-gradient(top,#d9edf7 0,#c4e3f3 100%);background-image:-o-linear-gradient(top,#d9edf7 0,#c4e3f3 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#d9edf7),to(#c4e3f3));background-image:linear-gradient(to bottom,#d9edf7 0,#c4e3f3 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffc4e3f3', GradientType=0);background-repeat:repeat-x}.panel-warning>.panel-heading{background-image:-webkit-linear-gradient(top,#fcf8e3 0,#faf2cc 100%);background-image:-o-linear-gradient(top,#fcf8e3 0,#faf2cc 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#fcf8e3),to(#faf2cc));background-image:linear-gradient(to bottom,#fcf8e3 0,#faf2cc 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fffaf2cc', GradientType=0);background-repeat:repeat-x}.panel-danger>.panel-heading{background-image:-webkit-linear-gradient(top,#f2dede 0,#ebcccc 100%);background-image:-o-linear-gradient(top,#f2dede 0,#ebcccc 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f2dede),to(#ebcccc));background-image:linear-gradient(to bottom,#f2dede 0,#ebcccc 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffebcccc', GradientType=0);background-repeat:repeat-x}.well{background-image:-webkit-linear-gradient(top,#e8e8e8 0,#f5f5f5 100%);background-image:-o-linear-gradient(top,#e8e8e8 0,#f5f5f5 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#e8e8e8),to(#f5f5f5));background-image:linear-gradient(to bottom,#e8e8e8 0,#f5f5f5 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffe8e8e8', endColorstr='#fff5f5f5', GradientType=0);background-repeat:repeat-x;border-color:#dcdcdc;-webkit-box-shadow:inset 0 1px 3px rgba(0,0,0,.05),0 1px 0 rgba(255,255,255,.1);box-shadow:inset 0 1px 3px rgba(0,0,0,.05),0 1px 0 rgba(255,255,255,.1)}/*# sourceMappingURL=bootstrap-theme.min.css.map */12345678910111213/*! * IE10 viewport hack for Surface/desktop Windows 8 bug * Copyright 2014-2015 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) */
/* * See the Getting Started docs for more information: * http://getbootstrap.com/getting-started/#support-ie10-width */@-ms-viewport { width: device-width; }@-o-viewport { width: device-width; }@viewport { width: device-width; }12345/* Move down content because we have a fixed navbar that is 50px tall */body { padding-top: 50px; padding-bottom: 20px;}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849.which-image-container { display: flex; flex-wrap: wrap; align-items: center; flex-direction: column; justify-content: space-between; height: 100%;}
.which-image-container :nth-child(2) { display: flex; flex-wrap: wrap; align-items: center; flex-direction: column; justify-content: flex-end;}
.which-image { display: inline-block; flex: 1; flex-basis: 45%; margin: 1% 1% 1% 1%; width: 100%; height: auto;
}
.which-image img { float: right; width: 100%;}
.image-display2 img { float: right; width: 100%;}/* .image-display{ align-items: center;}.image-display2{ align-items: center;} */.select-show { border-style: dashed; border-width: 2px; border-color: purple;
/* padding: 2px; */}12345678910111213141516171819202122232425262728293031323334353637
# Preparation
### Installation**We highly recommand that you use Anaconda for Installation**```conda create -n simswap python=3.6conda activate simswapconda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=10.2 -c pytorch(option): pip install --ignore-installed imageiopip install insightface==0.2.1 onnxruntime moviepy(option): pip install onnxruntime-gpu (If you want to reduce the inference time)(It will be diffcult to install onnxruntime-gpu , the specify version of onnxruntime-gpu may depends on your machine and cuda version.)```- ***We have now updated the prepare document. The main change gpu version of onnx is supported now. If you have configured the environment before, now use pip install onnxruntime-gpu ,You can increase the computing speed.***- We use the face detection and alignment methods from **[insightface](https://github.com/deepinsight/insightface)** for image preprocessing. Please download the relative files and unzip them to ./insightface_func/models from [this link](https://onedrive.live.com/?authkey=%21ADJ0aAOSsc90neY&cid=4A83B6B633B029CC&id=4A83B6B633B029CC%215837&parId=4A83B6B633B029CC%215834&action=locate).- We use the face parsing from **[face-parsing.PyTorch](https://github.com/zllrunning/face-parsing.PyTorch)** for image postprocessing. Please download the relative file and place it in ./parsing_model/checkpoint from [this link](https://drive.google.com/file/d/154JgKpzCPW82qINcVieuPH3fZ2e0P812/view).- The pytorch and cuda versions above are most recommanded. They may vary.- Using insightface with different versions is not recommanded. Please use this specific version.- These settings are tested valid on both Windows and Ubuntu.
### Pretrained modelThere are two archive files in the drive: **checkpoints.zip** and **arcface_checkpoint.tar**
- **Copy the arcface_checkpoint.tar into ./arcface_model**- **Unzip checkpoints.zip, place it in the root dir ./**
[[Google Drive]](https://drive.google.com/drive/folders/1jV6_0FIMPC53FZ2HzZNJZGMe55bbu17R?usp=sharing)[[Baidu Drive]](https://pan.baidu.com/s/1wFV11RVZMHqd-ky4YpLdcA) Password: ```jd2v```
**Simswap 512 (optional)**
The checkpoint of **Simswap 512 beta version** has been uploaded in [Github release](https://github.com/neuralchen/SimSwap/releases/download/512_beta/512.zip).If you want to experience Simswap 512, feel free to try.- **Unzip 512.zip, place it in the root dir ./checkpoints**.
### NoteWe expect users to have GPU with at least 3G memory. For those who do not, we provide [[Colab Notebook implementation]](https://colab.research.google.com/github/neuralchen/SimSwap/blob/main/SimSwap%20colab.ipynb).123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115<!-- * @FilePath: \SimSwap\docs\guidance\usage.md * @Author: AceSix * @Date: 2021-06-28 10:01:40 * @LastEditors: AceSix * @LastEditTime: 2021-06-28 10:05:11 * Copyright (C) 2021 SJTU. All rights reserved.-->
# Usage
###### Before running, please make sure you have installed the environment and downloaded requested files according to the [preparation guidance](./preparation.md).###### The below example command lines are using mask by default.
### Simple face swapping for already face-aligned images```python test_one_image.py --name people --Arc_path arcface_model/arcface_checkpoint.tar --pic_a_path crop_224/6.jpg --pic_b_path crop_224/ds.jpg --output_path output/ ```
### Face swapping for video
- Swap only one face within the video(the one with highest confidence by face detection).```python test_video_swapsingle.py --crop_size 224 --use_mask --name people --Arc_path arcface_model/arcface_checkpoint.tar --pic_a_path ./demo_file/Iron_man.jpg --video_path ./demo_file/multi_people_1080p.mp4 --output_path ./output/multi_test_swapsingle.mp4 --temp_path ./temp_results ```- Swap all faces within the video.```python test_video_swapmulti.py --crop_size 224 --use_mask --name people --Arc_path arcface_model/arcface_checkpoint.tar --pic_a_path ./demo_file/Iron_man.jpg --video_path ./demo_file/multi_people_1080p.mp4 --output_path ./output/multi_test_swapmulti.mp4 --temp_path ./temp_results ```- Swap the ***specific*** face within the video.```python test_video_swapspecific.py --crop_size 224 --use_mask --pic_specific_path ./demo_file/specific1.png --name people --Arc_path arcface_model/arcface_checkpoint.tar --pic_a_path ./demo_file/Iron_man.jpg --video_path ./demo_file/multi_people_1080p.mp4 --output_path ./output/multi_test_specific.mp4 --temp_path ./temp_results ```When changing the specified face, you need to give a picture of the person whose face is to be changed. Then assign the picture path to the argument "***--pic_specific_path***". This picture should be a front face and show the entire head and neck, which can help accurately change the face (if you still donβt know how to choose the picture, you can refer to the specific*.png of [./demo_file/](https://github.com/neuralchen/SimSwap/tree/main/demo_file)). It would be better if this picture was taken from the video to be changed.
- Swap ***multi specific*** face with **multi specific id** within the video.```python test_video_swap_multispecific.py --crop_size 224 --use_mask --name people --Arc_path arcface_model/arcface_checkpoint.tar --video_path ./demo_file/multi_people_1080p.mp4 --output_path ./output/multi_test_multispecific.mp4 --temp_path ./temp_results --multisepcific_dir ./demo_file/multispecific ```The folder you assign to ***"--multisepcific_dir"*** should be looked like:```$Your folder name$
βββ DST_01.jpg(png)βββ DST_02.jpg(png)βββ...βββ SRC_01.jpg(png)βββ SRC_02.jpg(png)βββ...```The result is that the face corresponding to SRC_01.jpg (png) in the video will be replaced by the face corresponding to DST_01.jpg (png). Then the character corresponding to SRC_02.jpg(png) will be replaced by the face of DST_02.jpg(png), and so on. Note that when using your own data and naming it, do not remove the **0** in SRC_(DST_)**0**1.jpg(png), etc.
### Face swapping for Arbitrary images
- Swap only one face within one image(the one with highest confidence by face detection). The result would be saved to ./output/result_whole_swapsingle.jpg```python test_wholeimage_swapsingle.py --crop_size 224 --use_mask --name people --Arc_path arcface_model/arcface_checkpoint.tar --pic_a_path ./demo_file/Iron_man.jpg --pic_b_path ./demo_file/multi_people.jpg --output_path ./output/ ```- Swap all faces within one image. The result would be saved to ./output/result_whole_swapmulti.jpg```python test_wholeimage_swapmulti.py --crop_size 224 --use_mask --name people --Arc_path arcface_model/arcface_checkpoint.tar --pic_a_path ./demo_file/Iron_man.jpg --pic_b_path ./demo_file/multi_people.jpg --output_path ./output/ ```- Swap **specific** face within one image. The result would be saved to ./output/result_whole_swapspecific.jpg```python test_wholeimage_swapspecific.py --crop_size 224 --use_mask --name people --Arc_path arcface_model/arcface_checkpoint.tar --pic_a_path ./demo_file/Iron_man.jpg --pic_b_path ./demo_file/multi_people.jpg --output_path ./output/ --pic_specific_path ./demo_file/specific2.png ```- Swap **multi specific** face with **multi specific id** within one image. The result would be saved to ./output/result_whole_swap_multispecific.jpg```python test_wholeimage_swap_multispecific.py --crop_size 224 --use_mask --name people --Arc_path arcface_model/arcface_checkpoint.tar --pic_b_path ./demo_file/multi_people.jpg --output_path ./output/ --multisepcific_dir ./demo_file/multispecific ```### About using Simswap 512 (beta version)We trained a beta version of Simswap 512 on [VGGFace2-HQ](https://github.com/NNNNAI/VGGFace2-HQ) and open sourced the model (if you think the Simswap 512 is cool, please star our [VGGFace2-HQ](https://github.com/NNNNAI/VGGFace2-HQ) repo).
The usage of applying Simswap 512 is to modify the value of the argument: "***--crop_size***" to 512 , take the command line of "Swap **multi specific** face with **multi specific id** within one image." as an example, the following command line can get the result without watermark:```python test_wholeimage_swap_multispecific.py --crop_size 512 --use_mask --name people --Arc_path arcface_model/arcface_checkpoint.tar --pic_b_path ./demo_file/multi_people.jpg --output_path ./output/ --multisepcific_dir ./demo_file/multispecific ```The effect of Simswap 512 is shown below.<img src="../img/result_whole_swap_multispecific_512.jpg"/>
### About watermark of simswap logoThe above example command lines are to add the simswap logo as the watermark by default. After our discussion, we have added a hyper parameter to control whether to remove watermark.
The usage of removing the watermark is to add an argument: "***--no_simswaplogo***" to the command line, take the command line of "Swap all faces within one image" as an example, the following command line can get the result without watermark:```python test_wholeimage_swapmulti.py --no_simswaplogo --crop_size 224 --use_mask --name people --Arc_path arcface_model/arcface_checkpoint.tar --pic_a_path ./demo_file/Iron_man.jpg --pic_b_path ./demo_file/multi_people.jpg --output_path ./output/```### About using mask for better resultWe provide two methods to paste the face back to the original image after changing the face: Using mask or using bounding box. At present, the effect of using mask is the best. All the above code examples are using mask. If you want to use the bounding box, you only need to remove the --use_mask in the code example.Difference between using mask and not using mask can be found [here](https://imgsli.com/NjE3OTA).
### Difference between single face swapping and all face swapping are shown below.<img src="../img/multi_face_comparison.png"/>
### Parameters| Parameters | Function || :---- | :---- || --name | The SimSwap training logs name || --pic_a_path | Path of image with the target face || --pic_b_path | Path of image with the source face to swap || --pic_specific_path | Path of image with the specific face to be swapped ||--multisepcific_dir |Path of image folder for multi specific face swapping|| --video_path | Path of video with the source face to swap || --temp_path | Path to store intermediate files || --output_path | Path of directory to store the face swapping result || --no_simswaplogo |The hyper parameter to control whether to remove watermark || --use_mask |The hyper parameter to control whether to use face parsing for the better visual effects(I recommend to use)|
### NoteWe expect users to have GPU with at least 3G memory.the For those who do not, we will provide Colab Notebook implementation in the future..gitattributes+81
SimSwap/.gitattributesAdded+2
SimSwap/.gitignoreAdded+145
SimSwap/LICENSEAdded+399
SimSwap/MultiSpecific.ipynbAdded+1
SimSwap/README.mdAdded+247
SimSwap/SimSwap colab.ipynbAdded+579
SimSwap/arcface_model/arcface_checkpoint.tarAdded+3
SimSwap/checkpoints/people/iter.txtAdded+2
SimSwap/checkpoints/people/latest_net_D1.pthAdded+3
SimSwap/checkpoints/people/latest_net_D2.pthAdded+3
SimSwap/checkpoints/people/latest_net_G.pthAdded+3
SimSwap/checkpoints/people/loss_log.txtAdded
SimSwap/checkpoints/people/opt.txtAdded+72
SimSwap/cog.yamlAdded+20
SimSwap/data/data_loader_Swapping.pyAdded+125
SimSwap/docs/css/bootstrap-theme.min.cssAdded+6
SimSwap/docs/css/bootstrap.min.cssAdded
SimSwap/docs/css/ie10-viewport-bug-workaround.cssAdded+13
SimSwap/docs/css/jumbotron.cssAdded+5
SimSwap/docs/css/page.cssAdded+49
SimSwap/docs/favicon.icoAdded
SimSwap/docs/fonts/glyphicons-halflings-regular.eotAdded
SimSwap/docs/fonts/glyphicons-halflings-regular.svgAdded
SimSwap/docs/fonts/glyphicons-halflings-regular.ttfAdded
SimSwap/docs/fonts/glyphicons-halflings-regular.woffAdded
SimSwap/docs/fonts/glyphicons-halflings-regular.woff2Added
SimSwap/docs/guidance/preparation.mdAdded+37
SimSwap/docs/guidance/usage.mdAdded+115
SimSwap/docs/img/LRGT_201110059_201110091.webpAdded

Large File Pointer Details
- SHA256: 5ee03f9b50cbd670775d0d35d069d80faf6caa0852efaa4c56056fa2dcfb32ec
- Pointer size: 132 Bytes
- Size of remote file: 1.1 MB
SimSwap/docs/img/anni.webpAdded

Large File Pointer Details
- SHA256: 7b24ed6d04bda9064989d3a5cb175fa1b5a47f19c60560f8b8fc48f542122d9a
- Pointer size: 132 Bytes
- Size of remote file: 4.61 MB
SimSwap/docs/img/chenglong.webpAdded

Large File Pointer Details
- SHA256: 1225e4e305aea3f397b026cdb21cd65f9153f03cfaceb48878a1f1ed383801fc
- Pointer size: 132 Bytes
- Size of remote file: 4.61 MB
SimSwap/docs/img/girl2-RGB.pngAdded

Large File Pointer Details
- SHA256: 2ee8c1f81db555f4744f9f1d67b8ce2a90dfe4506bce2c6c295ba01531f40f3b
- Pointer size: 132 Bytes
- Size of remote file: 1.57 MB
SimSwap/docs/img/girl2.gifAdded

Large File Pointer Details
- SHA256: a357007c63e82866caaf95b67d20f5fc5cf4a74c55b9f6f160db5739372145b1
- Pointer size: 133 Bytes
- Size of remote file: 16.4 MB
SimSwap/docs/img/id/Iron_man.jpgAdded

SimSwap/docs/img/id/anni.jpgAdded

SimSwap/docs/img/id/chenglong.jpgAdded

SimSwap/docs/img/id/wuyifan.pngAdded

Large File Pointer Details
- SHA256: 7c0162a0446c27d0477796b84af948918b4af4056862df78f76391e1b8475bb7
- Pointer size: 131 Bytes
- Size of remote file: 244 kB
SimSwap/docs/img/id/zhoujielun.jpgAdded

SimSwap/docs/img/id/zhuyin.jpgAdded

Large File Pointer Details
- SHA256: 4067296af9f24912b81717599d8e719eac9801773ca81c8fd3c3de61fcf0ac7e
- Pointer size: 131 Bytes
- Size of remote file: 235 kB
SimSwap/docs/img/logo.pngAdded

SimSwap/docs/img/logo1.pngAdded

SimSwap/docs/img/logo2.pngAdded

SimSwap/docs/img/mama_mask_short.webpAdded

Large File Pointer Details
- SHA256: 0fcae8825b4432c707213ba1c4bb12a3558f21dc4a5daa33093236a64c4068aa
- Pointer size: 132 Bytes
- Size of remote file: 8.42 MB
SimSwap/docs/img/mama_mask_wuyifan_short.webpAdded

Large File Pointer Details
- SHA256: 1ce1a1268f53247815a40ced34d71a48f297a813f1c46a72fd60a3ac6db1873f
- Pointer size: 132 Bytes
- Size of remote file: 8.45 MB
SimSwap/docs/img/multi_face_comparison.pngAdded

Large File Pointer Details
- SHA256: 5094cc0e43097f1f36ce56cf97f8642fb230d380402cb4bdd18698f4d427a72e
- Pointer size: 132 Bytes
- Size of remote file: 9.17 MB
SimSwap/docs/img/new.gifAdded

SimSwap/docs/img/nrsig.pngAdded

Large File Pointer Details
- SHA256: 410c7d637466e05c9994478956ab92604514b84c3c5005984a3e8ab8ced9bb31
- Pointer size: 132 Bytes
- Size of remote file: 1.6 MB
SimSwap/docs/img/result_whole_swap_multispecific_512.jpgAdded

Large File Pointer Details
- SHA256: 8cf2075ddb5d029d4c5d41f9c4adabada3fbf94268e06e1692e8000f2b42e1bf
- Pointer size: 131 Bytes
- Size of remote file: 343 kB
SimSwap/docs/img/results1.PNGAdded
Large File Pointer Details
- SHA256: e5bcdf0796760d0a0e1b1dbcb9ab1960739e20461de6aaf73e16c8a2b17a1c53
- Pointer size: 132 Bytes
- Size of remote file: 1.63 MB