{"id":18612949,"url":"https://github.com/haofanwang/inswapper","last_synced_at":"2025-04-04T13:08:16.894Z","repository":{"id":179651960,"uuid":"659540114","full_name":"haofanwang/inswapper","owner":"haofanwang","description":"One-click Face Swapper and Restoration powered by insightface 🔥","archived":false,"fork":false,"pushed_at":"2024-04-16T09:01:23.000Z","size":782,"stargazers_count":597,"open_issues_count":23,"forks_count":93,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-03-28T12:03:04.397Z","etag":null,"topics":["codeformer","deepfake","face-swap","insightface","restoration","roop","super-resolution"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/haofanwang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-28T03:58:28.000Z","updated_at":"2025-03-27T07:59:11.000Z","dependencies_parsed_at":"2023-11-21T07:54:40.497Z","dependency_job_id":"79bc2f7d-5c32-4e8f-87a4-9814ae1825fa","html_url":"https://github.com/haofanwang/inswapper","commit_stats":null,"previous_names":["haofanwang/inswapper"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haofanwang%2Finswapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haofanwang%2Finswapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haofanwang%2Finswapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haofanwang%2Finswapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haofanwang","download_url":"https://codeload.github.com/haofanwang/inswapper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174686,"owners_count":20896121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codeformer","deepfake","face-swap","insightface","restoration","roop","super-resolution"],"created_at":"2024-11-07T03:19:13.213Z","updated_at":"2025-04-04T13:08:16.869Z","avatar_url":"https://github.com/haofanwang.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# inswapper\n\nOne-click Face Swapper and Restoration powered by [insightface](https://github.com/deepinsight/insightface). We don't use the name ROOP here, as the credit should be given to the group that develops this great face swap model.\n\n## News\n🔥 We release [InstantID](https://github.com/InstantID/InstantID) as a state-of-the-art ID preservering generation method.\n\n\u003cleft\u003e\u003cimg src=\"https://github.com/haofanwang/inswapper/raw/main/data/mans1.jpeg\" width=\"49%\" height=\"49%\"\u003e\u003c/left\u003e \n\u003cright\u003e\u003cimg src=\"https://github.com/haofanwang/inswapper/raw/main/result.png\" width=\"49%\" height=\"49%\"\u003e\u003c/right\u003e \n\n## Installation\n\n```bash\n# git clone this repository\ngit clone https://github.com/haofanwang/inswapper.git\ncd inswapper\n\n# create a Python venv\npython3 -m venv venv\n\n# activate the venv\nsource venv/bin/activate\n\n# install required packages\npip install -r requirements.txt\n```\n\nYou have to install ``onnxruntime-gpu`` manually to enable GPU inference, install ``onnxruntime`` by default to use CPU only inference.\n\n## Download Checkpoints\n\nFirst, you need to download [face swap model](https://github.com/facefusion/facefusion-assets/releases/download/models/inswapper_128.onnx) and save it under `./checkpoints`. To obtain better result, it is highly recommended to improve image quality with face restoration model. Here, we use [CodeFormer](https://github.com/sczhou/CodeFormer). You can finish all as following, required models will be downloaded automatically when you first run the inference.\n\n```bash\nmkdir checkpoints\nwget -O ./checkpoints/inswapper_128.onnx https://github.com/facefusion/facefusion-assets/releases/download/models/inswapper_128.onnx\n\ncd ..\ngit lfs install\ngit clone https://huggingface.co/spaces/sczhou/CodeFormer\n```\n\n\n## Quick Inference\n\n```bash\nfrom swapper import *\n\nsource_img = [Image.open(\"./data/man1.jpeg\"),Image.open(\"./data/man2.jpeg\")]\ntarget_img = Image.open(\"./data/mans1.jpeg\")\n\nmodel = \"./checkpoints/inswapper_128.onnx\"\nresult_image = process(source_img, target_img, -1, -1, model)\nresult_image.save(\"result.png\")\n```\n\nTo improve to quality of face, we can further do face restoration as shown in the full script.\n\n```bash\npython swapper.py \\\n--source_img=\"./data/man1.jpeg;./data/man2.jpeg\" \\\n--target_img \"./data/mans1.jpeg\" \\\n--face_restore \\\n--background_enhance \\\n--face_upsample \\\n--upscale=2 \\\n--codeformer_fidelity=0.5\n```\nYou will obtain the exact result as above.\n\n## Acknowledgement\nThis project is inspired by [inswapper](https://huggingface.co/deepinsight/inswapper/tree/main), thanks [insightface.ai](https://insightface.ai/) for releasing their powerful face swap model that makes this happen. Our codebase is built on the top of [sd-webui-roop](https://github.com/s0md3v/sd-webui-roop) and [CodeFormer](https://huggingface.co/spaces/sczhou/CodeFormer).\n\n## Contact\nIf you have any issue, feel free to contact me via haofanwang.ai@gmail.com.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaofanwang%2Finswapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaofanwang%2Finswapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaofanwang%2Finswapper/lists"}