[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-modelscope--facechain":3,"tool-modelscope--facechain":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":79,"owner_location":79,"owner_email":80,"owner_twitter":79,"owner_website":81,"owner_url":82,"languages":83,"stars":100,"forks":101,"last_commit_at":102,"license":103,"difficulty_score":10,"env_os":104,"env_gpu":105,"env_ram":106,"env_deps":107,"category_tags":118,"github_topics":79,"view_count":10,"oss_zip_url":79,"oss_zip_packed_at":79,"status":16,"created_at":119,"updated_at":120,"faqs":121,"releases":151},1273,"modelscope\u002Ffacechain","facechain","FaceChain is a deep-learning toolchain for generating your Digital-Twin.","FaceChain 是一个基于深度学习的工具链，用于生成高质量的数字孪生人像。用户只需提供一张照片，即可在 10 秒内生成多种风格的人像作品，支持文本描述、图像修复等多种生成方式。它解决了传统人像生成中需要复杂训练流程、风格受限以及生成速度慢的问题，使得个性化人像创作更加高效和灵活。\n\nFaceChain 适合开发者、研究人员以及对 AI 图像生成感兴趣的设计师使用。对于开发者来说，它提供了 Python 脚本和 Gradio 界面，便于集成与扩展；研究人员可以借助其开源代码和论文细节深入探索相关技术；设计师则能快速生成符合需求的高质量人像作品。\n\n其独特之处在于 FACT（Face Adapter with deCoupled Training）技术，实现了无需训练即可生成多风格人像，同时兼容 ControlNet 和 LoRAs 等主流模型，显著提升了生成效率和可控性。此外，FaceChain 还支持一键调用多种风格，并提供自动训练脚本，方便用户扩展新风格。","\u003Cp align=\"center\">\n    \u003Cbr>\n    \u003Cimg src=\"https:\u002F\u002Fmodelscope.oss-cn-beijing.aliyuncs.com\u002Fmodelscope.gif\" width=\"400\"\u002F>\n    \u003Cbr>\n    \u003Ch1>FaceChain\u003C\u002Fh1>\n\u003Cp>\n\n\u003Cp align=\"center\">\n\u003Ca href=\"https:\u002F\u002Ftrendshift.io\u002Frepositories\u002F1185\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmodelscope_facechain_readme_4cc089988f35.png\" alt=\"modelscope%2Ffacechain | Trendshift\" style=\"width: 250px; height: 55px;\" width=\"250\" height=\"55\"\u002F>\u003C\u002Fa>\n\u003C\u002Fp>\n\n# News\n- Our work [FaceChain-MMID](https:\u002F\u002Fwww.sciencedirect.com\u002Fscience\u002Farticle\u002Fabs\u002Fpii\u002FS0031320325005187) got accepted to Pattern Recognition ! (May 30th, 2025 UTC)\n- More Technology Details of FaceChain-FACT train-free portrait generation can be seen in [Paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.12312). (October 17th, 2024 UTC)\n- Our work [TopoFR](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.10587) got accepted to NeurIPS 2024 ! (September 26th, 2024 UTC)\n- We provide training scripts for new styles, offering an automatic training for new style LoRas as well as the corresponding style prompts, along with the one click call in Infinite Style Portrait generation tab! (July 3rd, 2024 UTC)\n- 🚀🚀🚀 We are launching [FACT] into the main branch, offering a 10-second impressive speed and seamless integration with standard ready-to-use LoRas and ControlNets, along with improved instruction-following capabilities ! The original train-based FaceChain is moved to (https:\u002F\u002Fgithub.com\u002Fmodelscope\u002Ffacechain\u002Ftree\u002Fv3.0.0 ). (May 28th, 2024 UTC)\n- Our work [FaceChain-ImagineID](https:\u002F\u002Farxiv.org\u002Fabs\u002F2403.01901) and [FaceChain-SuDe](https:\u002F\u002Farxiv.org\u002Fabs\u002F2403.06775) got accepted to CVPR 2024 ! (February 27th, 2024 UTC)\n\n# Introduction\n\n如果您熟悉中文，可以阅读[中文版本的README](.\u002FREADME_ZH.md)。\n\nFaceChain is a novel framework for generating identity-preserved human portraits. In the newest FaceChain FACT (Face Adapter with deCoupled Training) version, with only 1 photo and 10 seconds, you can generate personal portraits in different settings (multiple styles now supported!). FaceChain has both high controllability and authenticity in portrait generation, including text-to-image and inpainting based pipelines, and is seamlessly compatible with ControlNet and LoRAs. You may generate portraits via FaceChain's Python scripts, or via the familiar Gradio interface, or via sd webui. \nFaceChain is powered by [ModelScope](https:\u002F\u002Fgithub.com\u002Fmodelscope\u002Fmodelscope).\n\n\n\u003Cp align=\"center\">\n        ModelScope Studio \u003Ca href=\"https:\u002F\u002Fmodelscope.cn\u002Fstudios\u002FCVstudio\u002FFaceChain-FACT\">🤖\u003Ca>\u003C\u002Fa>&nbsp ｜API \u003Ca href=\"https:\u002F\u002Fhelp.aliyun.com\u002Fzh\u002Fdashscope\u002Fdeveloper-reference\u002Ffacechain-quick-start\">🔥\u003Ca>\u003C\u002Fa>&nbsp | SD WebUI | HuggingFace Space \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fmodelscope\u002FFaceChain-FACT\">🤗\u003C\u002Fa>&nbsp \n\u003C\u002Fp>\n\u003Cbr>\n\n\u003Ca href='https:\u002F\u002Ffacechain-fact.github.io\u002F'>\u003Cimg src='https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FProject-Page-Green'>\u003C\u002Fa>  [![YouTube](https:\u002F\u002Fbadges.aleen42.com\u002Fsrc\u002Fyoutube.svg)](https:\u002F\u002Fyoutu.be\u002FDHqEl0qwi-M?si=y6VpInXdhIX0HpbI)\n\n\n![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmodelscope_facechain_readme_1db1b2b101d4.png)\n\n\n# News\n- Our work [FaceChain-MMID](https:\u002F\u002Fwww.sciencedirect.com\u002Fscience\u002Farticle\u002Fabs\u002Fpii\u002FS0031320325005187) got accepted to Pattern Recognition ! (May 30th, 2025 UTC)\n- More Technology Details of FaceChain-FACT train-free portrait generation can be seen in [Paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.12312). (October 17th, 2024 UTC)\n- Our work [TopoFR](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.10587) got accepted to NeurIPS 2024 ! (September 26th, 2024 UTC)\n- We provide training scripts for new styles, offering an automatic training for new style LoRas as well as the corresponding style prompts, along with the one click call in Infinite Style Portrait generation tab! (July 3rd, 2024 UTC)\n- 🚀🚀🚀 We are launching [FACT], offering a 10-second impressive speed and seamless integration with standard ready-to-use LoRas and ControlNets, along with improved instruction-following capabilities ! (May 28th, 2024 UTC)\n- Our work [FaceChain-ImagineID](https:\u002F\u002Farxiv.org\u002Fabs\u002F2403.01901) and [FaceChain-SuDe](https:\u002F\u002Farxiv.org\u002Fabs\u002F2403.06775) got accepted to CVPR 2024 ! (February 27th, 2024 UTC)\n- 🏆🏆🏆Alibaba Annual Outstanding Open Source Project, Alibaba Annual Open Source Pioneer (Yang Liu, Baigui Sun). (January 20th, 2024 UTC)\n- Our work [InfoBatch](https:\u002F\u002Fgithub.com\u002Fhenryqin1997\u002FInfoBatch) co-authored with NUS team got accepted to ICLR 2024(Oral)! (January 16th, 2024 UTC)\n- 🏆OpenAtom's 2023 Rapidly Growing Open Source Projects Award. (December 20th, 2023 UTC)\n- Add SDXL pipeline🔥🔥🔥, image detail is improved obviously. (November 22th, 2023 UTC)\n- Support super resolution🔥🔥🔥, provide multiple resolution choice (512*512, 768*768, 1024*1024, 2048*2048). (November 13th, 2023 UTC)\n- 🏆FaceChain has been selected in the [BenchCouncil Open100 (2022-2023)](https:\u002F\u002Fwww.benchcouncil.org\u002Fevaluation\u002Fopencs\u002Fannual.html#Institutions) annual ranking. (November 8th, 2023 UTC)\n- Add virtual try-on module. (October 27th, 2023 UTC)\n- Add wanx version [online free app](https:\u002F\u002Ftongyi.aliyun.com\u002Fwanxiang\u002Fapp\u002Fportrait-gallery). (October 26th, 2023 UTC)\n- 🏆1024 Programmer's Day AIGC Application Tool Most Valuable Business Award. (2023-10-24, 2023 UTC)\n- Support FaceChain in stable-diffusion-webui🔥🔥🔥. (October 13th, 2023 UTC)\n- High performance inpainting for single & double person, Simplify User Interface. (September 09th, 2023 UTC)\n- More Technology Details can be seen in [Paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2308.14256). (August 30th, 2023 UTC)\n- Add validate & ensemble for Lora training, and InpaintTab(hide in gradio for now).  (August 28th, 2023 UTC)\n- Add pose control module.   (August 27th, 2023 UTC)\n- Add robust face lora training module, enhance the performance of one pic training & style-lora blending.   (August 27th, 2023 UTC)\n- HuggingFace Space is available now! You can experience FaceChain directly with \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fmodelscope\u002FFaceChain\">🤗\u003C\u002Fa>      (August 25th, 2023 UTC)\n- Add awesome prompts! Refer to: [awesome-prompts-facechain](resources\u002Fawesome-prompts-facechain.txt)   (August 18th, 2023 UTC)\n- Support a series of new style models in a plug-and-play fashion.  (August 16th, 2023 UTC)\n- Support customizable prompts. (August 16th, 2023 UTC)\n- Colab notebook is available now! You can experience FaceChain directly with  [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fmodelscope\u002Ffacechain\u002Fblob\u002Fmain\u002Ffacechain_demo.ipynb).   (August 15th, 2023 UTC)\n\n\n# To-Do List\n- full-body digital humans\n\n\n# Citation\n\nPlease cite FaceChain and FaceChain-FACT in your publications if it helps your research\n```\n@article{liu2023facechain,\n  title={FaceChain: A Playground for Identity-Preserving Portrait Generation},\n  author={Liu, Yang and Yu, Cheng and Shang, Lei and Wu, Ziheng and \n          Wang, Xingjun and Zhao, Yuze and Zhu, Lin and Cheng, Chen and \n          Chen, Weitao and Xu, Chao and Xie, Haoyu and Yao, Yuan and \n          Zhou,  Wenmeng and Chen Yingda and Xie, Xuansong and Sun, Baigui},\n  journal={arXiv preprint arXiv:2308.14256},\n  year={2023}\n}\n```\n```\n@article{yu2024facechain,\n  title={FaceChain-FACT: Face Adapter with Decoupled Training for Identity-preserved Personalization},\n  author={Yu, Cheng and Xie, Haoyu and Shang, Lei and Liu, Yang and Dan, Jun and Sun, Baigui and Bo, Liefeng},\n  journal={arXiv preprint arXiv:2410.12312},\n  year={2024}\n}\n```\n\n\n# Installation\n\n## Compatibility Verification\nWe have verified e2e execution on the following environment:\n- python: py3.8, py3.10\n- pytorch: torch2.0.0, torch2.0.1\n- CUDA: 11.7\n- CUDNN: 8+\n- OS: Ubuntu 20.04, CentOS 7.9\n- GPU: Nvidia-A10 24G\n\n## Memory Optimization\nJemalloc are recommanded to install for optimizing the memory from above 30G to below 20G. Here is an example for installing Jemalloc in Modelscope notebook.\n\n```shell\napt-get install -y libjemalloc-dev\nexport LD_PRELOAD=\u002Flib\u002Fx86_64-linux-gnu\u002Flibjemalloc.so\n```\n\n## Installation Guide\nThe following installation methods are supported:\n\n\n### 1. ModelScope notebook【recommended】\n\n   The ModelScope Notebook offers a free-tier that allows ModelScope user to run the FaceChain application with minimum setup, refer to [ModelScope Notebook](https:\u002F\u002Fmodelscope.cn\u002Fmy\u002Fmynotebook\u002Fpreset)\n\n```shell\n# Step1: 我的notebook -> PAI-DSW -> GPU环境\n# Note: Please use: ubuntu20.04-py38-torch2.0.1-tf1.15.5-modelscope1.8.1\n\n# Step2: Entry the Notebook cell，clone FaceChain from github:\n!GIT_LFS_SKIP_SMUDGE=1 git clone https:\u002F\u002Fgithub.com\u002Fmodelscope\u002Ffacechain.git --depth 1\n\n# Step3: Change the working directory to facechain, and install the dependencies:\nimport os\nos.chdir('\u002Fmnt\u002Fworkspace\u002Ffacechain')    # You may change to your own path\nprint(os.getcwd())\n\n!pip3 install gradio==3.47.1\n!pip3 install controlnet_aux==0.0.6\n!pip3 install python-slugify\n!pip3 install diffusers==0.29.0\n!pip3 install peft==0.11.1\n!pip3 install modelscope -U\n!pip3 install datasets==2.16\n\n# Step4: Start the app service, click \"public URL\" or \"local URL\", upload your images to \n# train your own model and then generate your digital twin.\n!python3 app.py\n\n```\n   Alternatively, you may also purchase a [PAI-DSW](https:\u002F\u002Fwww.aliyun.com\u002Factivity\u002Fbigdata\u002Fpai\u002Fdsw) instance (using A10 resource), with the option of ModelScope image to run FaceChain following similar steps.\n\n\n### 2. Docker\n\nIf you are familiar with using docker, we recommend to use this way:\n\n```shell\n# Step1: Prepare the environment with GPU on local or cloud, we recommend to use Alibaba Cloud ECS, refer to: https:\u002F\u002Fwww.aliyun.com\u002Fproduct\u002Fecs\n\n# Step2: Download the docker image (for installing docker engine, refer to https:\u002F\u002Fdocs.docker.com\u002Fengine\u002Finstall\u002F）\n# For China Mainland users:\ndocker pull registry.cn-hangzhou.aliyuncs.com\u002Fmodelscope-repo\u002Fmodelscope:ubuntu20.04-cuda11.7.1-py38-torch2.0.1-tf1.15.5-1.8.1\n# For users outside China Mainland:\ndocker pull registry.us-west-1.aliyuncs.com\u002Fmodelscope-repo\u002Fmodelscope:ubuntu20.04-cuda11.7.1-py38-torch2.0.1-tf1.15.5-1.8.1\n\n# Step3: run the docker container\ndocker run -it --name facechain -p 7860:7860 --gpus all registry.cn-hangzhou.aliyuncs.com\u002Fmodelscope-repo\u002Fmodelscope:ubuntu20.04-cuda11.7.1-py38-torch2.0.1-tf1.15.5-1.8.1 \u002Fbin\u002Fbash\n# Note: you may need to install the nvidia-container-runtime, follow the instructions:\n# 1. Install nvidia-container-runtime：https:\u002F\u002Fdocs.nvidia.com\u002Fdatacenter\u002Fcloud-native\u002Fcontainer-toolkit\u002Flatest\u002Finstall-guide.html\n# 2. sudo systemctl restart docker\n\n# Step4: Install the gradio in the docker container:\npip3 install gradio==3.47.1\npip3 install controlnet_aux==0.0.6\npip3 install python-slugify\npip3 install diffusers==0.29.0\npip3 install peft==0.11.1\npip3 install modelscope -U\npip3 install datasets==2.16\n\n# Step5 clone facechain from github\nGIT_LFS_SKIP_SMUDGE=1 git clone https:\u002F\u002Fgithub.com\u002Fmodelscope\u002Ffacechain.git --depth 1\ncd facechain\npython3 app.py\n# Note: FaceChain currently assume single-GPU, if your environment has multiple GPU, please use the following instead:\n# CUDA_VISIBLE_DEVICES=0 python3 app.py\n\n# Step6\nRun the app server: click \"public URL\" --> in the form of: https:\u002F\u002Fxxx.gradio.live\n```\n\n### 3. stable-diffusion-webui\n\n1. Select the `Extensions Tab`, then choose `Install From URL` (official plugin integration is integrated, please install from URL currently).\n   ![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmodelscope_facechain_readme_5b272b6a430d.png)\n\n2. Switch to `Installed`, check the FaceChain plugin, then click `Apply and restart UI`. It may take a while for installing the dependencies and downloading the models. Make sure that the \"CUDA Toolkit\" is installed correctly, otherwise the \"mmcv\" package cannot be successfully installed.\n   ![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmodelscope_facechain_readme_f6324874beed.png)\n\n3. After the page refreshes, the appearance of the `FaceChain` Tab indicates a successful installation.\n   ![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmodelscope_facechain_readme_31511fe4388a.jpg)\n\n# Script Execution\n\nFaceChain supports direct inference in the python environment. When inferring for Infinite Style Portrait generation, please edit the code in run_inference.py:\n\n```python\n# Use pose control, default False\nuse_pose_model = False\n# The path of the input image containing ID information for portrait generation\ninput_img_path = 'poses\u002Fman\u002Fpose2.png'\n# The path of the image for pose control, only effective when using pose control\npose_image = 'poses\u002Fman\u002Fpose1.png'\n# The number of images to generate in inference\nnum_generate = 5\n# The weight for the style model, see styles for detail\nmultiplier_style = 0.25\n# Specify a folder to save the generated images, this parameter can be modified as needed\noutput_dir = '.\u002Fgenerated'\n# The index of the chosen base model, see facechain\u002Fconstants.py for detail\nbase_model_idx = 0\n# The index of the style model, see styles for detail\nstyle_idx = 0\n```\n\nThen execute:\n\n```shell\npython run_inference.py\n```\n\nYou can find the generated personal digital image photos in the `output_dir`.\n\nWhen inferring for Fixed Templates Portrait generation, please edit the code in run_inference_inpaint.py.\n\n```python\n# Number of faces for the template image\nnum_faces = 1\n# Index of face for inpainting, counting from left to right\nselected_face = 1\n# The strength for inpainting, you do not need to change the parameter\nstrength = 0.6\n# The path of the template image\ninpaint_img = 'poses\u002Fman\u002Fpose1.png'\n# The path of the input image containing ID information for portrait generation\ninput_img_path = 'poses\u002Fman\u002Fpose2.png'\n# The number of images to generate in inference\nnum_generate = 1\n# Specify a folder to save the generated images, this parameter can be modified as needed\noutput_dir = '.\u002Fgenerated_inpaint'\n```\n\nThen execute:\n\n```shell\npython run_inference_inpaint.py\n```\n\nYou can find the generated personal digital image photos in the `output_dir`.\n\n\n# Algorithm Introduction\n\nThe capability of AI portraits generation comes from the large generative models like Stable Diffusion and its fine-tuning techniques. Due to the strong generalization capability of large models, it is possible to perform downstream tasks by fine-tuning on specific types of data and tasks, while preserving the model's overall ability of text following and image generation. The technical foundation of train-based and train-free AI portraits generation comes from applying different fine-tuning tasks to generative models. Currently, most existing AI portraits tools adopt a two-stage “train then generate” pipeline, where the fine-tuning task is “to generate portrait photos of a fixed character ID”, and the corresponding training data are multiple images of the fixed character ID. The effectiveness of such train-based pipeline depends on the scale of the training data, thus requiring certain image data support and training time, which also increases the cost for users.\n\nDifferent from train-based pipeline, train-free pipeline adjusts the fine-tuning task to “generate portrait photos of a specified character ID”, meaning that the character ID image (face photo) is used as an additional input, and the output is a portrait photo preserving the input ID. Such a pipeline completely separates offline training from online inference, allowing users to generate portraits directly based on the fine-tuned model with only one photo in just 10 seconds, avoiding the cost for extensive data and training time. The fine-tuning task of train-free AI portraits generation is based on the adapter module. Face photos are processed through an image encoder with fixed weights and a parameter-efficient feature projection layer to obtain aligned features, and are then fed into the U-Net model of Stable Diffusion through attention mechanism similar as text conditions. At this point, face information as an independent branch condition is fed into the model alongside text information for inference, thereby enabling the generated images to maintain ID fidelity.\n\nThe basic algorithm based on face adapter is capable of achieving train-free AI portraits, but still requires certain adjustments to further improve its effectiveness. Existing train-free portrait tools generally suffer from the following issues: poor image quality of portraits, inadequate text following and style retention abilities in portraits, poor controllability and richness of portrait faces, and poor compatibility with extensions like ControlNet and style Lora. To address these issues, FaceChain attribute them to the fact that the fine-tuning tasks for existing train-free AI portrait tools have coupled with too much information beyond character IDs, and propose FaceChain Face Adapter with Decoupled Training (FaceChain FACT) to solve these problems. By fine-tuning the Stable Diffusion model on millions of portrait data, FaceChain FACT can achieve high-quality portrait image generation for specified character IDs. The entire framework of FaceChain FACT is shown in the figure below.\n\n![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmodelscope_facechain_readme_6f343bebbbd2.png)\n\nThe decoupled training of FaceChain FACT consists of two parts: decoupling face from image, and decoupling ID from face. Existing methods often treat denoising portrait images as the fine-tuning task, which makes the model hard to accurately focus on the face area, thereby affecting the text-to-image ability of the base Stable Diffusion model. FaceChain FACT draws on the sequential processing and regional control advantages of face-swapping algorithms and implements the fine-tuning method for decoupling faces from images from both structural and training strategy aspects. Structurally, unlike existing methods that use a parallel cross-attention mechanism to process face and text information, FaceChain FACT adopts a sequential processing approach as an independent adapter layer inserted into the original Stable Diffusion's blocks. This way, face adaptation acts as an independent step similar to face-swapping during the denoising process, avoiding interference between face and text conditions. In terms of training strategy, besides the original MSE loss function, FaceChain FACT introduces the Face Adapting Incremental Regularization (FAIR) loss function, which controls the feature increment of the face adaptation step in the adapter layer to focus on the face region. During inference, users can flexibly adjust the generated effects by modifying the weight of the face adapter, balancing fidelity and generalization of the face while maintaining the text-to-image ability of Stable Diffusion. The FAIR loss function is formulated as follows:\n\n![image](resources\u002FFAIR.png)\n\nFurthermore, addressing the issue of poor controllability and richness of generated faces, FaceChain FACT proposes a training method for decoupling ID from face, so that the portrait process only preserves the character ID rather than the entire face. Firstly, to better extract the ID information from the face while maintaining certain key facial details, and to better adapt to the structure of Stable Diffusion, FaceChain FACT employs a face feature extractor named [TransFace](https:\u002F\u002Fgithub.com\u002FDanJun6737\u002FTransFace) based on the Transformer architecture, which is pre-trained on a large-scale face dataset. All tokens from the penultimate layer are subsequently fed into a simple attention query model for feature projection, thereby ensuring that the extracted ID features meet the aforementioned requirements. Additionally, during the training process, FaceChain FACT uses the Classifier Free Guidance (CFG) method to perform random shuffle and drop for different portrait images of the same ID, thus ensuring that the input face images and the target images used for denoising may have different faces with the same ID, thus further preventing the model from overfitting to non-ID information of the face. As such, FaceChain FACT possesses high compatibility with the massive exquisite styles of FaceChain, which is shown as follows.\n\n![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmodelscope_facechain_readme_c6b2a23146f9.png)\n\n\n## Model List\n\nThe models used in FaceChain:\n\n[1]  Face recognition model TransFace：https:\u002F\u002Fwww.modelscope.cn\u002Fmodels\u002Fiic\u002Fcv_vit_face-recognition\n\n[2]  Face detection model DamoFD：https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002Fdamo\u002Fcv_ddsar_face-detection_iclr23-damofd\n\n[3]  Human parsing model M2FP：https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002Fdamo\u002Fcv_resnet101_image-multiple-human-parsing\n\n[4]  Skin retouching model ABPN：https:\u002F\u002Fwww.modelscope.cn\u002Fmodels\u002Fdamo\u002Fcv_unet_skin_retouching_torch\n\n[5]  Face fusion model：https:\u002F\u002Fwww.modelscope.cn\u002Fmodels\u002Fdamo\u002Fcv_unet_face_fusion_torch\n\n[6]  FaceChain FACT model: https:\u002F\u002Fwww.modelscope.cn\u002Fmodels\u002Fyucheng1996\u002FFaceChain-FACT\n\n[7]  Face attribute recognition model FairFace: https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002Fdamo\u002Fcv_resnet34_face-attribute-recognition_fairface\n\n\n# More Information\n\n- [ModelScope library](https:\u002F\u002Fgithub.com\u002Fmodelscope\u002Fmodelscope\u002F)\n\n\n​        ModelScope Library provides the foundation for building the model-ecosystem of ModelScope, including the interface and implementation to integrate various models into ModelScope. \n\n- [Contribute models to ModelScope](https:\u002F\u002Fmodelscope.cn\u002Fdocs\u002FModelScope%E6%A8%A1%E5%9E%8B%E6%8E%A5%E5%85%A5%E6%B5%81%E7%A8%8B%E6%A6%82%E8%A7%88)\n\n# License\n\nThis project is licensed under the [Apache License (Version 2.0)](https:\u002F\u002Fgithub.com\u002Fmodelscope\u002Fmodelscope\u002Fblob\u002Fmaster\u002FLICENSE).\n","\u003Cp align=\"center\">\n    \u003Cbr>\n    \u003Cimg src=\"https:\u002F\u002Fmodelscope.oss-cn-beijing.aliyuncs.com\u002Fmodelscope.gif\" width=\"400\"\u002F>\n    \u003Cbr>\n    \u003Ch1>FaceChain\u003C\u002Fh1>\n\u003Cp>\n\n\u003Cp align=\"center\">\n\u003Ca href=\"https:\u002F\u002Ftrendshift.io\u002Frepositories\u002F1185\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmodelscope_facechain_readme_4cc089988f35.png\" alt=\"modelscope%2Ffacechain | Trendshift\" style=\"width: 250px; height: 55px;\" width=\"250\" height=\"55\"\u002F>\u003C\u002Fa>\n\u003C\u002Fp>\n\n# 新闻\n- 我们的工作 [FaceChain-MMID](https:\u002F\u002Fwww.sciencedirect.com\u002Fscience\u002Farticle\u002Fabs\u002Fpii\u002FS0031320325005187) 已被《Pattern Recognition》期刊接受！（2025年5月30日 UTC）\n- FaceChain-FACT 无训练肖像生成的更多技术细节可在[论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.12312)中查看。（2024年10月17日 UTC）\n- 我们的工作 [TopoFR](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.10587) 已被 NeurIPS 2024 接受！（2024年9月26日 UTC）\n- 我们提供新风格的训练脚本，支持自动为新风格 LoRa 进行训练并生成相应的风格提示，同时在“无限风格肖像生成”选项卡中实现一键调用！（2024年7月3日 UTC）\n- 🚀🚀🚀 我们将 [FACT] 上线主分支，提供仅需10秒的惊人速度，并与标准即用型 LoRa 和 ControlNet 无缝集成，同时提升指令遵循能力！原基于训练的 FaceChain 已移至 (https:\u002F\u002Fgithub.com\u002Fmodelscope\u002Ffacechain\u002Ftree\u002Fv3.0.0 )。（2024年5月28日 UTC）\n- 我们的工作 [FaceChain-ImagineID](https:\u002F\u002Farxiv.org\u002Fabs\u002F2403.01901) 和 [FaceChain-SuDe](https:\u002F\u002Farxiv.org\u002Fabs\u002F2403.06775) 已被 CVPR 2024 接受！（2024年2月27日 UTC）\n\n# 简介\n\n如果您熟悉中文，可以阅读[中文版本的README](.\u002FREADME_ZH.md)。\n\nFaceChain 是一个用于生成身份保真的人像的新框架。在最新的 FaceChain FACT（带解耦训练的面部适配器）版本中，只需一张照片和10秒钟，您就能在不同场景下生成个性化肖像（现已支持多种风格！）。FaceChain 在肖像生成方面兼具高度可控性和真实性，包括文本到图像和修复填充等流程，并且可与 ControlNet 和 LoRa 无缝兼容。您可以通过 FaceChain 的 Python 脚本、熟悉的 Gradio 界面或 SD WebUI 来生成肖像。\nFaceChain 由 [ModelScope](https:\u002F\u002Fgithub.com\u002Fmodelscope\u002Fmodelscope) 提供技术支持。\n\n\n\u003Cp align=\"center\">\n        ModelScope Studio \u003Ca href=\"https:\u002F\u002Fmodelscope.cn\u002Fstudios\u002FCVstudio\u002FFaceChain-FACT\">🤖\u003Ca>\u003C\u002Fa>&nbsp ｜API \u003Ca href=\"https:\u002F\u002Fhelp.aliyun.com\u002Fzh\u002Fdashscope\u002Fdeveloper-reference\u002Ffacechain-quick-start\">🔥\u003Ca>\u003C\u002Fa>&nbsp | SD WebUI | HuggingFace Space \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fmodelscope\u002FFaceChain-FACT\">🤗\u003C\u002Fa>&nbsp \n\u003C\u002Fp>\n\u003Cbr>\n\n\u003Ca href='https:\u002F\u002Ffacechain-fact.github.io\u002F'>\u003Cimg src='https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FProject-Page-Green'>\u003C\u002Fa>  [![YouTube](https:\u002F\u002Fbadges.aleen42.com\u002Fsrc\u002Fyoutube.svg)](https:\u002F\u002Fyoutu.be\u002FDHqEl0qwi-M?si=y6VpInXdhIX0HpbI)\n\n\n![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmodelscope_facechain_readme_1db1b2b101d4.png)\n\n\n# 新闻\n- 我们的工作 [FaceChain-MMID](https:\u002F\u002Fwww.sciencedirect.com\u002Fscience\u002Farticle\u002Fabs\u002Fpii\u002FS0031320325005187) 已被《Pattern Recognition》期刊接受！（2025年5月30日 UTC）\n- FaceChain-FACT 无训练肖像生成的更多技术细节可在[论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.12312)中查看。（2024年10月17日 UTC）\n- 我们的工作 [TopoFR](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.10587) 已被 NeurIPS 2024 接受！（2024年9月26日 UTC）\n- 我们提供新风格的训练脚本，支持自动为新风格 LoRa 进行训练并生成相应的风格提示，同时在“无限风格肖像生成”选项卡中实现一键调用！（2024年7月3日 UTC）\n- 🚀🚀🚀 我们将 [FACT] 上线，提供仅需10秒的惊人速度，并与标准即用型 LoRa 和 ControlNet 无缝集成，同时提升指令遵循能力！（2024年5月28日 UTC）\n- 我们的工作 [FaceChain-ImagineID](https:\u002F\u002Farxiv.org\u002Fabs\u002F2403.01901) 和 [FaceChain-SuDe](https:\u002F\u002Farxiv.org\u002Fabs\u002F2403.06775) 已被 CVPR 2024 接受！（2024年2月27日 UTC）\n- 🏆🏆🏆阿里巴巴年度优秀开源项目、阿里巴巴年度开源先锋（刘洋、孙百贵）。（2024年1月20日 UTC）\n- 我们的工作 [InfoBatch](https:\u002F\u002Fgithub.com\u002Fhenryqin1997\u002FInfoBatch) 与新加坡国立大学团队合作完成，已被 ICLR 2024 接受（口头报告）！（2024年1月16日 UTC）\n- 🏆开放原子基金会2023年度快速成长开源项目奖。（2023年12月20日 UTC）\n- 新增 SDXL 流程🔥🔥🔥，图像细节明显提升。（2023年11月22日 UTC）\n- 支持超分辨率🔥🔥🔥，提供多种分辨率选择（512*512、768*768、1024*1024、2048*2048）。（2023年11月13日 UTC）\n- 🏆FaceChain 已入选[BenchCouncil Open100（2022-2023）](https:\u002F\u002Fwww.benchcouncil.org\u002Fevaluation\u002Fopencs\u002Fannual.html#Institutions) 年度排名。（2023年11月8日 UTC）\n- 新增虚拟试穿模块。（2023年10月27日 UTC）\n- 推出 wanx 版本[在线免费应用](https:\u002F\u002Ftongyi.aliyun.com\u002Fwanxiang\u002Fapp\u002Fportrait-gallery)。（2023年10月26日 UTC）\n- 🏆1024程序员节 AIGC 应用工具最具价值商业奖。（2023年10月24日 UTC）\n- 支持 FaceChain 在 stable-diffusion-webui 中使用🔥🔥🔥。（2023年10月13日 UTC）\n- 高性能单人及双人修复填充，简化用户界面。（2023年9月9日 UTC）\n- 更多技术细节可在[论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2308.14256)中查看。（2023年8月30日 UTC）\n- 新增 Lora 训练的验证与集成功能，以及 InpaintTab（目前在 Gradio 中隐藏）。（2023年8月28日 UTC）\n- 新增姿态控制模块。（2023年8月27日 UTC）\n- 新增稳健的面部 Lora 训练模块，提升单张照片训练及风格 Lora 混合的效果。（2023年8月27日 UTC）\n- HuggingFace Space 现已上线！您可通过 \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fmodelscope\u002FFaceChain\">🤗\u003C\u002Fa> 直接体验 FaceChain。（2023年8月25日 UTC）\n- 新增超赞提示词！请参考：[awesome-prompts-facechain](resources\u002Fawesome-prompts-facechain.txt)。（2023年8月18日 UTC）\n- 支持一系列新风格模型，实现即插即用。（2023年8月16日 UTC）\n- 支持自定义提示词。（2023年8月16日 UTC）\n- Colab 笔记本现已上线！您可通过 [![在 Colab 中打开](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fmodelscope\u002Ffacechain\u002Fblob\u002Fmain\u002Ffacechain_demo.ipynb) 直接体验 FaceChain。（2023年8月15日 UTC）\n\n\n# 待办事项\n- 全身数字人\n\n# 引用\n\n如果您认为 FaceChain 和 FaceChain-FACT 对您的研究有所帮助，请在您的论文中引用它们。\n```\n@article{liu2023facechain,\n  title={FaceChain: 一个用于身份保留的人像生成平台},\n  author={刘洋、于成、尚磊、吴子恒、王兴军、赵宇泽、朱琳、程晨、陈伟涛、徐超、谢浩宇、姚远、周文梦、陈英达、谢轩松、孙百贵},\n  journal={arXiv 预印本 arXiv:2308.14256},\n  year={2023}\n}\n```\n```\n@article{yu2024facechain,\n  title={FaceChain-FACT：一种具有解耦训练的身份保留个性化面部适配器},\n  author={于成、谢浩宇、尚磊、刘洋、单俊、孙百贵、薄立峰},\n  journal={arXiv 预印本 arXiv:2410.12312},\n  year={2024}\n}\n```\n\n\n# 安装\n\n## 兼容性验证\n我们已在以下环境中验证了端到端的运行：\n- Python：py3.8、py3.10\n- PyTorch：torch2.0.0、torch2.0.1\n- CUDA：11.7\n- cuDNN：8+\n- 操作系统：Ubuntu 20.04、CentOS 7.9\n- GPU：Nvidia-A10 24G\n\n## 内存优化\n建议安装 Jemalloc，以将内存占用从 30G 以上优化至 20G 以下。以下是 Modelscope Notebook 中安装 Jemalloc 的示例。\n\n```shell\napt-get install -y libjemalloc-dev\nexport LD_PRELOAD=\u002Flib\u002Fx86_64-linux-gnu\u002Flibjemalloc.so\n```\n\n## 安装指南\n支持以下几种安装方式：\n\n\n### 1. ModelScope Notebook【推荐】\n\nModelScope Notebook 提供免费版，允许 ModelScope 用户在最少配置下运行 FaceChain 应用程序，详情请参阅 [ModelScope Notebook](https:\u002F\u002Fmodelscope.cn\u002Fmy\u002Fmynotebook\u002Fpreset)。\n\n```shell\n# 第一步：我的 Notebook -> PAI-DSW -> GPU 环境\n# 注意：请使用：ubuntu20.04-py38-torch2.0.1-tf1.15.5-modelscope1.8.1\n\n# 第二步：进入 Notebook 单元格，从 GitHub 克隆 FaceChain：\n!GIT_LFS_SKIP_SMUDGE=1 git clone https:\u002F\u002Fgithub.com\u002Fmodelscope\u002Ffacechain.git --depth 1\n\n# 第三步：切换工作目录到 facechain，并安装依赖项：\nimport os\nos.chdir('\u002Fmnt\u002Fworkspace\u002Ffacechain')    # 您可以更改为您自己的路径\nprint(os.getcwd())\n\n!pip3 install gradio==3.47.1\n!pip3 install controlnet_aux==0.0.6\n!pip3 install python-slugify\n!pip3 install diffusers==0.29.0\n!pip3 install peft==0.11.1\n!pip3 install modelscope -U\n!pip3 install datasets==2.16\n\n# 第四步：启动应用服务，点击“公共 URL”或“本地 URL”，上传您的图片以\n# 训练您自己的模型并生成您的数字孪生。\n!python3 app.py\n```\n此外，您也可以购买一个 [PAI-DSW](https:\u002F\u002Fwww.aliyun.com\u002Factivity\u002Fbigdata\u002Fpai\u002Fdsw) 实例（使用 A10 资源），并选择 ModelScope 镜像来按照类似步骤运行 FaceChain。\n\n\n### 2. Docker\n\n如果您熟悉 Docker 的使用，我们推荐采用这种方式：\n\n```shell\n# 第一步：在本地或云端准备带有 GPU 的环境，建议使用阿里云 ECS，详情请参阅：https:\u002F\u002Fwww.aliyun.com\u002Fproduct\u002Fecs\n\n# 第二步：下载 Docker 镜像（有关安装 Docker 引擎的说明，请参阅 https:\u002F\u002Fdocs.docker.com\u002Fengine\u002Finstall\u002F）\n# 针对中国大陆用户：\ndocker pull registry.cn-hangzhou.aliyuncs.com\u002Fmodelscope-repo\u002Fmodelscope:ubuntu20.04-cuda11.7.1-py38-torch2.0.1-tf1.15.5-1.8.1\n# 针对海外用户：\ndocker pull registry.us-west-1.aliyuncs.com\u002Fmodelscope-repo\u002Fmodelscope:ubuntu20.04-cuda11.7.1-py38-torch2.0.1-tf1.15.5-1.8.1\n\n# 第三步：运行 Docker 容器\ndocker run -it --name facechain -p 7860:7860 --gpus all registry.cn-hangzhou.aliyuncs.com\u002Fmodelscope-repo\u002Fmodelscope:ubuntu20.04-cuda11.7.1-py38-torch2.0.1-tf1.15.5-1.8.1 \u002Fbin\u002Fbash\n# 注意：您可能需要安装 nvidia-container-runtime，具体操作如下：\n# 1. 安装 nvidia-container-runtime：https:\u002F\u002Fdocs.nvidia.com\u002Fdatacenter\u002Fcloud-native\u002Fcontainer-toolkit\u002Flatest\u002Finstall-guide.html\n# 2. sudo systemctl restart docker\n\n# 第四步：在 Docker 容器内安装 Gradio：\npip3 install gradio==3.47.1\npip3 install controlnet_aux==0.0.6\npip3 install python-slugify\npip3 install diffusers==0.29.0\npip3 install peft==0.11.1\npip3 install modelscope -U\npip3 install datasets==2.16\n\n# 第五步：从 GitHub 克隆 FaceChain\nGIT_LFS_SKIP_SMUDGE=1 git clone https:\u002F\u002Fgithub.com\u002Fmodelscope\u002Ffacechain.git --depth 1\ncd facechain\npython3 app.py\n# 注意：FaceChain 目前假设为单 GPU，如果您的环境有多个 GPU，请改用以下命令：\n# CUDA_VISIBLE_DEVICES=0 python3 app.py\n\n# 第六步\n运行应用服务器：点击“公共 URL”--> 形式为：https:\u002F\u002Fxxx.gradio.live\n```\n\n### 3. stable-diffusion-webui\n\n1. 选择“扩展选项卡”，然后选择“从 URL 安装”（官方插件集成已整合，目前请从 URL 安装）。\n   ![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmodelscope_facechain_readme_5b272b6a430d.png)\n\n2. 切换到“已安装”，勾选 FaceChain 插件，然后点击“应用并重启 UI”。安装依赖和下载模型可能需要一些时间。请确保正确安装了“CUDA Toolkit”，否则无法成功安装“mmcv”包。\n   ![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmodelscope_facechain_readme_f6324874beed.png)\n\n3. 页面刷新后，若出现“FaceChain”选项卡，则表示安装成功。\n   ![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmodelscope_facechain_readme_31511fe4388a.jpg)\n\n# 脚本执行\n\nFaceChain 支持在 Python 环境中直接推理。在进行无限风格人像生成推理时，请编辑 run_inference.py 中的代码：\n\n```python\n# 使用姿态控制，默认为 False\nuse_pose_model = False\n# 包含人像生成 ID 信息的输入图像路径\ninput_img_path = 'poses\u002Fman\u002Fpose2.png'\n# 姿态控制图像的路径，仅在使用姿态控制时有效\npose_image = 'poses\u002Fman\u002Fpose1.png'\n# 推理时生成的图像数量\nnum_generate = 5\n# 风格模型的权重，详情请参见 styles\nmultiplier_style = 0.25\n# 指定保存生成图像的文件夹，可根据需要修改此参数\noutput_dir = '.\u002Fgenerated'\n# 所选基础模型的索引，详情请参见 facechain\u002Fconstants.py\nbase_model_idx = 0\n# 风格模型的索引，详情请参见 styles\nstyle_idx = 0\n```\n\n然后执行：\n\n```shell\npython run_inference.py\n```\n\n您可以在 `output_dir` 中找到生成的个人数字图像照片。\n\n在进行固定模板人像生成推理时，请编辑 run_inference_inpaint.py 中的代码。\n\n```python\n# 模板图像中的人脸数量\nnum_faces = 1\n# 用于修复的人脸索引，从左至右计数\nselected_face = 1\n# 修复强度，无需更改此参数\nstrength = 0.6\n# 模板图像的路径\ninpaint_img = 'poses\u002Fman\u002Fpose1.png'\n# 包含人像生成 ID 信息的输入图像路径\ninput_img_path = 'poses\u002Fman\u002Fpose2.png'\n# 推理时生成的图像数量\nnum_generate = 1\n\n# 指定保存生成图像的文件夹，此参数可根据需要修改\noutput_dir = '.\u002Fgenerated_inpaint'\n```\n\n然后执行：\n\n```shell\npython run_inference_inpaint.py\n```\n\n您可以在 `output_dir` 文件夹中找到生成的个人数字图像照片。\n\n\n# 算法介绍\n\nAI人像生成的能力源自于像 Stable Diffusion 这样的大型生成模型及其微调技术。由于大型模型具有强大的泛化能力，因此可以通过在特定类型的数据和任务上进行微调来完成下游任务，同时保持模型整体的文本理解与图像生成能力。基于训练与无训练的 AI 人像生成技术基础在于将不同的微调任务应用于生成模型。目前，大多数现有的 AI 人像工具都采用“先训练后生成”的两阶段流程，其中微调任务是“生成固定角色 ID 的人像照片”，对应的训练数据则是该固定角色 ID 的多张图像。这种基于训练的流程效果取决于训练数据的规模，因此需要一定的图像数据支持和较长的训练时间，这也增加了用户的使用成本。\n\n与基于训练的流程不同，无训练的流程将微调任务调整为“生成指定角色 ID 的人像照片”，即以角色 ID 图像（人脸照片）作为额外输入，输出则是一张保留输入 ID 的人像照片。这种流程将离线训练与在线推理完全分离，用户只需一张照片即可在短短 10 秒内直接基于微调后的模型生成人像，从而避免了大量数据和长时间训练所带来的成本。无训练 AI 人像生成的微调任务基于适配器模块。人脸照片通过一个权重固定的图像编码器和一个参数高效的特征投影层进行处理，以获得对齐的特征，随后通过类似于文本条件的注意力机制输入到 Stable Diffusion 的 U-Net 模型中。此时，人脸信息作为独立的分支条件与文本信息一同输入模型进行推理，从而使生成的图像能够保持 ID 的保真度。\n\n基于人脸适配器的基本算法已经可以实现无训练的 AI 人像生成，但为了进一步提升其效果，仍需进行一些调整。现有的无训练人像工具普遍存在以下问题：人像图像质量较差、人像中的文本跟随与风格保留能力不足、人像面部的可控性和丰富性欠佳，以及与 ControlNet 和风格 Lora 等扩展的兼容性较差。为了解决这些问题，FaceChain 认为现有无训练 AI 人像工具的微调任务耦合了过多超出角色 ID 的信息，并提出了 FaceChain 人脸适配器解耦训练（FaceChain FACT），以解决上述问题。通过在数百万张人像数据上对 Stable Diffusion 模型进行微调，FaceChain FACT 能够实现针对指定角色 ID 的高质量人像生成。FaceChain FACT 的整个框架如下图所示。\n\n![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmodelscope_facechain_readme_6f343bebbbd2.png)\n\nFaceChain FACT 的解耦训练包含两个部分：人脸与图像的解耦，以及 ID 与人脸的解耦。现有方法通常将去噪人像图像作为微调任务，这使得模型难以准确聚焦于人脸区域，从而影响基础 Stable Diffusion 模型的文生图能力。FaceChain FACT 借鉴了换脸算法的顺序处理与区域控制优势，从结构和训练策略两方面实现了人脸与图像解耦的微调方法。在结构上，不同于现有方法采用并行交叉注意力机制处理人脸与文本信息，FaceChain FACT 采用了顺序处理的方式，将一个独立的适配器层插入到原 Stable Diffusion 的各个模块中。这样一来，人脸适配就成为去噪过程中类似换脸的一个独立步骤，避免了人脸与文本条件之间的相互干扰。在训练策略上，除了原有的 MSE 损失函数外，FaceChain FACT 还引入了人脸适配增量正则化（FAIR）损失函数，通过控制适配器层中人脸适配步骤的特征增量，使其更加专注于人脸区域。在推理时，用户可以通过调整人脸适配器的权重灵活地调节生成效果，在保持 Stable Diffusion 文生图能力的同时，平衡人脸的保真度与泛化能力。FAIR 损失函数的公式如下：\n\n![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmodelscope_facechain_readme_b9cdbba71c7c.png)\n\n此外，针对生成人脸的可控性和丰富性较差的问题，FaceChain FACT 提出了 ID 与人脸解耦的训练方法，使整个人像生成过程仅保留角色 ID 而非完整的人脸。首先，为了更好地从人脸中提取 ID 信息并保留某些关键的面部细节，同时更好地适配 Stable Diffusion 的结构，FaceChain FACT 采用了一种名为 [TransFace](https:\u002F\u002Fgithub.com\u002FDanJun6737\u002FTransFace) 的基于 Transformer 架构的人脸特征提取器，该模型已在大规模人脸数据集上进行了预训练。随后，将倒数第二层的所有 token 输入到一个简单的注意力查询模型中进行特征投影，从而确保提取出的 ID 特征符合上述要求。另外，在训练过程中，FaceChain FACT 还使用分类器自由引导（CFG）方法对同一 ID 的不同人像图像进行随机打乱与丢弃，这样就能保证用于去噪的输入人脸图像与目标图像可能来自不同但具有相同 ID 的人脸，从而进一步防止模型过度拟合人脸的非 ID 信息。因此，FaceChain FACT 具有与 FaceChain 大量精美风格的高度兼容性，具体表现如下。\n\n![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmodelscope_facechain_readme_c6b2a23146f9.png)\n\n## 模型列表\n\nFaceChain 中使用的模型：\n\n[1]  人脸识别模型 TransFace：https:\u002F\u002Fwww.modelscope.cn\u002Fmodels\u002Fiic\u002Fcv_vit_face-recognition\n\n[2]  人脸检测模型 DamoFD：https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002Fdamo\u002Fcv_ddsar_face-detection_iclr23-damofd\n\n[3]  人体分割模型 M2FP：https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002Fdamo\u002Fcv_resnet101_image-multiple-human-parsing\n\n[4]  美肤修复模型 ABPN：https:\u002F\u002Fwww.modelscope.cn\u002Fmodels\u002Fdamo\u002Fcv_unet_skin_retouching_torch\n\n[5]  人脸融合模型：https:\u002F\u002Fwww.modelscope.cn\u002Fmodels\u002Fdamo\u002Fcv_unet_face_fusion_torch\n\n[6]  FaceChain FACT 模型：https:\u002F\u002Fwww.modelscope.cn\u002Fmodels\u002Fyucheng1996\u002FFaceChain-FACT\n\n[7]  人脸属性识别模型 FairFace：https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002Fdamo\u002Fcv_resnet34_face-attribute-recognition_fairface\n\n\n# 更多信息\n\n- [ModelScope 库](https:\u002F\u002Fgithub.com\u002Fmodelscope\u002Fmodelscope\u002F)\n\n\n​        ModelScope 库为构建 ModelScope 的模型生态系统提供了基础，包括将各类模型集成到 ModelScope 的接口与实现。\n\n- [向 ModelScope 贡献模型](https:\u002F\u002Fmodelscope.cn\u002Fdocs\u002FModelScope%E6%A8%A1%E5%9E%8B%E6%8E%A5%E5%85%A5%E6%B5%81%E7%A8%8B%E6%A6%82%E8%A7%88)\n\n# 许可证\n\n本项目采用 [Apache 许可证（版本 2.0）](https:\u002F\u002Fgithub.com\u002Fmodelscope\u002Fmodelscope\u002Fblob\u002Fmaster\u002FLICENSE) 许可。","# FaceChain 快速上手指南\n\n## 环境准备\n\n### 系统要求\n- 操作系统：Ubuntu 20.04 \u002F CentOS 7.9\n- Python 版本：3.8 或 3.10\n- PyTorch 版本：2.0.0 或 2.0.1\n- CUDA 版本：11.7\n- CUDNN 版本：8+\n- GPU：Nvidia A10 24G（推荐）\n\n### 前置依赖\n- 安装 Jemalloc 可优化内存使用，将内存从超过 30G 降低至低于 20G：\n  ```shell\n  apt-get install -y libjemalloc-dev\n  export LD_PRELOAD=\u002Flib\u002Fx86_64-linux-gnu\u002Flibjemalloc.so\n  ```\n\n---\n\n## 安装步骤\n\n### 方法一：ModelScope Notebook（推荐）\n\n1. 登录 [ModelScope Notebook](https:\u002F\u002Fmodelscope.cn\u002Fmy\u002Fmynotebook\u002Fpreset)，选择 `PAI-DSW` 的 GPU 环境。\n   - 推荐镜像：`ubuntu20.04-py38-torch2.0.1-tf1.15.5-modelscope1.8.1`\n\n2. 在 Notebook 中执行以下命令：\n\n```shell\n# Step1: 克隆 FaceChain 仓库\n!GIT_LFS_SKIP_SMUDGE=1 git clone https:\u002F\u002Fgithub.com\u002Fmodelscope\u002Ffacechain.git --depth 1\n\n# Step2: 进入 facechain 目录并安装依赖\nimport os\nos.chdir('\u002Fmnt\u002Fworkspace\u002Ffacechain')    # 根据实际路径修改\nprint(os.getcwd())\n\n!pip3 install gradio==3.47.1\n!pip3 install controlnet_aux==0.0.6\n!pip3 install python-slugify\n!pip3 install diffusers==0.29.0\n!pip3 install peft==0.11.1\n!pip3 install modelscope -U\n!pip3 install datasets==2.16\n\n# Step3: 启动应用服务\n!python3 app.py\n```\n\n3. 启动后通过提供的 URL 访问 Gradio 界面，上传图片即可生成数字人肖像。\n\n---\n\n### 方法二：Docker（适合熟悉 Docker 的用户）\n\n1. 准备支持 GPU 的本地或云环境，推荐使用阿里云 ECS。\n\n2. 下载 Docker 镜像（国内用户）：\n\n```shell\ndocker pull registry.cn-hangzhou.aliyuncs.com\u002Fmodelscope-repo\u002Fmodelscope:ubuntu20.04-cuda11.7.1-py38-torch2.0.1-tf1.15.5-1.8.1\n```\n\n3. 启动容器：\n\n```shell\ndocker run -it --name facechain -p 7860:7860 --gpus all registry.cn-hangzhou.aliyuncs.com\u002Fmodelscope-repo\u002Fmodelscope:ubuntu20.04-cuda11.7.1-py38-torch2.0.1-tf1.15.5-1.8.1 \u002Fbin\u002Fbash\n```\n\n4. 安装依赖并启动应用：\n\n```shell\npip3 install gradio==3.47.1\npip3 install controlnet_aux==0.0.6\npip3 install python-slugify\npip3 install diffusers==0.29.0\npip3 install peft==0.11.1\npip3 install modelscope -U\npip3 install datasets==2.16\n\nGIT_LFS_SKIP_SMUDGE=1 git clone https:\u002F\u002Fgithub.com\u002Fmodelscope\u002Ffacechain.git --depth 1\ncd facechain\npython3 app.py\n```\n\n---\n\n### 方法三：stable-diffusion-webui 插件安装\n\n1. 打开 stable-diffusion-webui 的 `Extensions Tab`，选择 `Install From URL`，输入 FaceChain 插件地址进行安装。\n\n2. 安装完成后，在 `Installed` 页面中启用 FaceChain 插件，并重启 UI。\n\n3. 页面刷新后，若出现 `FaceChain` 标签页，则表示安装成功。\n\n---\n\n## 基本使用（最简单的使用示例）\n\n### 使用 Gradio 界面生成数字人肖像\n\n1. 启动 FaceChain 应用后，访问提供的 Gradio 网页链接（如：https:\u002F\u002Fxxx.gradio.live）。\n\n2. 上传一张人脸照片，选择风格、分辨率等参数，点击生成按钮。\n\n3. 等待约 10 秒，即可看到生成的个性化肖像。\n\n### 使用 Python 脚本生成（以 Infinite Style Portrait 为例）\n\n编辑 `run_inference.py` 文件，设置如下参数：\n\n```python\n# 是否使用姿态控制，默认为 False\nuse_pose_model = False\n# 输入图像路径\ninput_image_path = 'your_image.jpg'\n# 输出图像路径\noutput_image_path = 'generated_image.png'\n```\n\n然后运行脚本：\n\n```shell\npython3 run_inference.py\n```\n\n---\n\n> 📌 提示：如果需要更详细的配置或自定义训练，请参考项目中的文档和论文。","某影视公司特效团队正在为一部历史题材的电视剧制作虚拟角色，需要根据演员的照片生成多个不同风格的数字分身，用于不同场景和年代的演绎。\n\n### 没有 facechain 时\n- 需要依赖专业3D建模师手动创建每个角色的数字分身，耗时且成本高昂。\n- 无法快速生成多种风格的虚拟形象，导致角色设计周期长、灵活性差。\n- 对于非专业人员来说，缺乏直观的操作界面，学习成本高。\n- 生成的图像质量不稳定，难以保持角色身份的一致性。\n- 缺乏自动化流程，每次生成都需要重新训练模型或调整参数。\n\n### 使用 facechain 后\n- 只需上传一张演员照片，即可在10秒内生成多个风格各异的高质量数字分身。\n- 支持一键调用多种风格模板，极大提升了角色设计的效率与多样性。\n- 提供了用户友好的Gradio界面，非技术人员也能轻松操作。\n- 生成的图像保持高度一致性，确保角色身份特征不被破坏。\n- 自动化流程减少了人工干预，显著降低了开发和制作成本。\n\nFaceChain 通过高效、灵活和易用的特性，大幅提升了影视特效团队在虚拟角色生成方面的生产力与创意实现能力。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmodelscope_facechain_1db1b2b1.png","modelscope","ModelScope","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fmodelscope_66a27ef8.png","Model-as-a-Service in the making: bring accessible AI to all.",null,"contact@modelscope.cn","https:\u002F\u002Fwww.modelscope.cn\u002F","https:\u002F\u002Fgithub.com\u002Fmodelscope",[84,88,92,96],{"name":85,"color":86,"percentage":87},"Jupyter Notebook","#DA5B0B",79,{"name":89,"color":90,"percentage":91},"Python","#3572A5",20.7,{"name":93,"color":94,"percentage":95},"CSS","#663399",0.2,{"name":97,"color":98,"percentage":99},"Shell","#89e051",0.1,9500,889,"2026-04-04T17:29:57","Apache-2.0","Ubuntu 20.04, CentOS 7.9","需要 NVIDIA GPU（如 A10 24G），显存 8GB+，CUDA 11.7+","建议 16GB+（使用 Jemalloc 可优化内存至 20GB 以下）",{"notes":108,"python":109,"dependencies":110},"推荐使用 ModelScope Notebook 或 Docker 部署，首次运行需下载约 5GB 模型文件。建议安装 Jemalloc 以优化内存使用。","3.8, 3.10",[111,112,113,114,115,75,116,117],"torch>=2.0.0","gradio==3.47.1","controlnet_aux==0.0.6","diffusers==0.29.0","peft==0.11.1","datasets==2.16","python-slugify",[14,13,54],"2026-03-27T02:49:30.150509","2026-04-06T06:56:48.665362",[122,127,132,137,142,147],{"id":123,"question_zh":124,"answer_zh":125,"source_url":126},5805,"如何解决模型下载超时导致的 metadata.jsonl 文件找不到问题？","1. 设置环境变量 `export MODELSCOPE_CACHE=\u002Ffacechain\u002Fmodels`；2. 修改 timeout 设置，路径为 `\u002Fopt\u002Fconda\u002Flib\u002Fpython3.8\u002Fsite-packages\u002Fmodelscope\u002Fhub\u002Fconstants.py`。","https:\u002F\u002Fgithub.com\u002Fmodelscope\u002Ffacechain\u002Fissues\u002F161",{"id":128,"question_zh":129,"answer_zh":130,"source_url":131},5806,"安装 facechain 时出现 mmcv-full 安装失败的问题如何解决？","请先确保 pip 安装 mmcv-full 成功，然后重新安装 facechain 插件。此外，在 Windows 上需要启用 UTF-8 全局语言支持（在语言设置中启用 Beta 功能并重启系统）。","https:\u002F\u002Fgithub.com\u002Fmodelscope\u002Ffacechain\u002Fissues\u002F514",{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},5807,"如何解决图片显示不出来的问题？","请拉取最新代码并再次尝试。该问题已在 Pull Request #164 中提出并合并。","https:\u002F\u002Fgithub.com\u002Fmodelscope\u002Ffacechain\u002Fissues\u002F163",{"id":138,"question_zh":139,"answer_zh":140,"source_url":141},5808,"如何本地加载模型以避免依赖网络下载？","可以通过设置环境变量 `env MODELSCOPE_CACHE=\u002Froot\u002F.cache\u002Fmodelscope` 并在容器启动时映射该目录实现本地加载。默认下载地址为 `~\u002F.cache\u002Fmodelscope`。","https:\u002F\u002Fgithub.com\u002Fmodelscope\u002Ffacechain\u002Fissues\u002F78",{"id":143,"question_zh":144,"answer_zh":145,"source_url":146},5809,"CUDA 12.2 是否兼容 facechain 的部署要求？","建议使用与项目兼容的 CUDA 版本（如 CUDA 11.7）。如果使用 CUDA 12.2，可能会遇到 torch 或 mmcv-full 安装失败的问题。可参考相关教程调整环境配置。","https:\u002F\u002Fgithub.com\u002Fmodelscope\u002Ffacechain\u002Fissues\u002F22",{"id":148,"question_zh":149,"answer_zh":150,"source_url":146},5810,"如何解决 mmcv-full 安装卡住的问题？","尝试卸载当前 torch，安装与显卡匹配的版本；或重装 numpy；最后可以尝试通过 pip 安装 mmcv-full。具体方法可参考相关技术博客。",[152,157,162,167],{"id":153,"version":154,"summary_zh":155,"released_at":156},105448,"v2.0.0","\r\n- Fix lora training issue\r\n- Fix dataset loading issue","2023-12-19T17:41:05",{"id":158,"version":159,"summary_zh":160,"released_at":161},105449,"v1.2.0","# 中文版本\r\n\r\n## 功能列表\r\n\r\n- 增加虚拟试衣模块，可基于包含给定服饰的模特图或人台图进行重绘\r\n- 增加万相版本[在线免费应用](https:\u002F\u002Ftongyi.aliyun.com\u002Fwanxiang\u002Fapp\u002Fportrait-gallery). (2023-10-26)\r\n- stable-diffusion-webui支持\r\n\r\n## BugFix\r\n- 修复Gradio的一些体验问题\r\n\r\n\r\n# English Version\r\n\r\n## Feature\r\n- Add virtual try-on module\r\n- Add wanx version [online free app](https:\u002F\u002Ftongyi.aliyun.com\u002Fwanxiang\u002Fapp\u002Fportrait-gallery)\r\n- Support FaceChain in stable-diffusion-webui\r\n\r\n\r\n## BugFix\r\n- Fix some bugs of Gradio UI\r\n\r\n","2023-10-30T12:29:29",{"id":163,"version":164,"summary_zh":165,"released_at":166},105450,"v1.1.0","\r\nAdapt envs for ModelScope studio","2023-10-30T12:13:16",{"id":168,"version":169,"summary_zh":170,"released_at":171},105451,"v1.0.0","# 中文版本\r\n\r\n\r\n## 功能列表\r\n\r\n- 提供基于Gradio的服务\r\n- 现成风格模型即插即用\r\n- 支持个性化prompt模块\r\n\r\n## BugFix\r\n- 暂无\r\n\r\n# English Version\r\n\r\n## Feature\r\n- Init service based on Gradio\r\n- Support a series of new style models in a plug-and-play fashion\r\n- Support customizable prompts\r\n\r\n\r\n## BugFix\r\n- NA\r\n","2023-09-07T07:01:33"]