[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-tencent-ailab--IP-Adapter":3,"tool-tencent-ailab--IP-Adapter":62},[4,18,26,35,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},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,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108322,2,"2026-04-10T11:39:34",[14,15,13],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":32,"last_commit_at":41,"category_tags":42,"status":17},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[43,13,15,14],"插件",{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":10,"last_commit_at":50,"category_tags":51,"status":17},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,"2026-04-06T11:19:32",[52,15,13,14],"语言模型",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":10,"last_commit_at":59,"category_tags":60,"status":17},4292,"Deep-Live-Cam","hacksider\u002FDeep-Live-Cam","Deep-Live-Cam 是一款专注于实时换脸与视频生成的开源工具，用户仅需一张静态照片，即可通过“一键操作”实现摄像头画面的即时变脸或制作深度伪造视频。它有效解决了传统换脸技术流程繁琐、对硬件配置要求极高以及难以实时预览的痛点，让高质量的数字内容创作变得触手可及。\n\n这款工具不仅适合开发者和技术研究人员探索算法边界，更因其极简的操作逻辑（仅需三步：选脸、选摄像头、启动），广泛适用于普通用户、内容创作者、设计师及直播主播。无论是为了动画角色定制、服装展示模特替换，还是制作趣味短视频和直播互动，Deep-Live-Cam 都能提供流畅的支持。\n\n其核心技术亮点在于强大的实时处理能力，支持口型遮罩（Mouth Mask）以保留使用者原始的嘴部动作，确保表情自然精准；同时具备“人脸映射”功能，可同时对画面中的多个主体应用不同面孔。此外，项目内置了严格的内容安全过滤机制，自动拦截涉及裸露、暴力等不当素材，并倡导用户在获得授权及明确标注的前提下合规使用，体现了技术发展与伦理责任的平衡。",88924,"2026-04-06T03:28:53",[14,15,13,61],"视频",{"id":63,"github_repo":64,"name":65,"description_en":66,"description_zh":67,"ai_summary_zh":67,"readme_en":68,"readme_zh":69,"quickstart_zh":70,"use_case_zh":71,"hero_image_url":72,"owner_login":73,"owner_name":74,"owner_avatar_url":75,"owner_bio":76,"owner_company":77,"owner_location":74,"owner_email":74,"owner_twitter":74,"owner_website":78,"owner_url":79,"languages":80,"stars":89,"forks":90,"last_commit_at":91,"license":92,"difficulty_score":10,"env_os":93,"env_gpu":94,"env_ram":93,"env_deps":95,"category_tags":104,"github_topics":74,"view_count":32,"oss_zip_url":74,"oss_zip_packed_at":74,"status":17,"created_at":106,"updated_at":107,"faqs":108,"releases":138},7008,"tencent-ailab\u002FIP-Adapter","IP-Adapter","The image prompt adapter is designed to enable a pretrained text-to-image diffusion model to generate images with image prompt. ","IP-Adapter 是一款专为文生图扩散模型设计的轻量级插件，它让 AI 不仅能听懂文字描述，还能直接“看懂”参考图片并生成风格或内容相似的新图像。传统方法往往需要耗费大量算力对模型进行整体微调才能具备识图能力，而 IP-Adapter 巧妙地在冻结的预训练模型旁挂载了一个仅含 2200 万参数的小型适配器，以极低的资源成本实现了同等甚至更优的图像提示效果。\n\n这一设计有效解决了多模态生成中参考图融合难、计算成本高以及兼容性差的痛点。用户只需提供一张图片作为提示，即可精准控制生成结果的特征，同时还能将图像提示与文字提示灵活结合，实现更丰富的创意表达。此外，它不仅适用于基础模型，还能无缝迁移到各类基于同一底座微调的定制模型中，并支持与现有可控生成工具协同工作。\n\n凭借高效、灵活且易于集成的特性，IP-Adapter 非常适合开发者快速构建应用、研究人员探索多模态算法，以及设计师和普通创作者在日常工作中利用参考图进行辅助创作。其独特的轻量化架构和广泛的生态支持（如 Diffusers、WebUI 和 ComfyUI），使其成为当前连接文本与视觉创意的桥梁型工具。","# ___***IP-Adapter: Text Compatible Image Prompt Adapter for Text-to-Image Diffusion Models***___\n\n\u003Ca href='https:\u002F\u002Fip-adapter.github.io'>\u003Cimg src='https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FProject-Page-green'>\u003C\u002Fa> \n\u003Ca href='https:\u002F\u002Farxiv.org\u002Fabs\u002F2308.06721'>\u003Cimg src='https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FTechnique-Report-red'>\u003C\u002Fa> \n\u003Ca href='https:\u002F\u002Fhuggingface.co\u002Fh94\u002FIP-Adapter'>\u003Cimg src='https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F%F0%9F%A4%97%20Hugging%20Face-Model-blue'>\u003C\u002Fa>\n[![GitHub](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fstars\u002Ftencent-ailab\u002FIP-Adapter?style=social)](https:\u002F\u002Fgithub.com\u002Ftencent-ailab\u002FIP-Adapter\u002F)\n\n\n---\n\n\n## Introduction\n\nwe present IP-Adapter, an effective and lightweight adapter to achieve image prompt capability for the pre-trained text-to-image diffusion models. An IP-Adapter with only 22M parameters can achieve comparable or even better performance to a fine-tuned image prompt model. IP-Adapter can be generalized not only to other custom models fine-tuned from the same base model, but also to controllable generation using existing controllable tools. Moreover, the image prompt can also work well with the text prompt to accomplish multimodal image generation.\n\n![arch](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_b99fcb524ad4.png)\n\n## Release\n- [2024\u002F01\u002F19] 🔥 Add IP-Adapter-FaceID-Portrait, more information can be found [here](https:\u002F\u002Fhuggingface.co\u002Fh94\u002FIP-Adapter-FaceID).\n- [2024\u002F01\u002F17] 🔥 Add an experimental version of IP-Adapter-FaceID-PlusV2 for SDXL, more information can be found [here](https:\u002F\u002Fhuggingface.co\u002Fh94\u002FIP-Adapter-FaceID).\n- [2024\u002F01\u002F04] 🔥 Add an experimental version of IP-Adapter-FaceID for SDXL, more information can be found [here](https:\u002F\u002Fhuggingface.co\u002Fh94\u002FIP-Adapter-FaceID).\n- [2023\u002F12\u002F29] 🔥 Add an experimental version of IP-Adapter-FaceID-PlusV2, more information can be found [here](https:\u002F\u002Fhuggingface.co\u002Fh94\u002FIP-Adapter-FaceID).\n- [2023\u002F12\u002F27] 🔥 Add an experimental version of IP-Adapter-FaceID-Plus, more information can be found [here](https:\u002F\u002Fhuggingface.co\u002Fh94\u002FIP-Adapter-FaceID).\n- [2023\u002F12\u002F20] 🔥 Add an experimental version of IP-Adapter-FaceID, more information can be found [here](https:\u002F\u002Fhuggingface.co\u002Fh94\u002FIP-Adapter-FaceID).\n- [2023\u002F11\u002F22] IP-Adapter is available in [Diffusers](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdiffusers\u002Fpull\u002F5713) thanks to Diffusers Team.\n- [2023\u002F11\u002F10] 🔥 Add an updated version of IP-Adapter-Face. The demo is [here](ip_adapter-full-face_demo.ipynb).\n- [2023\u002F11\u002F05] 🔥 Add text-to-image [demo](ip_adapter_t2i_demo.ipynb) with IP-Adapter and [Kandinsky 2.2 Prior](https:\u002F\u002Fhuggingface.co\u002Fkandinsky-community\u002Fkandinsky-2-2-prior)\n- [2023\u002F11\u002F02] Support [safetensors](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fsafetensors)\n- [2023\u002F9\u002F08] 🔥 Update a new version of IP-Adapter with SDXL_1.0. More information can be found [here](#sdxl_10).\n- [2023\u002F9\u002F05] 🔥🔥🔥 IP-Adapter is supported in [WebUI](https:\u002F\u002Fgithub.com\u002FMikubill\u002Fsd-webui-controlnet\u002Fdiscussions\u002F2039) and [ComfyUI](https:\u002F\u002Fgithub.com\u002Flaksjdjf\u002FIPAdapter-ComfyUI) (or [ComfyUI_IPAdapter_plus](https:\u002F\u002Fgithub.com\u002Fcubiq\u002FComfyUI_IPAdapter_plus)).\n- [2023\u002F8\u002F30] 🔥 Add an IP-Adapter with face image as prompt. The demo is [here](ip_adapter-plus-face_demo.ipynb).\n- [2023\u002F8\u002F29] 🔥 Release the training code.\n- [2023\u002F8\u002F23] 🔥 Add code and models of IP-Adapter with fine-grained features. The demo is [here](ip_adapter-plus_demo.ipynb).\n- [2023\u002F8\u002F18] 🔥 Add code and models for [SDXL 1.0](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-base-1.0). The demo is [here](ip_adapter_sdxl_demo.ipynb).\n- [2023\u002F8\u002F16] 🔥 We release the code and models.\n\n\n## Installation\n\n```\n# install latest diffusers\npip install diffusers==0.22.1\n\n# install ip-adapter\npip install git+https:\u002F\u002Fgithub.com\u002Ftencent-ailab\u002FIP-Adapter.git\n\n# download the models\ncd IP-Adapter\ngit lfs install\ngit clone https:\u002F\u002Fhuggingface.co\u002Fh94\u002FIP-Adapter\nmv IP-Adapter\u002Fmodels models\nmv IP-Adapter\u002Fsdxl_models sdxl_models\n\n# then you can use the notebook\n```\n\n## Download Models\n\nyou can download models from [here](https:\u002F\u002Fhuggingface.co\u002Fh94\u002FIP-Adapter). To run the demo, you should also download the following models:\n- [runwayml\u002Fstable-diffusion-v1-5](https:\u002F\u002Fhuggingface.co\u002Frunwayml\u002Fstable-diffusion-v1-5)\n- [stabilityai\u002Fsd-vae-ft-mse](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsd-vae-ft-mse)\n- [SG161222\u002FRealistic_Vision_V4.0_noVAE](https:\u002F\u002Fhuggingface.co\u002FSG161222\u002FRealistic_Vision_V4.0_noVAE)\n- [ControlNet models](https:\u002F\u002Fhuggingface.co\u002Flllyasviel)\n\n## How to Use\n\n### SD_1.5\n\n- [**ip_adapter_demo**](ip_adapter_demo.ipynb): image variations, image-to-image, and inpainting with image prompt.\n- [![**ip_adapter_demo**](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Ftencent-ailab\u002FIP-Adapter\u002Fblob\u002Fmain\u002Fip_adapter_demo.ipynb) \n\n![image variations](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_a3cd109c493d.jpg)\n\n![image-to-image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_fc12a0cf8ac5.jpg)\n\n![inpainting](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_9ea6b8e5966e.jpg)\n\n- [**ip_adapter_controlnet_demo**](ip_adapter_controlnet_demo_new.ipynb), [**ip_adapter_t2i-adapter**](ip_adapter_t2i-adapter_demo.ipynb): structural generation with image prompt.\n- [![**ip_adapter_controlnet_demo**](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Ftencent-ailab\u002FIP-Adapter\u002Fblob\u002Fmain\u002Fip_adapter_controlnet_demo.ipynb) \n\n![structural_cond](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_320273ca6c05.jpg)\n![structural_cond2](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_6af96fdb5e39.jpg)\n\n- [**ip_adapter_multimodal_prompts_demo**](ip_adapter_multimodal_prompts_demo.ipynb): generation with multimodal prompts.\n- [![**ip_adapter_multimodal_prompts_demo**](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Ftencent-ailab\u002FIP-Adapter\u002Fblob\u002Fmain\u002Fip_adapter_multimodal_prompts_demo.ipynb) \n\n![multi_prompts](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_c2f34eb7156c.jpg)\n\n- [**ip_adapter-plus_demo**](ip_adapter-plus_demo.ipynb): the demo of IP-Adapter with fine-grained features.\n\n![ip_adpter_plus_image_variations](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_efe0c0d37ce1.jpg)\n![ip_adpter_plus_multi](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_83277773bc0e.jpg)\n\n- [**ip_adapter-plus-face_demo**](ip_adapter-plus-face_demo.ipynb): generation with face image as prompt.\n\n![ip_adpter_plus_face](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_f1daa944c531.jpg)\n\n**Best Practice**\n- If you only use the image prompt, you can set the `scale=1.0` and `text_prompt=\"\"`(or some generic text prompts, e.g. \"best quality\", you can also use any negative text prompt). If you lower the `scale`, more diverse images can be generated, but they may not be as consistent with the image prompt.\n- For multimodal prompts, you can adjust the `scale` to get the best results. In most cases, setting `scale=0.5` can get good results. For the version of SD 1.5, we recommend using community models to generate good images.\n\n**IP-Adapter for non-square images**\n\nAs the image is center cropped in the default image processor of CLIP, IP-Adapter works best for square images. For the non square images, it will miss the information outside the center. But you can just resize to 224x224 for non-square images, the comparison is as follows:\n\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_1cae76af51c6.jpg)\n\n### SDXL_1.0\n\n- [**ip_adapter_sdxl_demo**](ip_adapter_sdxl_demo.ipynb): image variations with image prompt.\n- [**ip_adapter_sdxl_controlnet_demo**](ip_adapter_sdxl_controlnet_demo.ipynb): structural generation with image prompt.\n\nThe comparison of **IP-Adapter_XL** with [Reimagine XL](https:\u002F\u002Fclipdrop.co\u002Fstable-diffusion-reimagine) is shown as follows:\n\n![sdxl_demo](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_09b742b91c5f.jpg)\n\n**Improvements in new version (2023.9.8)**:\n- **Switch to CLIP-ViT-H**: we trained the new IP-Adapter with [OpenCLIP-ViT-H-14](https:\u002F\u002Fhuggingface.co\u002Flaion\u002FCLIP-ViT-H-14-laion2B-s32B-b79K) instead of [OpenCLIP-ViT-bigG-14](https:\u002F\u002Fhuggingface.co\u002Flaion\u002FCLIP-ViT-bigG-14-laion2B-39B-b160k). Although ViT-bigG is much larger than ViT-H, our experimental results did not find a significant difference, and the smaller model can reduce the memory usage in the inference phase.\n- **A Faster and better training recipe**: In our previous version, training directly at a resolution of 1024x1024 proved to be highly inefficient. However, in the new version, we have implemented a more effective two-stage training strategy. Firstly, we perform pre-training at a resolution of 512x512. Then, we employ a multi-scale strategy for fine-tuning. (Maybe this training strategy can also be used to speed up the training of controlnet).\n\n## How to Train\nFor training, you should install [accelerate](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Faccelerate) and make your own dataset into a json file.\n\n```\naccelerate launch --num_processes 8 --multi_gpu --mixed_precision \"fp16\" \\\n  tutorial_train.py \\\n  --pretrained_model_name_or_path=\"runwayml\u002Fstable-diffusion-v1-5\u002F\" \\\n  --image_encoder_path=\"{image_encoder_path}\" \\\n  --data_json_file=\"{data.json}\" \\\n  --data_root_path=\"{image_path}\" \\\n  --mixed_precision=\"fp16\" \\\n  --resolution=512 \\\n  --train_batch_size=8 \\\n  --dataloader_num_workers=4 \\\n  --learning_rate=1e-04 \\\n  --weight_decay=0.01 \\\n  --output_dir=\"{output_dir}\" \\\n  --save_steps=10000\n```\n\nOnce training is complete, you can convert the weights with the following code:\n\n```python\nimport torch\nckpt = \"checkpoint-50000\u002Fpytorch_model.bin\"\nsd = torch.load(ckpt, map_location=\"cpu\")\nimage_proj_sd = {}\nip_sd = {}\nfor k in sd:\n    if k.startswith(\"unet\"):\n        pass\n    elif k.startswith(\"image_proj_model\"):\n        image_proj_sd[k.replace(\"image_proj_model.\", \"\")] = sd[k]\n    elif k.startswith(\"adapter_modules\"):\n        ip_sd[k.replace(\"adapter_modules.\", \"\")] = sd[k]\n\ntorch.save({\"image_proj\": image_proj_sd, \"ip_adapter\": ip_sd}, \"ip_adapter.bin\")\n```\n\n## Third-party Usage\n- [IP-Adapter for WebUI](https:\u002F\u002Fgithub.com\u002FMikubill\u002Fsd-webui-controlnet) [[release notes](https:\u002F\u002Fgithub.com\u002FMikubill\u002Fsd-webui-controlnet\u002Fdiscussions\u002F2039)]\n- IP-Adapter for ComfyUI [[IPAdapter-ComfyUI](https:\u002F\u002Fgithub.com\u002Flaksjdjf\u002FIPAdapter-ComfyUI) or [ComfyUI_IPAdapter_plus](https:\u002F\u002Fgithub.com\u002Fcubiq\u002FComfyUI_IPAdapter_plus)]\n- [IP-Adapter for InvokeAI](https:\u002F\u002Fgithub.com\u002Finvoke-ai\u002FInvokeAI) [[release notes](https:\u002F\u002Fgithub.com\u002Finvoke-ai\u002FInvokeAI\u002Freleases\u002Ftag\u002Fv3.2.0)]\n- [IP-Adapter for AnimateDiff prompt travel](https:\u002F\u002Fgithub.com\u002Fs9roll7\u002Fanimatediff-cli-prompt-travel)\n- [Diffusers_IPAdapter](https:\u002F\u002Fgithub.com\u002Fcubiq\u002FDiffusers_IPAdapter): more features such as supporting multiple input images\n- [Official Diffusers ](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdiffusers\u002Fpull\u002F5713)\n- [InstantStyle](https:\u002F\u002Fgithub.com\u002FInstantStyle\u002FInstantStyle): Style transfer based on IP-Adapter\n\n## Disclaimer\n\nThis project strives to positively impact the domain of AI-driven image generation. Users are granted the freedom to create images using this tool, but they are expected to comply with local laws and utilize it in a responsible manner. **The developers do not assume any responsibility for potential misuse by users.**\n\n## Citation\nIf you find IP-Adapter useful for your research and applications, please cite using this BibTeX:\n```bibtex\n@article{ye2023ip-adapter,\n  title={IP-Adapter: Text Compatible Image Prompt Adapter for Text-to-Image Diffusion Models},\n  author={Ye, Hu and Zhang, Jun and Liu, Sibo and Han, Xiao and Yang, Wei},\n  booktitle={arXiv preprint arxiv:2308.06721},\n  year={2023}\n}\n```\n","# ___***IP-Adapter：文本兼容的图像提示适配器，用于文生图扩散模型***___\n\n\u003Ca href='https:\u002F\u002Fip-adapter.github.io'>\u003Cimg src='https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FProject-Page-green'>\u003C\u002Fa> \n\u003Ca href='https:\u002F\u002Farxiv.org\u002Fabs\u002F2308.06721'>\u003Cimg src='https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FTechnique-Report-red'>\u003C\u002Fa> \n\u003Ca href='https:\u002F\u002Fhuggingface.co\u002Fh94\u002FIP-Adapter'>\u003Cimg src='https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F%F0%9F%A4%97%20Hugging%20 Face-Model-blue'>\u003C\u002Fa>\n[![GitHub](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fstars\u002Ftencent-ailab\u002FIP-Adapter?style=social)](https:\u002F\u002Fgithub.com\u002Ftencent-ailab\u002FIP-Adapter\u002F)\n\n\n---\n\n\n## 简介\n\n我们提出了IP-Adapter，这是一种高效且轻量级的适配器，能够为预训练的文生图扩散模型赋予图像提示能力。仅需2200万参数的IP-Adapter，便能实现与经过微调的图像提示模型相当甚至更优的效果。IP-Adapter不仅可推广到基于同一基础模型微调的其他自定义模型，还能与现有的可控生成工具结合，实现可控生成任务。此外，图像提示还可以与文本提示协同工作，完成多模态图像生成。\n\n![arch](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_b99fcb524ad4.png)\n\n## 发布\n- [2024\u002F01\u002F19] 🔥 添加IP-Adapter-FaceID-Portrait，更多信息请见[这里](https:\u002F\u002Fhuggingface.co\u002Fh94\u002FIP-Adapter-FaceID)。\n- [2024\u002F01\u002F17] 🔥 为SDXL添加IP-Adapter-FaceID-PlusV2实验版本，更多信息请见[这里](https:\u002F\u002Fhuggingface.co\u002Fh94\u002FIP-Adapter-FaceID)。\n- [2024\u002F01\u002F04] 🔥 为SDXL添加IP-Adapter-FaceID实验版本，更多信息请见[这里](https:\u002F\u002Fhuggingface.co\u002Fh94\u002FIP-Adapter-FaceID)。\n- [2023\u002F12\u002F29] 🔥 添加IP-Adapter-FaceID-PlusV2实验版本，更多信息请见[这里](https:\u002F\u002Fhuggingface.co\u002Fh94\u002FIP-Adapter-FaceID)。\n- [2023\u002F12\u002F27] 🔥 添加IP-Adapter-FaceID-Plus实验版本，更多信息请见[这里](https:\u002F\u002Fhuggingface.co\u002Fh94\u002FIP-Adapter-FaceID)。\n- [2023\u002F12\u002F20] 🔥 添加IP-Adapter-FaceID实验版本，更多信息请见[这里](https:\u002F\u002Fhuggingface.co\u002Fh94\u002FIP-Adapter-FaceID)。\n- [2023\u002F11\u002F22] 感谢Diffusers团队，IP-Adapter现已在[Diffusers](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdiffusers\u002Fpull\u002F5713)中可用。\n- [2023\u002F11\u002F10] 🔥 添加更新版IP-Adapter-Face。演示请见[ip_adapter-full-face_demo.ipynb]。\n- [2023\u002F11\u002F05] 🔥 添加使用IP-Adapter和[Kandinsky 2.2 Prior](https:\u002F\u002Fhuggingface.co\u002Fkandinsky-community\u002Fkandinsky-2-2-prior)的文生图[演示](ip_adapter_t2i_demo.ipynb)。\n- [2023\u002F11\u002F02] 支持[safetensors](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fsafetensors)。\n- [2023\u002F9\u002F08] 🔥 更新了适用于SDXL_1.0的新版IP-Adapter。更多信息请见[#sdxl_10]。\n- [2023\u002F9\u002F05] 🔥🔥🔥 IP-Adapter已在[WebUI](https:\u002F\u002Fgithub.com\u002FMikubill\u002Fsd-webui-controlnet\u002Fdiscussions\u002F2039)和[ComfyUI](https:\u002F\u002Fgithub.com\u002Flaksjdjf\u002FIPAdapter-ComfyUI)（或[ComfyUI_IPAdapter_plus](https:\u002F\u002Fgithub.com\u002Fcubiq\u002FComfyUI_IPAdapter_plus)）中得到支持。\n- [2023\u002F8\u002F30] 🔥 添加以人脸图像作为提示的IP-Adapter。演示请见[ip_adapter-plus-face_demo.ipynb]。\n- [2023\u002F8\u002F29] 🔥 发布训练代码。\n- [2023\u002F8\u002F23] 🔥 添加带有细粒度特征的IP-Adapter代码及模型。演示请见[ip_adapter-plus_demo.ipynb]。\n- [2023\u002F8\u002F18] 🔥 添加针对[SDXL 1.0](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-base-1.0)的代码和模型。演示请见[ip_adapter_sdxl_demo.ipynb]。\n- [2023\u002F8\u002F16] 🔥 我们发布了代码和模型。\n\n\n## 安装\n\n```\n# 安装最新版diffusers\npip install diffusers==0.22.1\n\n# 安装ip-adapter\npip install git+https:\u002F\u002Fgithub.com\u002Ftencent-ailab\u002FIP-Adapter.git\n\n# 下载模型\ncd IP-Adapter\ngit lfs install\ngit clone https:\u002F\u002Fhuggingface.co\u002Fh94\u002FIP-Adapter\nmv IP-Adapter\u002Fmodels models\nmv IP-Adapter\u002Fsdxl_models sdxl_models\n\n# 然后你就可以使用notebook了\n```\n\n## 下载模型\n\n你可以从[这里](https:\u002F\u002Fhuggingface.co\u002Fh94\u002FIP-Adapter)下载模型。要运行演示，你还需下载以下模型：\n- [runwayml\u002Fstable-diffusion-v1-5](https:\u002F\u002Fhuggingface.co\u002Frunwayml\u002Fstable-diffusion-v1-5)\n- [stabilityai\u002Fsd-vae-ft-mse](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsd-vae-ft-mse)\n- [SG161222\u002FRealistic_Vision_V4.0_noVAE](https:\u002F\u002Fhuggingface.co\u002FSG161222\u002FRealistic_Vision_V4.0_noVAE)\n- [ControlNet模型](https:\u002F\u002Fhuggingface.co\u002Flllyasviel)\n\n## 使用方法\n\n### SD_1.5\n\n- [**ip_adapter_demo**](ip_adapter_demo.ipynb): 基于图像提示的图像变体、图像到图像生成以及修复。\n- [![**ip_adapter_demo**](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Ftencent-ailab\u002FIP-Adapter\u002Fblob\u002Fmain\u002Fip_adapter_demo.ipynb) \n\n![图像变体](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_a3cd109c493d.jpg)\n\n![图像到图像](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_fc12a0cf8ac5.jpg)\n\n![修复](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_9ea6b8e5966e.jpg)\n\n- [**ip_adapter_controlnet_demo**](ip_adapter_controlnet_demo_new.ipynb), [**ip_adapter_t2i-adapter**](ip_adapter_t2i-adapter_demo.ipynb): 基于图像提示的结构化生成。\n- [![**ip_adapter_controlnet_demo**](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Ftencent-ailab\u002FIP-Adapter\u002Fblob\u002Fmain\u002Fip_adapter_controlnet_demo.ipynb) \n\n![结构条件](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_320273ca6c05.jpg)\n![结构条件2](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_6af96fdb5e39.jpg)\n\n- [**ip_adapter_multimodal_prompts_demo**](ip_adapter_multimodal_prompts_demo.ipynb): 多模态提示下的生成。\n- [![**ip_adapter_multimodal_prompts_demo**](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Ftencent-ailab\u002FIP-Adapter\u002Fblob\u002Fmain\u002Fip_adapter_multimodal_prompts_demo.ipynb) \n\n![多提示](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_c2f34eb7156c.jpg)\n\n- [**ip_adapter-plus_demo**](ip_adapter-plus_demo.ipynb): 具有细粒度特征的IP-Adapter演示。\n  \n![ip_adpter_plus_image_variations](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_efe0c0d37ce1.jpg)\n![ip_adpter_plus_multi](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_83277773bc0e.jpg)\n\n- [**ip_adapter-plus-face_demo**](ip_adapter-plus-face_demo.ipynb): 以人脸图像为提示的生成。\n\n![ip_adpter_plus_face](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_f1daa944c531.jpg)\n\n**最佳实践**\n- 如果仅使用图像提示，可以将`scale`设置为1.0，并将`text_prompt`留空（或使用一些通用文本提示，例如“最佳质量”），也可以使用任何负面文本提示。如果降低`scale`值，可以生成更多样化的图像，但这些图像可能与图像提示的一致性较差。\n- 对于多模态提示，可以通过调整`scale`来获得最佳效果。在大多数情况下，将`scale`设置为0.5即可获得不错的效果。对于SD 1.5版本，我们建议使用社区模型来生成高质量图像。\n\n**非正方形图像的IP-Adapter**\n\n由于CLIP默认的图像处理器会对图像进行中心裁剪，因此IP-Adapter最适合处理正方形图像。对于非正方形图像，中心区域之外的信息可能会丢失。不过，您可以将非正方形图像调整为224x224像素，对比效果如下：\n\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_1cae76af51c6.jpg)\n\n### SDXL_1.0\n\n- [**ip_adapter_sdxl_demo**](ip_adapter_sdxl_demo.ipynb): 基于图像提示的图像变体。\n- [**ip_adapter_sdxl_controlnet_demo**](ip_adapter_sdxl_controlnet_demo.ipynb): 基于图像提示的结构化生成。\n\n以下是**IP-Adapter_XL**与[Reimagine XL](https:\u002F\u002Fclipdrop.co\u002Fstable-diffusion-reimagine)的对比：\n\n![sdxl_demo](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_readme_09b742b91c5f.jpg)\n\n**新版本改进（2023年9月8日）**：\n- **切换至CLIP-ViT-H**：我们使用[OpenCLIP-ViT-H-14](https:\u002F\u002Fhuggingface.co\u002Flaion\u002FCLIP-ViT-H-14-laion2B-s32B-b79K)而非[OpenCLIP-ViT-bigG-14](https:\u002F\u002Fhuggingface.co\u002Flaion\u002FCLIP-ViT-bigG-14-laion2B-39B-b160k)训练了新的IP-Adapter。尽管ViT-bigG比ViT-H大得多，但我们的实验结果并未显示出显著差异，且较小的模型可以在推理阶段减少内存占用。\n- **更快速、更优的训练方案**：在之前的版本中，直接以1024x1024分辨率进行训练效率极低。而在新版本中，我们实施了一种更为有效的两阶段训练策略。首先，我们在512x512分辨率下进行预训练，随后采用多尺度策略进行微调。（这种训练策略或许也可用于加速ControlNet的训练）。\n\n## 如何训练\n进行训练时，您需要安装[accelerate](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Faccelerate)，并将自己的数据集转换为JSON文件。\n\n```\naccelerate launch --num_processes 8 --multi_gpu --mixed_precision \"fp16\" \\\n  tutorial_train.py \\\n  --pretrained_model_name_or_path=\"runwayml\u002Fstable-diffusion-v1-5\u002F\" \\\n  --image_encoder_path=\"{image_encoder_path}\" \\\n  --data_json_file=\"{data.json}\" \\\n  --data_root_path=\"{image_path}\" \\\n  --mixed_precision=\"fp16\" \\\n  --resolution=512 \\\n  --train_batch_size=8 \\\n  --dataloader_num_workers=4 \\\n  --learning_rate=1e-04 \\\n  --weight_decay=0.01 \\\n  --output_dir=\"{output_dir}\" \\\n  --save_steps=10000\n```\n\n训练完成后，您可以使用以下代码转换权重：\n\n```python\nimport torch\nckpt = \"checkpoint-50000\u002Fpytorch_model.bin\"\nsd = torch.load(ckpt, map_location=\"cpu\")\nimage_proj_sd = {}\nip_sd = {}\nfor k in sd:\n    if k.startswith(\"unet\"):\n        pass\n    elif k.startswith(\"image_proj_model\"):\n        image_proj_sd[k.replace(\"image_proj_model.\", \"\")] = sd[k]\n    elif k.startswith(\"adapter_modules\"):\n        ip_sd[k.replace(\"adapter_modules.\", \"\")] = sd[k]\n\ntorch.save({\"image_proj\": image_proj_sd, \"ip_adapter\": ip_sd}, \"ip_adapter.bin\")\n```\n\n## 第三方应用\n- [WebUI版IP-Adapter](https:\u002F\u002Fgithub.com\u002FMikubill\u002Fsd-webui-controlnet) [[发布说明](https:\u002F\u002Fgithub.com\u002FMikubill\u002Fsd-webui-controlnet\u002Fdiscussions\u002F2039)]\n- ComfyUI版IP-Adapter [[IPAdapter-ComfyUI](https:\u002F\u002Fgithub.com\u002Flaksjdjf\u002FIPAdapter-ComfyUI) 或 [ComfyUI_IPAdapter_plus](https:\u002F\u002Fgithub.com\u002Fcubiq\u002FComfyUI_IPAdapter_plus)]\n- [InvokeAI版IP-Adapter](https:\u002F\u002Fgithub.com\u002Finvoke-ai\u002FInvokeAI) [[发布说明](https:\u002F\u002Fgithub.com\u002Finvoke-ai\u002FInvokeAI\u002Freleases\u002Ftag\u002Fv3.2.0)]\n- [AnimateDiff提示旅行版IP-Adapter](https:\u002F\u002Fgithub.com\u002Fs9roll7\u002Fanimatediff-cli-prompt-travel)\n- [Diffusers_IPAdapter](https:\u002F\u002Fgithub.com\u002Fcubiq\u002FDiffusers_IPAdapter): 提供更多功能，如支持多张输入图像。\n- [官方Diffusers](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdiffusers\u002Fpull\u002F5713)\n- [InstantStyle](https:\u002F\u002Fgithub.com\u002FInstantStyle\u002FInstantStyle): 基于IP-Adapter的风格迁移。\n\n## 免责声明\n\n本项目致力于对AI驱动的图像生成领域产生积极影响。用户可以自由地使用此工具创作图像，但应遵守当地法律法规，并以负责任的方式使用。**开发者不对用户的任何潜在滥用行为承担责任。**\n\n## 引用\n如果您发现IP-Adapter对您的研究和应用有所帮助，请使用以下BibTeX格式引用：\n```bibtex\n@article{ye2023ip-adapter,\n  title={IP-Adapter: 文本兼容的图像提示适配器，适用于文生图扩散模型},\n  author={Ye, Hu and Zhang, Jun and Liu, Sibo and Han, Xiao and Yang, Wei},\n  booktitle={arXiv预印本 arxiv:2308.06721},\n  year={2023}\n}\n```","# IP-Adapter 快速上手指南\n\nIP-Adapter 是一个轻量级适配器，能让预训练的文本到图像扩散模型（如 Stable Diffusion）具备强大的“图像提示”（Image Prompt）能力。仅需 22M 参数，即可实现与微调模型相当甚至更优的效果，支持图像变体、重绘、结构控制及多模态生成。\n\n## 环境准备\n\n*   **系统要求**：Linux \u002F Windows \u002F macOS\n*   **Python 版本**：建议 Python 3.8+\n*   **GPU**：推荐 NVIDIA GPU（显存建议 8GB 以上，SDXL 需更大显存）\n*   **前置依赖**：\n    *   `git` 和 `git-lfs`（用于下载大模型文件）\n    *   `pip` 包管理工具\n\n> **注意**：国内用户建议在 `pip` 命令后添加 `-i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple` 以加速下载。\n\n## 安装步骤\n\n### 1. 安装核心依赖\n首先安装指定版本的 `diffusers` 库，然后安装 IP-Adapter 源码。\n\n```bash\n# install latest diffusers\npip install diffusers==0.22.1\n\n# install ip-adapter\npip install git+https:\u002F\u002Fgithub.com\u002Ftencent-ailab\u002FIP-Adapter.git\n```\n\n### 2. 下载模型文件\n使用 `git lfs` 克隆模型仓库并整理目录结构。\n\n```bash\ncd IP-Adapter\ngit lfs install\ngit clone https:\u002F\u002Fhuggingface.co\u002Fh94\u002FIP-Adapter\nmv IP-Adapter\u002Fmodels models\nmv IP-Adapter\u002Fsdxl_models sdxl_models\n```\n\n### 3. 下载基础底模\n运行 Demo 前，还需确保本地已下载以下基础模型（可通过 Hugging Face 或国内镜像站下载）：\n*   [runwayml\u002Fstable-diffusion-v1-5](https:\u002F\u002Fhuggingface.co\u002Frunwayml\u002Fstable-diffusion-v1-5)\n*   [stabilityai\u002Fsd-vae-ft-mse](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsd-vae-ft-mse)\n*   (可选) ControlNet 模型或其他社区微调模型（如 Realistic_Vision_V4.0）\n\n## 基本使用\n\n以下是最基础的 SD 1.5 图像变体生成示例。请确保已在当前目录下准备好 `models` 文件夹及对应的底模。\n\n### 代码示例 (`ip_adapter_demo.py`)\n\n```python\nimport torch\nfrom PIL import Image\nfrom diffusers import StableDiffusionPipeline\nfrom ip_adapter import IPAdapter\n\n# 1. 加载基础 SD 模型\nbase_model_path = \"runwayml\u002Fstable-diffusion-v1-5\"\nimage_encoder_path = \"models\u002Fimage_encoder\"\nip_ckpt = \"models\u002Fip-adapter_sd15.bin\" # 根据实际下载的文件名调整\n\ndevice = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n\n# 初始化 Pipeline\npipe = StableDiffusionPipeline.from_pretrained(\n    base_model_path,\n    torch_dtype=torch.float16,\n).to(device)\n\n# 2. 加载 IP-Adapter\nip_adapter = IPAdapter(pipe, image_encoder_path, ip_ckpt, device)\n\n# 3. 准备输入\nprompt = \"best quality, high resolution\" # 文本提示词可为空或通用词\nnegative_prompt = \"monochrome, lowres, bad anatomy, worst quality, low quality\"\nimage = Image.open(\"assets\u002Fdemo\u002Fsource_image.jpg\").convert(\"RGB\") # 替换为你的参考图路径\n\n# 4. 生成图像\n# scale: 控制图像提示词的权重。仅使用图像提示时设为 1.0；多模态混合时可尝试 0.5\ngenerator = torch.Generator(device=device).manual_seed(42)\nimages = ip_adapter.generate(\n    pil_image=image,\n    num_samples=1,\n    num_inference_steps=30,\n    seed=42,\n    prompt=prompt,\n    negative_prompt=negative_prompt,\n    scale=1.0, \n    generator=generator\n)\n\n# 5. 保存结果\nimages[0].save(\"output_result.jpg\")\nprint(\"生成完成！\")\n```\n\n### 使用建议\n*   **纯图像提示**：设置 `scale=1.0`，`text_prompt` 可留空或使用 \"best quality\" 等通用词。\n*   **多模态提示（图 + 文）**：建议调整 `scale` 参数（例如 `0.5`），以平衡图像特征与文本描述。\n*   **非正方形图片**：IP-Adapter 默认对图像进行中心裁剪。若参考图非正方形，建议先手动 Resize 至 224x224 再传入，以保留完整信息。","一位电商设计师需要为某品牌的新款运动鞋快速生成一系列营销海报，要求模特必须保持品牌代言人的特定面部特征，同时背景需根据“雪山”、“海滩”等不同文案灵活变换。\n\n### 没有 IP-Adapter 时\n- **重训成本高昂**：若要固定人物长相，通常需要对大模型进行 Dreambooth 微调或训练 LoRA，耗时数小时且需要大量该人物的多角度照片。\n- **风格迁移困难**：一旦更换背景描述（如从室内转到户外），微调后的模型容易出现过拟合，导致人物脸部崩坏或无法融入新环境。\n- **多模态控制割裂**：难以在同一生成过程中完美平衡“参考图的人物特征”与“文本提示词的场景描述”，往往顾此失彼。\n- **迭代效率低下**：每次调整人物细节或尝试新风格都需重新调整训练参数，无法满足紧急的营销上线需求。\n\n### 使用 IP-Adapter 后\n- **即插即用免训练**：仅需上传一张代言人照片作为图像提示（Image Prompt），IP-Adapter 即可在无需任何微调的情况下精准锁定人物面部特征。\n- **文图完美协同**：IP-Adapter 能让预训练的扩散模型同时理解图像提示和文本提示，轻松实现“保留特定人脸 + 自由切换雪山\u002F海滩背景”的多模态生成。\n- **通用性强**：同一个 IP-Adapter 插件可直接应用于基于同一基座模型微调出的各种风格化模型（如二次元、写实风），无需重复适配。\n- **轻量高效**：仅增加约 2200 万参数，推理速度几乎无损耗，设计师可在几分钟内产出数十张高质量变体图供筛选。\n\nIP-Adapter 通过轻量级的适配器架构，彻底打破了文本与图像提示的壁垒，让“指定人物 + 自由场景”的定制化图像生成变得像写提示词一样简单高效。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftencent-ailab_IP-Adapter_a3cd109c.jpg","tencent-ailab",null,"https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Ftencent-ailab_63b9101f.png","Research repositories. ","Tencent AI Lab","https:\u002F\u002Fai.tencent.com\u002F","https:\u002F\u002Fgithub.com\u002Ftencent-ailab",[81,85],{"name":82,"color":83,"percentage":84},"Jupyter Notebook","#DA5B0B",99.7,{"name":86,"color":87,"percentage":88},"Python","#3572A5",0.3,6521,425,"2026-04-12T13:53:28","Apache-2.0","未说明","需要 NVIDIA GPU（训练命令包含 --multi_gpu 和 --mixed_precision \"fp16\"），显存需求未明确说明（但提到使用 ViT-H 替代 ViT-bigG 是为了减少推理阶段的显存占用），CUDA 版本未说明",{"notes":96,"python":93,"dependencies":97},"1. 安装前需运行 'git lfs install' 以支持大模型文件下载。\n2. 需手动下载基础模型（如 stable-diffusion-v1-5, SDXL 等）及 IP-Adapter 权重文件。\n3. 训练时需准备 JSON 格式的数据集配置文件。\n4. 官方支持 WebUI (ControlNet), ComfyUI, InvokeAI 等第三方工具集成。\n5. 针对非正方形图片，建议调整大小为 224x224 以避免中心裁剪导致的信息丢失。",[98,99,100,101,102,103],"diffusers==0.22.1","torch","accelerate","transformers","safetensors","git-lfs",[15,105],"其他","2026-03-27T02:49:30.150509","2026-04-13T13:37:43.755463",[109,114,119,124,129,134],{"id":110,"question_zh":111,"answer_zh":112,"source_url":113},31551,"训练 face-ip-adaptor 使用了多少张人脸图像？","训练使用了来自 LAION-2B 和 COYO-700M 数据集的超过 40 万张图像。","https:\u002F\u002Fgithub.com\u002Ftencent-ailab\u002FIP-Adapter\u002Fissues\u002F74",{"id":115,"question_zh":116,"answer_zh":117,"source_url":118},31552,"IP-Adapter FaceID-Plus V2 SDXL 模型使用的是哪种 CLIP Vision Encoder？为什么加载状态字典时会报错？","这是一个常见的误解。实际上并没有专门的\"SDXL Vision Encoder\"或\"SD Vision Encoder\"之分，它们都是视觉变压器（ViT）模型。仓库中的文件夹命名具有误导性：\n1. \"sd\"文件夹下存放的是 OpenCLIP ViT-H\u002F14（6.32 亿参数）。\n2. \"sdxl\"文件夹下存放的是 OpenCLIP ViT-g\u002F14（18.4 亿参数）。\n绝大多数模型（包括 SDXL 模型）实际上是使用 ViT-H 编码训练的。如果您遇到形状不匹配的错误（如 shape [2048, 1280] vs [2048, 1664]），通常是因为错误地混用了 ViT-g 编码器与为 ViT-H 训练的适配器权重。建议对于 SDXL 的 FaceID Plus V2，尝试使用 ViT-H 编码器（即通常标记为 SD 的那个），除非您明确知道该特定模型是用 ViT-g 训练的。","https:\u002F\u002Fgithub.com\u002Ftencent-ailab\u002FIP-Adapter\u002Fissues\u002F265",{"id":120,"question_zh":121,"answer_zh":122,"source_url":123},31553,"使用 StableDiffusionXLCustomPipeline 时出现 'AttributeError: maybe_free_model_hooks' 或 'TypeError: _get_add_time_ids' 错误怎么办？","这通常是由于 `diffusers` 库的版本不兼容导致的。\n1. 确保您安装的 `diffusers` 版本为 0.22.1 或更高（针对 `_get_add_time_ids` 参数问题）。\n2. 如果更新后仍报错，可能需要检查 `custom_pipelines.py` 代码是否与当前安装的 `diffusers` 版本匹配。\n3. 临时解决方法可以是注释掉报错的相关行（如 `maybe_free_model_hooks` 调用），但长期解决方案是保持 `diffusers` 库与 IP-Adapter 代码同步更新。","https:\u002F\u002Fgithub.com\u002Ftencent-ailab\u002FIP-Adapter\u002Fissues\u002F131",{"id":125,"question_zh":126,"answer_zh":127,"source_url":128},31554,"IP-Adapter 的训练目标是什么？文本描述在训练中起什么作用？对文本描述有什么具体要求？","1. **训练目标**：虽然论文提到图文对，但在实际训练代码中，通常使用同一张图像作为输入和目标（自监督方式），文本描述在某些情况下可以省略。\n2. **文本作用**：文本描述有助于模型学习更丰富的语义关联，但并非绝对必要。\n3. **文本要求**：简单的图像描述通常就足够了，不需要非常详细的描述。\n4. **与 SD img2img 的区别**：IP-Adapter 通过额外的适配器模块注入图像特征，而不是像传统 img2img 那样直接修改潜在空间噪声，这使得它在保持主体一致性方面表现更好。\n5. **细节保留**：如果需要保留按钮、文字等细粒度细节，可以使用 CLIP 图像编码器的所有 token（256 个），信息损失几乎为零。也可以尝试 DINOv2 等其他编码器，但这可能导致生成过程完全由图像条件主导，无法再有效使用文本提示。","https:\u002F\u002Fgithub.com\u002Ftencent-ailab\u002FIP-Adapter\u002Fissues\u002F100",{"id":130,"question_zh":131,"answer_zh":132,"source_url":133},31555,"微调训练后保存的检查点中没有 pytorch_model.bin 文件，如何提取 ip_adapter 权重？","这是因为 `accelerator.save_state()` 默认使用了安全序列化（safe_serialization=True），导致某些结构无法正确保存为预期的字典格式。\n**解决方案**：\n在保存状态时，显式设置 `safe_serialization=False`。例如：\n`accelerator.save_state(output_dir, safe_serialization=False)`\n\n如果在加载 `.safetensors` 文件时遇到缺少 LoRA 密钥（如 \"0.to_q_lora.down.weight\"）的错误，可能是因为权重存储结构与加载代码不匹配。确保加载代码适应新的保存格式，或者在加载时使用 `strict=False` 参数（如果支持）：\n`ip_layers.load_state_dict(state_dict[\"ip_adapter\"], strict=False)`","https:\u002F\u002Fgithub.com\u002Ftencent-ailab\u002FIP-Adapter\u002Fissues\u002F246",{"id":135,"question_zh":136,"answer_zh":137,"source_url":128},31556,"是否可以用多模态编码器（如 BLIPDiffusion）替换当前的 CLIP 图像编码器？","是的，理论上可以使用多模态编码器（如 BLIPDiffusion）替换当前的 CLIP 图像编码器，这将扩展 IP-Adapter 的应用场景。作者认为这是一个很有前景的研究方向，类似于 MiniGPT-5 等工作。不过，这需要相应的模型结构调整和重新训练。",[]]