[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-deep-floyd--IF":3,"tool-deep-floyd--IF":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":68,"readme_en":69,"readme_zh":70,"quickstart_zh":71,"use_case_zh":72,"hero_image_url":73,"owner_login":74,"owner_name":74,"owner_avatar_url":75,"owner_bio":76,"owner_company":66,"owner_location":66,"owner_email":66,"owner_twitter":66,"owner_website":66,"owner_url":77,"languages":78,"stars":83,"forks":84,"last_commit_at":85,"license":86,"difficulty_score":87,"env_os":88,"env_gpu":89,"env_ram":88,"env_deps":90,"category_tags":101,"github_topics":66,"view_count":32,"oss_zip_url":66,"oss_zip_packed_at":66,"status":17,"created_at":102,"updated_at":103,"faqs":104,"releases":135},6492,"deep-floyd\u002FIF","IF",null,"IF 是由 DeepFloyd 实验室推出的开源文生图模型，旨在生成具有高度照片级真实感且能精准理解语言描述的图像。它有效解决了传统模型在复杂语义理解和图像细节还原上的不足，能够根据文字提示创作出逼真的高质量图片。\n\nIF 采用独特的级联扩散架构，由一个冻结的文本编码器和三个像素扩散模块组成：首先生成 64x64 的基础图像，随后通过两个超分辨率模型逐步提升至 256x256 乃至 1024x1024 的高清分辨率。其核心亮点在于利用强大的 T5 变压器提取文本特征，并结合增强的 UNet 架构，在 COCO 数据集上取得了零样本 FID 6.66 的卓越成绩，性能超越当前多数主流模型。\n\n这款工具非常适合 AI 研究人员、开发者以及追求极致画质的数字艺术家使用。对于技术人员，IF 提供了灵活的模块化设计，支持与 Hugging Face Diffusers 库集成，允许自定义生成流程并检查中间结果；对于创作者，它提供了包括风格迁移、图像修复和超级分辨率在内的多种模式。虽然运行完整流程对显存有一定要求（建议 16GB-24GB），但其出色的生成效果和开源特性，使其成为探索高质量图像合成","IF 是由 DeepFloyd 实验室推出的开源文生图模型，旨在生成具有高度照片级真实感且能精准理解语言描述的图像。它有效解决了传统模型在复杂语义理解和图像细节还原上的不足，能够根据文字提示创作出逼真的高质量图片。\n\nIF 采用独特的级联扩散架构，由一个冻结的文本编码器和三个像素扩散模块组成：首先生成 64x64 的基础图像，随后通过两个超分辨率模型逐步提升至 256x256 乃至 1024x1024 的高清分辨率。其核心亮点在于利用强大的 T5 变压器提取文本特征，并结合增强的 UNet 架构，在 COCO 数据集上取得了零样本 FID 6.66 的卓越成绩，性能超越当前多数主流模型。\n\n这款工具非常适合 AI 研究人员、开发者以及追求极致画质的数字艺术家使用。对于技术人员，IF 提供了灵活的模块化设计，支持与 Hugging Face Diffusers 库集成，允许自定义生成流程并检查中间结果；对于创作者，它提供了包括风格迁移、图像修复和超级分辨率在内的多种模式。虽然运行完整流程对显存有一定要求（建议 16GB-24GB），但其出色的生成效果和开源特性，使其成为探索高质量图像合成未来的有力工具。","[![License](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FCode_License-Modified_MIT-blue.svg)](LICENSE)\n[![License](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FWeights_License-DeepFloyd_IF-orange.svg)](LICENSE-MODEL)\n[![Downloads](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeep-floyd_IF_readme_12d530335a15.png)](https:\u002F\u002Fpepy.tech\u002Fproject\u002Fdeepfloyd_if)\n[![Discord](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FDiscord-%237289DA.svg?logo=discord&logoColor=white)](https:\u002F\u002Fdiscord.gg\u002Fumz62Mgr)\n[![Twitter](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FTwitter-%231DA1F2.svg?logo=twitter&logoColor=white)](https:\u002F\u002Ftwitter.com\u002Fdeepfloydai)\n[![Linktree](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLinktree-%2339E09B.svg?logo=linktree&logoColor=white)](http:\u002F\u002Flinktr.ee\u002Fdeepfloyd)\n\n# IF by [DeepFloyd Lab](https:\u002F\u002Fdeepfloyd.ai) at [StabilityAI](https:\u002F\u002Fstability.ai\u002F)\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeep-floyd_IF_readme_d163db819f85.jpg\" width=\"100%\">\n\u003C\u002Fp>\n\nWe introduce DeepFloyd IF, a novel state-of-the-art open-source text-to-image model with a high degree of photorealism and language understanding. DeepFloyd IF is a modular composed of a frozen text encoder and three cascaded pixel diffusion modules: a base model that generates 64x64 px image based on text prompt and two super-resolution models, each designed to generate images of increasing resolution: 256x256 px and 1024x1024 px. All stages of the model utilize a frozen text encoder based on the T5 transformer to extract text embeddings, which are then fed into a UNet architecture enhanced with cross-attention and attention pooling. The result is a highly efficient model that outperforms current state-of-the-art models, achieving a zero-shot FID score of 6.66 on the COCO dataset. Our work underscores the potential of larger UNet architectures in the first stage of cascaded diffusion models and depicts a promising future for text-to-image synthesis.\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeep-floyd_IF_readme_a6c38191e913.jpg\" width=\"100%\">\n\u003C\u002Fp>\n\n*Inspired by* [*Photorealistic Text-to-Image Diffusion Models with Deep Language Understanding*](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2205.11487.pdf)\n\n## Minimum requirements to use all IF models:\n- 16GB vRAM for IF-I-XL (4.3B text to 64x64 base module) & IF-II-L (1.2B to 256x256 upscaler module)\n- 24GB vRAM for IF-I-XL (4.3B text to 64x64 base module) & IF-II-L (1.2B to 256x256 upscaler module) & Stable x4 (to 1024x1024 upscaler)\n- `xformers` and set env variable `FORCE_MEM_EFFICIENT_ATTN=1`\n\n\n## Quick Start\n[![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fhuggingface\u002Fnotebooks\u002Fblob\u002Fmain\u002Fdiffusers\u002Fdeepfloyd_if_free_tier_google_colab.ipynb)\n[![Hugging Face Spaces](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FDeepFloyd\u002FIF)\n\n```shell\npip install deepfloyd_if==1.0.2rc0\npip install xformers==0.0.16\npip install git+https:\u002F\u002Fgithub.com\u002Fopenai\u002FCLIP.git --no-deps\n```\n\n## Local notebooks\n[![Jupyter Notebook](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fjupyter_notebook-%23FF7A01.svg?logo=jupyter&logoColor=white)](https:\u002F\u002Fhuggingface.co\u002FDeepFloyd\u002FIF-notebooks\u002Fblob\u002Fmain\u002Fpipes-DeepFloyd-IF-v1.0.ipynb)\n[![Kaggle](https:\u002F\u002Fkaggle.com\u002Fstatic\u002Fimages\u002Fopen-in-kaggle.svg)](https:\u002F\u002Fwww.kaggle.com\u002Fcode\u002Fshonenkov\u002Fdeepfloyd-if-4-3b-generator-of-pictures)\n\nThe Dream, Style Transfer, Super Resolution or Inpainting modes are avaliable in a Jupyter Notebook [here](https:\u002F\u002Fhuggingface.co\u002FDeepFloyd\u002FIF-notebooks\u002Fblob\u002Fmain\u002Fpipes-DeepFloyd-IF-v1.0.ipynb).\n\n\n\n## Integration with 🤗 Diffusers\n\nIF is also integrated with the 🤗 Hugging Face [Diffusers library](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdiffusers\u002F).\n\nDiffusers runs each stage individually allowing the user to customize the image generation process as well as allowing to inspect intermediate results easily.\n\n### Example\n\nBefore you can use IF, you need to accept its usage conditions. To do so:\n1. Make sure to have a [Hugging Face account](https:\u002F\u002Fhuggingface.co\u002Fjoin) and be loggin in\n2. Accept the license on the model card of [DeepFloyd\u002FIF-I-XL-v1.0](https:\u002F\u002Fhuggingface.co\u002FDeepFloyd\u002FIF-I-XL-v1.0)\n3. Make sure to login locally. Install `huggingface_hub`\n```sh\npip install huggingface_hub --upgrade\n```\n\nrun the login function in a Python shell\n\n```py\nfrom huggingface_hub import login\n\nlogin()\n```\n\nand enter your [Hugging Face Hub access token](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fhub\u002Fsecurity-tokens#what-are-user-access-tokens).\n\nNext we install `diffusers` and dependencies:\n\n```sh\npip install diffusers accelerate transformers safetensors\n```\n\nAnd we can now run the model locally.\n\nBy default `diffusers` makes use of [model cpu offloading](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\u002Foptimization\u002Ffp16#model-offloading-for-fast-inference-and-memory-savings) to run the whole IF pipeline with as little as 14 GB of VRAM.\n\nIf you are using `torch>=2.0.0`, make sure to **delete all** `enable_xformers_memory_efficient_attention()`\nfunctions.\n\n```py\nfrom diffusers import DiffusionPipeline\nfrom diffusers.utils import pt_to_pil\nimport torch\n\n# stage 1\nstage_1 = DiffusionPipeline.from_pretrained(\"DeepFloyd\u002FIF-I-XL-v1.0\", variant=\"fp16\", torch_dtype=torch.float16)\nstage_1.enable_xformers_memory_efficient_attention()  # remove line if torch.__version__ >= 2.0.0\nstage_1.enable_model_cpu_offload()\n\n# stage 2\nstage_2 = DiffusionPipeline.from_pretrained(\n    \"DeepFloyd\u002FIF-II-L-v1.0\", text_encoder=None, variant=\"fp16\", torch_dtype=torch.float16\n)\nstage_2.enable_xformers_memory_efficient_attention()  # remove line if torch.__version__ >= 2.0.0\nstage_2.enable_model_cpu_offload()\n\n# stage 3\nsafety_modules = {\"feature_extractor\": stage_1.feature_extractor, \"safety_checker\": stage_1.safety_checker, \"watermarker\": stage_1.watermarker}\nstage_3 = DiffusionPipeline.from_pretrained(\"stabilityai\u002Fstable-diffusion-x4-upscaler\", **safety_modules, torch_dtype=torch.float16)\nstage_3.enable_xformers_memory_efficient_attention()  # remove line if torch.__version__ >= 2.0.0\nstage_3.enable_model_cpu_offload()\n\nprompt = 'a photo of a kangaroo wearing an orange hoodie and blue sunglasses standing in front of the eiffel tower holding a sign that says \"very deep learning\"'\n\n# text embeds\nprompt_embeds, negative_embeds = stage_1.encode_prompt(prompt)\n\ngenerator = torch.manual_seed(0)\n\n# stage 1\nimage = stage_1(prompt_embeds=prompt_embeds, negative_prompt_embeds=negative_embeds, generator=generator, output_type=\"pt\").images\npt_to_pil(image)[0].save(\".\u002Fif_stage_I.png\")\n\n# stage 2\nimage = stage_2(\n    image=image, prompt_embeds=prompt_embeds, negative_prompt_embeds=negative_embeds, generator=generator, output_type=\"pt\"\n).images\npt_to_pil(image)[0].save(\".\u002Fif_stage_II.png\")\n\n# stage 3\nimage = stage_3(prompt=prompt, image=image, generator=generator, noise_level=100).images\nimage[0].save(\".\u002Fif_stage_III.png\")\n```\n\n There are multiple ways to speed up the inference time and lower the memory consumption even more with `diffusers`. To do so, please have a look at the Diffusers docs:\n\n- 🚀 [Optimizing for inference time](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\u002Fapi\u002Fpipelines\u002Fif#optimizing-for-speed)\n- ⚙️ [Optimizing for low memory during inference](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\u002Fapi\u002Fpipelines\u002Fif#optimizing-for-memory)\n\nFor more in-detail information about how to use IF, please have a look at [the IF blog post](https:\u002F\u002Fhuggingface.co\u002Fblog\u002Fif) and [the documentation](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\u002Fmain\u002Fen\u002Fapi\u002Fpipelines\u002Fif) 📖.\n\nDiffusers dreambooth scripts also supports fine-tuning 🎨 [IF](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\u002Fmain\u002Fen\u002Ftraining\u002Fdreambooth#if).\nWith parameter efficient finetuning, you can add new concepts to IF with a single GPU and ~28 GB VRAM.\n\n## Run the code locally\n\n### Loading the models into VRAM\n\n```python\nfrom deepfloyd_if.modules import IFStageI, IFStageII, StableStageIII\nfrom deepfloyd_if.modules.t5 import T5Embedder\n\ndevice = 'cuda:0'\nif_I = IFStageI('IF-I-XL-v1.0', device=device)\nif_II = IFStageII('IF-II-L-v1.0', device=device)\nif_III = StableStageIII('stable-diffusion-x4-upscaler', device=device)\nt5 = T5Embedder(device=\"cpu\")\n```\n\n### I. Dream\nDream is the text-to-image mode of the IF model\n\n```python\nfrom deepfloyd_if.pipelines import dream\n\nprompt = 'ultra close-up color photo portrait of rainbow owl with deer horns in the woods'\ncount = 4\n\nresult = dream(\n    t5=t5, if_I=if_I, if_II=if_II, if_III=if_III,\n    prompt=[prompt]*count,\n    seed=42,\n    if_I_kwargs={\n        \"guidance_scale\": 7.0,\n        \"sample_timestep_respacing\": \"smart100\",\n    },\n    if_II_kwargs={\n        \"guidance_scale\": 4.0,\n        \"sample_timestep_respacing\": \"smart50\",\n    },\n    if_III_kwargs={\n        \"guidance_scale\": 9.0,\n        \"noise_level\": 20,\n        \"sample_timestep_respacing\": \"75\",\n    },\n)\n\nif_III.show(result['III'], size=14)\n```\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeep-floyd_IF_readme_5f0c2e3966d9.jpg)\n\n## II. Zero-shot Image-to-Image Translation\n\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeep-floyd_IF_readme_420c3e143d6f.jpeg)\n\nIn Style Transfer mode, the output of your prompt comes out at the style of the `support_pil_img`\n```python\nfrom deepfloyd_if.pipelines import style_transfer\n\nresult = style_transfer(\n    t5=t5, if_I=if_I, if_II=if_II,\n    support_pil_img=raw_pil_image,\n    style_prompt=[\n        'in style of professional origami',\n        'in style of oil art, Tate modern',\n        'in style of plastic building bricks',\n        'in style of classic anime from 1990',\n    ],\n    seed=42,\n    if_I_kwargs={\n        \"guidance_scale\": 10.0,\n        \"sample_timestep_respacing\": \"10,10,10,10,10,10,10,10,0,0\",\n        'support_noise_less_qsample_steps': 5,\n    },\n    if_II_kwargs={\n        \"guidance_scale\": 4.0,\n        \"sample_timestep_respacing\": 'smart50',\n        \"support_noise_less_qsample_steps\": 5,\n    },\n)\nif_I.show(result['II'], 1, 20)\n```\n\n![Alternative Text](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeep-floyd_IF_readme_37a46f8d26a6.gif)\n\n\n## III. Super Resolution\nFor super-resolution, users can run `IF-II` and `IF-III` or 'Stable x4' on an image that was not necessarely generated by IF (two cascades):\n\n```python\nfrom deepfloyd_if.pipelines import super_resolution\n\nmiddle_res = super_resolution(\n    t5,\n    if_III=if_II,\n    prompt=['woman with a blue headscarf and a blue sweaterp, detailed picture, 4k dslr, best quality'],\n    support_pil_img=raw_pil_image,\n    img_scale=4.,\n    img_size=64,\n    if_III_kwargs={\n        'sample_timestep_respacing': 'smart100',\n        'aug_level': 0.5,\n        'guidance_scale': 6.0,\n    },\n)\nhigh_res = super_resolution(\n    t5,\n    if_III=if_III,\n    prompt=[''],\n    support_pil_img=middle_res['III'][0],\n    img_scale=4.,\n    img_size=256,\n    if_III_kwargs={\n        \"guidance_scale\": 9.0,\n        \"noise_level\": 20,\n        \"sample_timestep_respacing\": \"75\",\n    },\n)\nshow_superres(raw_pil_image, high_res['III'][0])\n```\n\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeep-floyd_IF_readme_8e379eede66e.jpg)\n\n\n### IV. Zero-shot Inpainting\n\n```python\nfrom deepfloyd_if.pipelines import inpainting\n\nresult = inpainting(\n    t5=t5, if_I=if_I,\n    if_II=if_II,\n    if_III=if_III,\n    support_pil_img=raw_pil_image,\n    inpainting_mask=inpainting_mask,\n    prompt=[\n        'oil art, a man in a hat',\n    ],\n    seed=42,\n    if_I_kwargs={\n        \"guidance_scale\": 7.0,\n        \"sample_timestep_respacing\": \"10,10,10,10,10,0,0,0,0,0\",\n        'support_noise_less_qsample_steps': 0,\n    },\n    if_II_kwargs={\n        \"guidance_scale\": 4.0,\n        'aug_level': 0.0,\n        \"sample_timestep_respacing\": '100',\n    },\n    if_III_kwargs={\n        \"guidance_scale\": 9.0,\n        \"noise_level\": 20,\n        \"sample_timestep_respacing\": \"75\",\n    },\n)\nif_I.show(result['I'], 2, 3)\nif_I.show(result['II'], 2, 6)\nif_I.show(result['III'], 2, 14)\n```\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeep-floyd_IF_readme_35182d1d12c1.gif)\n\n### 🤗 Model Zoo 🤗\nThe link to download the weights as well as the model cards will be available soon on each model of the model zoo\n\n#### Original\n\n| Name                                                      | Cascade | Params | FID  | Batch size | Steps |\n|:----------------------------------------------------------|:-------:|:------:|:----:|:----------:|:-----:|\n| [IF-I-M](https:\u002F\u002Fhuggingface.co\u002FDeepFloyd\u002FIF-I-M-v1.0)    |    I    |  400M  | 8.86 |    3072    | 2.5M  |\n| [IF-I-L](https:\u002F\u002Fhuggingface.co\u002FDeepFloyd\u002FIF-I-L-v1.0)    |    I    |  900M  | 8.06 |    3200    | 3.0M  |\n| [IF-I-XL](https:\u002F\u002Fhuggingface.co\u002FDeepFloyd\u002FIF-I-XL-v1.0)* |    I    |  4.3B  | 6.66 |    3072    | 2.42M |\n| [IF-II-M](https:\u002F\u002Fhuggingface.co\u002FDeepFloyd\u002FIF-II-M-v1.0)  |   II    |  450M  |  -   |    1536    | 2.5M  |\n| [IF-II-L](https:\u002F\u002Fhuggingface.co\u002FDeepFloyd\u002FIF-II-L-v1.0)* |   II    |  1.2B  |  -   |    1536    | 2.5M  |\n| IF-III-L* _(soon)_                                        |   III   |  700M  |  -   |    3072    | 1.25M |\n\n *best modules\n\n### Quantitative Evaluation\n\n`FID = 6.66`\n\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeep-floyd_IF_readme_81a6a55cee9e.jpg)\n\n## License\n\nThe code in this repository is released under the bespoke license (see added [point two](https:\u002F\u002Fgithub.com\u002Fdeep-floyd\u002FIF\u002Fblob\u002Fmain\u002FLICENSE#L13)).\n\nThe weights will be available soon via [the DeepFloyd organization at Hugging Face](https:\u002F\u002Fhuggingface.co\u002FDeepFloyd) and have their own LICENSE.\n\n**Disclaimer:** *The initial release of the IF model is under a restricted research-purposes-only license temporarily to gather feedback, and after that we intend to release a fully open-source model in line with other Stability AI models.*\n\n## Limitations and Biases\n\nThe models available in this codebase have known limitations and biases. Please refer to [the model card](https:\u002F\u002Fhuggingface.co\u002FDeepFloyd\u002FIF-I-L-v1.0) for more information.\n\n\n## 🎓 DeepFloyd IF creators:\n\n- Alex Shonenkov [GitHub](https:\u002F\u002Fgithub.com\u002Fshonenkov) | [Linktr](https:\u002F\u002Flinktr.ee\u002FshonenkovAI)\n- Misha Konstantinov [GitHub](https:\u002F\u002Fgithub.com\u002Fzeroshot-ai) | [Twitter](https:\u002F\u002Ftwitter.com\u002F_bra_ket)\n- Daria Bakshandaeva [GitHub](https:\u002F\u002Fgithub.com\u002FGugutse) | [Twitter](https:\u002F\u002Ftwitter.com\u002F_gugutse_)\n- Christoph Schuhmann [GitHub](https:\u002F\u002Fgithub.com\u002Fchristophschuhmann) | [Twitter](https:\u002F\u002Ftwitter.com\u002Flaion_ai)\n- Ksenia Ivanova [GitHub](https:\u002F\u002Fgithub.com\u002Fivksu) | [Twitter](https:\u002F\u002Ftwitter.com\u002Fsusiaiv)\n- Nadiia Klokova [GitHub](https:\u002F\u002Fgithub.com\u002Fvauimpuls) | [Twitter](https:\u002F\u002Ftwitter.com\u002Fvauimpuls)\n\n\n## 📄 Research Paper (Soon)\n\n## Acknowledgements\n\nSpecial thanks to [StabilityAI](http:\u002F\u002Fstability.ai) and its CEO [Emad Mostaque](https:\u002F\u002Ftwitter.com\u002Femostaque) for invaluable support, providing GPU compute and infrastructure to train the models (our gratitude goes to [Richard Vencu](https:\u002F\u002Fgithub.com\u002Frvencu)); thanks to [LAION](https:\u002F\u002Flaion.ai) and [Christoph Schuhmann](https:\u002F\u002Fgithub.com\u002Fchristophschuhmann) in particular for contribution to the project and well-prepared datasets; thanks to [Huggingface](https:\u002F\u002Fhuggingface.co) teams for optimizing models' speed and memory consumption during inference, creating demos and giving cool advice!\n\n## 🚀 External Contributors 🚀\n- The Biggest Thanks [@Apolinário](https:\u002F\u002Fgithub.com\u002Fapolinario), for ideas, consultations, help and support on all stages to make IF available in open-source; for writing a lot of documentation and instructions; for creating a friendly atmosphere in difficult moments 🦉;\n- Thanks, [@patrickvonplaten](https:\u002F\u002Fgithub.com\u002Fpatrickvonplaten), for improving loading time of unet models by 80%;\nfor integration Stable-Diffusion-x4 as native pipeline 💪;\n- Thanks, [@williamberman](https:\u002F\u002Fgithub.com\u002Fwilliamberman) and [@patrickvonplaten](https:\u002F\u002Fgithub.com\u002Fpatrickvonplaten) for diffusers integration 🙌;\n- Thanks, [@hysts](https:\u002F\u002Fgithub.com\u002Fhysts) and [@Apolinário](https:\u002F\u002Fgithub.com\u002Fapolinario) for creating [the best gradio demo with IF](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FDeepFloyd\u002FIF) 🚀;\n- Thanks, [@Dango233](https:\u002F\u002Fgithub.com\u002FDango233), for adapting IF with xformers memory efficient attention 💪;\n","[![许可证](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F代码_许可证-修改后的MIT-blue.svg)](LICENSE)\n[![许可证](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F权重_许可证-DeepFloyd_IF-orange.svg)](LICENSE-MODEL)\n[![下载量](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeep-floyd_IF_readme_12d530335a15.png)](https:\u002F\u002Fpepy.tech\u002Fproject\u002Fdeepfloyd_if)\n[![Discord](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FDiscord-%237289DA.svg?logo=discord&logoColor=white)](https:\u002F\u002Fdiscord.gg\u002Fumz62Mgr)\n[![Twitter](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FTwitter-%231DA1F2.svg?logo=twitter&logoColor=white)](https:\u002F\u002Ftwitter.com\u002Fdeepfloydai)\n[![Linktree](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLinktree-%2339E09B.svg?logo=linktree&logoColor=white)](http:\u002F\u002Flinktr.ee\u002Fdeepfloyd)\n\n# IF 由 [DeepFloyd Lab](https:\u002F\u002Fdeepfloyd.ai) 在 [StabilityAI](https:\u002F\u002Fstability.ai\u002F) 开发\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeep-floyd_IF_readme_d163db819f85.jpg\" width=\"100%\">\n\u003C\u002Fp>\n\n我们推出了 DeepFloyd IF，这是一种全新的、最先进的开源文本到图像模型，具有高度的逼真度和强大的语言理解能力。DeepFloyd IF 是一个模块化架构，由一个冻结的文本编码器和三个级联的像素扩散模块组成：一个基于文本提示生成 64x64 像素图像的基础模型，以及两个超分辨率模型，分别用于生成更高分辨率的图像：256x256 像素和 1024x1024 像素。该模型的所有阶段都使用基于 T5 变压器的冻结文本编码器来提取文本嵌入，然后将这些嵌入输入到增强了交叉注意力和注意力池化的 UNet 架构中。最终结果是一个非常高效的模型，其性能超越了当前最先进的模型，在 COCO 数据集上实现了 6.66 的零样本 FID 分数。我们的工作强调了在级联扩散模型的第一阶段使用更大规模 UNet 架构的潜力，并展示了文本到图像合成的光明前景。\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeep-floyd_IF_readme_a6c38191e913.jpg\" width=\"100%\">\n\u003C\u002Fp>\n\n*灵感来源于* [*具有深度语言理解能力的逼真文本到图像扩散模型*](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2205.11487.pdf)\n\n## 使用所有 IF 模型的最低要求：\n- IF-I-XL（43亿参数的文本到64x64基础模块）和 IF-II-L（12亿参数的256x256超分辨率模块）需要 16GB 显存\n- IF-I-XL（43亿参数的文本到64x64基础模块）、IF-II-L（12亿参数的256x256超分辨率模块）以及 Stable x4（1024x1024超分辨率模块）需要 24GB 显存\n- 需要安装 `xformers` 并设置环境变量 `FORCE_MEM_EFFICIENT_ATTN=1`\n\n\n## 快速入门\n[![在 Colab 中打开](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fhuggingface\u002Fnotebooks\u002Fblob\u002Fmain\u002Fdiffusers\u002Fdeepfloyd_if_free_tier_google_colab.ipynb)\n[![Hugging Face Spaces](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FDeepFloyd\u002FIF)\n\n```shell\npip install deepfloyd_if==1.0.2rc0\npip install xformers==0.0.16\npip install git+https:\u002F\u002Fgithub.com\u002Fopenai\u002FCLIP.git --no-deps\n```\n\n## 本地笔记本\n[![Jupyter Notebook](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fjupyter_notebook-%23FF7A01.svg?logo=jupyter&logoColor=white)](https:\u002F\u002Fhuggingface.co\u002FDeepFloyd\u002FIF-notebooks\u002Fblob\u002Fmain\u002Fpipes-DeepFloyd-IF-v1.0.ipynb)\n[![Kaggle](https:\u002F\u002Fkaggle.com\u002Fstatic\u002Fimages\u002Fopen-in-kaggle.svg)](https:\u002F\u002Fwww.kaggle.com\u002Fcode\u002Fshonenkov\u002Fdeepfloyd-if-4-3b-generator-of-pictures)\n\n梦境、风格迁移、超分辨率或修复模式都可以在 Jupyter Notebook 中使用，链接见 [这里](https:\u002F\u002Fhuggingface.co\u002FDeepFloyd\u002FIF-notebooks\u002Fblob\u002Fmain\u002Fpipes-DeepFloyd-IF-v1.0.ipynb)。\n\n\n\n## 与 🤗 Diffusers 的集成\n\nIF 也已集成到 🤗 Hugging Face 的 [Diffusers 库](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdiffusers\u002F) 中。\n\nDiffusers 会单独运行每个阶段，允许用户自定义图像生成过程，并轻松检查中间结果。\n\n### 示例\n\n在使用 IF 之前，您需要接受其使用条款。操作步骤如下：\n1. 确保您拥有一个 [Hugging Face 账号](https:\u002F\u002Fhuggingface.co\u002Fjoin)，并已登录\n2. 接受 [DeepFloyd\u002FIF-I-XL-v1.0](https:\u002F\u002Fhuggingface.co\u002FDeepFloyd\u002FIF-I-XL-v1.0) 模型卡片上的许可协议\n3. 确保您已在本地登录。安装 `huggingface_hub`\n```sh\npip install huggingface_hub --upgrade\n```\n\n在 Python shell 中运行登录函数：\n\n```py\nfrom huggingface_hub import login\n\nlogin()\n```\n\n并输入您的 [Hugging Face Hub 访问令牌](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fhub\u002Fsecurity-tokens#what-are-user-access-tokens)。\n\n接下来我们安装 `diffusers` 及其依赖项：\n\n```sh\npip install diffusers accelerate transformers safetensors\n```\n\n现在我们就可以在本地运行该模型了。\n\n默认情况下，`diffusers` 会使用 [模型 CPU 卸载](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\u002Foptimization\u002Ffp16#model-offloading-for-fast-inference-and-memory-savings) 技术，以仅需 14 GB 显存即可运行整个 IF 流程。\n\n如果您正在使用 `torch>=2.0.0`，请务必**删除所有** `enable_xformers_memory_efficient_attention()` 函数调用。\n\n```py\nfrom diffusers import DiffusionPipeline\nfrom diffusers.utils import pt_to_pil\nimport torch\n\n# 第一阶段\nstage_1 = DiffusionPipeline.from_pretrained(\"DeepFloyd\u002FIF-I-XL-v1.0\", variant=\"fp16\", torch_dtype=torch.float16)\nstage_1.enable_xformers_memory_efficient_attention()  # 如果 torch.__version__ >= 2.0.0，则移除此行\nstage_1.enable_model_cpu_offload()\n\n# 第二阶段\nstage_2 = DiffusionPipeline.from_pretrained(\n    \"DeepFloyd\u002FIF-II-L-v1.0\", text_encoder=None, variant=\"fp16\", torch_dtype=torch.float16\n)\nstage_2.enable_xformers_memory_efficient_attention()  # 如果 torch.__version__ >= 2.0.0，则移除此行\nstage_2.enable_model_cpu_offload()\n\n# 第三阶段\nsafety_modules = {\"feature_extractor\": stage_1.feature_extractor, \"safety_checker\": stage_1.safety_checker, \"watermarker\": stage_1.watermarker}\nstage_3 = DiffusionPipeline.from_pretrained(\"stabilityai\u002Fstable-diffusion-x4-upscaler\", **safety_modules, torch_dtype=torch.float16)\nstage_3.enable_xformers_memory_efficient_attention()  # 如果 torch.__version__ >= 2.0.0，则移除此行\nstage_3.enable_model_cpu_offload()\n\nprompt = '一只穿着橙色连帽衫、戴着蓝色太阳镜的袋鼠站在埃菲尔铁塔前，手里拿着写着“非常深度学习”的牌子'\n\n# 文本嵌入\nprompt_embeds, negative_embeds = stage_1.encode_prompt(prompt)\n\ngenerator = torch.manual_seed(0)\n\n# 第一阶段\nimage = stage_1(prompt_embeds=prompt_embeds, negative_prompt_embeds=negative_embeds, generator=generator, output_type=\"pt\").images\npt_to_pil(image)[0].save(\".\u002Fif_stage_I.png\")\n\n# 第二阶段\nimage = stage_2(\n    image=image, prompt_embeds=prompt_embeds, negative_prompt_embeds=negative_embeds, generator=generator, output_type=\"pt\"\n).images\npt_to_pil(image)[0].save(\".\u002Fif_stage_II.png\")\n\n# 第三阶段\nimage = stage_3(prompt=prompt, image=image, generator=generator, noise_level=100).images\nimage[0].save(\".\u002Fif_stage_III.png\")\n```\n\n`diffusers` 提供了多种方法来进一步加快推理速度并降低内存消耗。有关详细信息，请参阅 `diffusers` 文档：\n\n- 🚀 [优化推理速度](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\u002Fapi\u002Fpipelines\u002Fif#optimizing-for-speed)\n- ⚙️ [优化低内存下的推理](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\u002Fapi\u002Fpipelines\u002Fif#optimizing-for-memory)\n\n如需了解更多关于如何使用 IF 的详细信息，请查看 [IF 博客文章](https:\u002F\u002Fhuggingface.co\u002Fblog\u002Fif) 和 [官方文档](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\u002Fmain\u002Fen\u002Fapi\u002Fpipelines\u002Fif) 📖。\n\n`Diffusers` 的 DreamBooth 脚本也支持对 [IF](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\u002Fmain\u002Fen\u002Ftraining\u002Fdreambooth#if) 进行微调🎨。通过参数高效的微调，您只需一张 GPU 和约 28 GB 显存，即可为 IF 添加新概念。\n\n## 在本地运行代码\n\n### 将模型加载到显存中\n\n```python\nfrom deepfloyd_if.modules import IFStageI, IFStageII, StableStageIII\nfrom deepfloyd_if.modules.t5 import T5Embedder\n\ndevice = 'cuda:0'\nif_I = IFStageI('IF-I-XL-v1.0', device=device)\nif_II = IFStageII('IF-II-L-v1.0', device=device)\nif_III = StableStageIII('stable-diffusion-x4-upscaler', device=device)\nt5 = T5Embedder(device=\"cpu\")\n```\n\n### I. 梦境\n梦境模式是 IF 模型的文本到图像生成模式。\n\n```python\nfrom deepfloyd_if.pipelines import dream\n\nprompt = '超近距离彩色照片：森林中一只长着鹿角的彩虹猫头鹰'\ncount = 4\n\nresult = dream(\n    t5=t5, if_I=if_I, if_II=if_II, if_III=if_III,\n    prompt=[prompt]*count,\n    seed=42,\n    if_I_kwargs={\n        \"guidance_scale\": 7.0,\n        \"sample_timestep_respacing\": \"smart100\",\n    },\n    if_II_kwargs={\n        \"guidance_scale\": 4.0,\n        \"sample_timestep_respacing\": \"smart50\",\n    },\n    if_III_kwargs={\n        \"guidance_scale\": 9.0,\n        \"noise_level\": 20,\n        \"sample_timestep_respacing\": \"75\",\n    },\n)\n\nif_III.show(result['III'], size=14)\n```\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeep-floyd_IF_readme_5f0c2e3966d9.jpg)\n\n## II. 零样本图像到图像转换\n\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeep-floyd_IF_readme_420c3e143d6f.jpeg)\n\n在风格迁移模式下，您的提示输出将以 `support_pil_img` 的风格呈现。\n\n```python\nfrom deepfloyd_if.pipelines import style_transfer\n\nresult = style_transfer(\n    t5=t5, if_I=if_I, if_II=if_II,\n    support_pil_img=raw_pil_image,\n    style_prompt=[\n        '以专业折纸风格',\n        '以泰特现代艺术馆油画风格',\n        '以塑料积木风格',\n        '以1990年代经典动漫风格',\n    ],\n    seed=42,\n    if_I_kwargs={\n        \"guidance_scale\": 10.0,\n        \"sample_timestep_respacing\": \"10,10,10,10,10,10,10,10,0,0\",\n        'support_noise_less_qsample_steps': 5,\n    },\n    if_II_kwargs={\n        \"guidance_scale\": 4.0,\n        \"sample_timestep_respacing\": 'smart50',\n        \"support_noise_less_qsample_steps\": 5,\n    },\n)\nif_I.show(result['II'], 1, 20)\n```\n\n![Alternative Text](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeep-floyd_IF_readme_37a46f8d26a6.gif)\n\n\n## III. 超分辨率\n对于超分辨率任务，用户可以对并非由 IF 生成的图像运行 `IF-II` 和 `IF-III` 或者 ‘Stable x4’（两个级联）：\n\n```python\nfrom deepfloyd_if.pipelines import super_resolution\n\nmiddle_res = super_resolution(\n    t5,\n    if_III=if_II,\n    prompt=['一位戴着蓝色头巾、身穿蓝色毛衣的女性，细节丰富，4K 单反拍摄，最佳画质'],\n    support_pil_img=raw_pil_image,\n    img_scale=4.,\n    img_size=64,\n    if_III_kwargs={\n        'sample_timestep_respacing': 'smart100',\n        'aug_level': 0.5,\n        'guidance_scale': 6.0,\n    },\n)\nhigh_res = super_resolution(\n    t5,\n    if_III=if_III,\n    prompt=[''],\n    support_pil_img=middle_res['III'][0],\n    img_scale=4.,\n    img_size=256,\n    if_III_kwargs={\n        \"guidance_scale\": 9.0,\n        \"noise_level\": 20,\n        \"sample_timestep_respacing\": \"75\",\n    },\n)\nshow_superres(raw_pil_image, high_res['III'][0])\n```\n\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeep-floyd_IF_readme_8e379eede66e.jpg)\n\n\n### IV. 零样本修复\n\n```python\nfrom deepfloyd_if.pipelines import inpainting\n\nresult = inpainting(\n    t5=t5, if_I=if_I,\n    if_II=if_II,\n    if_III=if_III,\n    support_pil_img=raw_pil_image,\n    inpainting_mask=inpainting_mask,\n    prompt=[\n        '油画风格：一位戴帽子的男人',\n    ],\n    seed=42,\n    if_I_kwargs={\n        \"guidance_scale\": 7.0,\n        \"sample_timestep_respacing\": \"10,10,10,10,10,0,0,0,0,0\",\n        'support_noise_less_qsample_steps': 0,\n    },\n    if_II_kwargs={\n        \"guidance_scale\": 4.0,\n        'aug_level': 0.0,\n        \"sample_timestep_respacing\": '100',\n    },\n    if_III_kwargs={\n        \"guidance_scale\": 9.0,\n        \"noise_level\": 20,\n        \"sample_timestep_respacing\": \"75\",\n    },\n)\nif_I.show(result['I'], 2, 3)\nif_I.show(result['II'], 2, 6)\nif_I.show(result['III'], 2, 14)\n```\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeep-floyd_IF_readme_35182d1d12c1.gif)\n\n### 🤗 模型库 🤗\n每个模型的权重下载链接和模型卡片将很快在模型库中提供。\n\n#### 原始版本\n\n| 名称                                                      | 级联 | 参数量 | FID  | 批量大小 | 步数 |\n|:----------------------------------------------------------|:-------:|:------:|:----:|:----------:|:-----:|\n| [IF-I-M](https:\u002F\u002Fhuggingface.co\u002FDeepFloyd\u002FIF-I-M-v1.0)    |    I    |  400M  | 8.86 |    3072    | 2.5M  |\n| [IF-I-L](https:\u002F\u002Fhuggingface.co\u002FDeepFloyd\u002FIF-I-L-v1.0)    |    I    |  900M  | 8.06 |    3200    | 3.0M  |\n| [IF-I-XL](https:\u002F\u002Fhuggingface.co\u002FDeepFloyd\u002FIF-I-XL-v1.0)* |    I    |  4.3B  | 6.66 |    3072    | 2.42M |\n| [IF-II-M](https:\u002F\u002Fhuggingface.co\u002FDeepFloyd\u002FIF-II-M-v1.0)  |   II    |  450M  |  -   |    1536    | 2.5M  |\n| [IF-II-L](https:\u002F\u002Fhuggingface.co\u002FDeepFloyd\u002FIF-II-L-v1.0)* |   II    |  1.2B  |  -   |    1536    | 2.5M  |\n| IF-III-L* _(即将发布)_                                        |   III   |  700M  |  -   |    3072    | 1.25M |\n\n *最佳模块\n\n### 定量评估\n\n`FID = 6.66`\n\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeep-floyd_IF_readme_81a6a55cee9e.jpg)\n\n## 许可证\n\n本仓库中的代码采用定制许可证发布（详见附录 [第二条](https:\u002F\u002Fgithub.com\u002Fdeep-floyd\u002FIF\u002Fblob\u002Fmain\u002FLICENSE#L13)）。\n\n权重将很快通过 [Hugging Face 上的 DeepFloyd 组织](https:\u002F\u002Fhuggingface.co\u002FDeepFloyd) 提供，并拥有各自的 LICENSE。\n\n**免责声明：** *IF 模型的首次发布暂时采用仅限研究用途的限制性许可证，以便收集反馈；此后，我们计划发布一款完全开源的模型，与其他 Stability AI 模型保持一致。*\n\n## 局限性和偏见\n\n本代码库中的模型存在已知的局限性和偏见。更多信息请参阅 [模型卡片](https:\u002F\u002Fhuggingface.co\u002FDeepFloyd\u002FIF-I-L-v1.0)。\n\n## 🎓 DeepFloyd IF 的创作者：\n\n- Alex Shonenkov [GitHub](https:\u002F\u002Fgithub.com\u002Fshonenkov) | [Linktr](https:\u002F\u002Flinktr.ee\u002FshonenkovAI)\n- Misha Konstantinov [GitHub](https:\u002F\u002Fgithub.com\u002Fzeroshot-ai) | [Twitter](https:\u002F\u002Ftwitter.com\u002F_bra_ket)\n- Daria Bakshandaeva [GitHub](https:\u002F\u002Fgithub.com\u002FGugutse) | [Twitter](https:\u002F\u002Ftwitter.com\u002F_gugutse_)\n- Christoph Schuhmann [GitHub](https:\u002F\u002Fgithub.com\u002Fchristophschuhmann) | [Twitter](https:\u002F\u002Ftwitter.com\u002Flaion_ai)\n- Ksenia Ivanova [GitHub](https:\u002F\u002Fgithub.com\u002Fivksu) | [Twitter](https:\u002F\u002Ftwitter.com\u002Fsusiaiv)\n- Nadiia Klokova [GitHub](https:\u002F\u002Fgithub.com\u002Fvauimpuls) | [Twitter](https:\u002F\u002Ftwitter.com\u002Fvauimpuls)\n\n\n## 📄 研究论文（即将发布）\n\n## 致谢\n\n特别感谢 [StabilityAI](http:\u002F\u002Fstability.ai) 及其 CEO [Emad Mostaque](https:\u002F\u002Ftwitter.com\u002Femostaque)，在模型训练过程中提供了宝贵的 GPU 算力与基础设施支持（我们也要感谢 [Richard Vencu](https:\u002F\u002Fgithub.com\u002Frvencu)）；感谢 [LAION](https:\u002F\u002Flaion.ai) 以及 [Christoph Schuhmann](https:\u002F\u002Fgithub.com\u002Fchristophschuhmann) 对本项目的支持和高质量数据集的提供；同时感谢 [Huggingface](https:\u002F\u002Fhuggingface.co) 团队在推理阶段优化模型的速度与内存占用、制作演示并给予诸多实用建议！\n\n## 🚀 外部贡献者 🚀\n- 最诚挚的感谢 [@Apolinário](https:\u002F\u002Fgithub.com\u002Fapolinario)，他在各个阶段为 IF 开源提供了创意、咨询、帮助与支持；撰写了大量文档和使用指南，并在艰难时刻营造了友好的氛围 🦉；\n- 感谢 [@patrickvonplaten](https:\u002F\u002Fgithub.com\u002Fpatrickvonplaten)，他将 UNET 模型的加载速度提升了 80%；还成功将 Stable-Diffusion-x4 集成为原生流程 💪；\n- 感谢 [@williamberman](https:\u002F\u002Fgithub.com\u002Fwilliamberman) 和 [@patrickvonplaten](https:\u002F\u002Fgithub.com\u002Fpatrickvonplaten)，他们实现了 Diffusers 的集成 🙌；\n- 感谢 [@hysts](https:\u002F\u002Fgithub.com\u002Fhysts) 和 [@Apolinário](https:\u002F\u002Fgithub.com\u002Fapolinario)，他们共同打造了 [最佳的 Gradio IF 演示](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FDeepFloyd\u002FIF) 🚀；\n- 感谢 [@Dango233](https:\u002F\u002Fgithub.com\u002FDango233)，他利用 xformers 的高效注意力机制对 IF 进行了适配 💪；","# DeepFloyd IF 快速上手指南\n\nDeepFloyd IF 是由 StabilityAI 旗下的 DeepFloyd Lab 推出的开源文生图模型，以其极高的照片级真实感和语言理解能力著称。该模型采用级联扩散架构，包含三个模块：基础生成（64x64）、一级超分（256x256）和二级超分（1024x1024）。\n\n## 环境准备\n\n### 硬件要求\n要运行完整的 IF 流水线（包含所有三个阶段），建议满足以下显存（vRAM）要求：\n*   **最低配置 (16GB vRAM)**：可运行基础模型 (IF-I-XL) 和一级超分模型 (IF-II-L)，生成 256x256 分辨率图像。\n*   **推荐配置 (24GB vRAM)**：可运行完整流水线（含 Stable x4 超分），生成 1024x1024 分辨率图像。\n\n### 软件依赖\n*   Python 环境\n*   CUDA 支持的 GPU\n*   `xformers` 库（用于内存优化）\n*   环境变量设置：需设置 `FORCE_MEM_EFFICIENT_ATTN=1`\n\n## 安装步骤\n\n### 方案一：使用官方 Pip 源安装（推荐用于本地开发）\n\n依次执行以下命令安装核心依赖：\n\n```shell\npip install deepfloyd_if==1.0.2rc0\npip install xformers==0.0.16\npip install git+https:\u002F\u002Fgithub.com\u002Fopenai\u002FCLIP.git --no-deps\n```\n\n> **提示**：国内用户若下载缓慢，可添加 `-i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple` 参数使用清华镜像源。\n\n### 方案二：通过 Hugging Face Diffusers 集成安装（推荐用于灵活控制）\n\nDiffusers 库支持分阶段运行模型，便于自定义生成过程和检查中间结果，且默认支持 CPU 卸载以节省显存。\n\n1. 安装必要库：\n```sh\npip install diffusers accelerate transformers safetensors huggingface_hub --upgrade\n```\n\n2. 登录 Hugging Face（使用前需接受模型协议）：\n   * 访问 [DeepFloyd\u002FIF-I-XL-v1.0](https:\u002F\u002Fhuggingface.co\u002FDeepFloyd\u002FIF-I-XL-v1.0) 页面同意协议。\n   * 在终端运行登录命令并输入 Access Token：\n```py\nfrom huggingface_hub import login\nlogin()\n```\n\n## 基本使用\n\n以下提供两种最常用的快速启动方式。\n\n### 方式 A：使用 Diffusers 库（内存优化最佳）\n\n此方式自动处理模型加载和显存优化，适合大多数开发者。\n\n```python\nfrom diffusers import DiffusionPipeline\nfrom diffusers.utils import pt_to_pil\nimport torch\n\n# 阶段 1: 基础生成 (64x64)\nstage_1 = DiffusionPipeline.from_pretrained(\"DeepFloyd\u002FIF-I-XL-v1.0\", variant=\"fp16\", torch_dtype=torch.float16)\n# 若 torch 版本 >= 2.0.0，请删除下一行 enable_xformers...\nstage_1.enable_xformers_memory_efficient_attention()\nstage_1.enable_model_cpu_offload()\n\n# 阶段 2: 一级超分 (256x256)\nstage_2 = DiffusionPipeline.from_pretrained(\n    \"DeepFloyd\u002FIF-II-L-v1.0\", text_encoder=None, variant=\"fp16\", torch_dtype=torch.float16\n)\nstage_2.enable_xformers_memory_efficient_attention()\nstage_2.enable_model_cpu_offload()\n\n# 阶段 3: 二级超分 (1024x1024)\nsafety_modules = {\"feature_extractor\": stage_1.feature_extractor, \"safety_checker\": stage_1.safety_checker, \"watermarker\": stage_1.watermarker}\nstage_3 = DiffusionPipeline.from_pretrained(\"stabilityai\u002Fstable-diffusion-x4-upscaler\", **safety_modules, torch_dtype=torch.float16)\nstage_3.enable_xformers_memory_efficient_attention()\nstage_3.enable_model_cpu_offload()\n\nprompt = 'a photo of a kangaroo wearing an orange hoodie and blue sunglasses standing in front of the eiffel tower holding a sign that says \"very deep learning\"'\n\n# 编码提示词\nprompt_embeds, negative_embeds = stage_1.encode_prompt(prompt)\ngenerator = torch.manual_seed(0)\n\n# 执行生成\n# Stage 1\nimage = stage_1(prompt_embeds=prompt_embeds, negative_prompt_embeds=negative_embeds, generator=generator, output_type=\"pt\").images\npt_to_pil(image)[0].save(\".\u002Fif_stage_I.png\")\n\n# Stage 2\nimage = stage_2(\n    image=image, prompt_embeds=prompt_embeds, negative_prompt_embeds=negative_embeds, generator=generator, output_type=\"pt\"\n).images\npt_to_pil(image)[0].save(\".\u002Fif_stage_II.png\")\n\n# Stage 3\nimage = stage_3(prompt=prompt, image=image, generator=generator, noise_level=100).images\nimage[0].save(\".\u002Fif_stage_III.png\")\n```\n\n### 方式 B：使用原生 DeepFloyd IF 包（功能最全）\n\n此方式可直接调用 Dream、风格迁移、超分和修复等专用管道。\n\n```python\nfrom deepfloyd_if.modules import IFStageI, IFStageII, StableStageIII\nfrom deepfloyd_if.modules.t5 import T5Embedder\nfrom deepfloyd_if.pipelines import dream\n\n# 1. 加载模型到显存\ndevice = 'cuda:0'\nif_I = IFStageI('IF-I-XL-v1.0', device=device)\nif_II = IFStageII('IF-II-L-v1.0', device=device)\nif_III = StableStageIII('stable-diffusion-x4-upscaler', device=device)\nt5 = T5Embedder(device=\"cpu\")\n\n# 2. 执行 Dream (文生图) 模式\nprompt = 'ultra close-up color photo portrait of rainbow owl with deer horns in the woods'\ncount = 4\n\nresult = dream(\n    t5=t5, if_I=if_I, if_II=if_II, if_III=if_III,\n    prompt=[prompt]*count,\n    seed=42,\n    if_I_kwargs={\n        \"guidance_scale\": 7.0,\n        \"sample_timestep_respacing\": \"smart100\",\n    },\n    if_II_kwargs={\n        \"guidance_scale\": 4.0,\n        \"sample_timestep_respacing\": \"smart50\",\n    },\n    if_III_kwargs={\n        \"guidance_scale\": 9.0,\n        \"noise_level\": 20,\n        \"sample_timestep_respacing\": \"75\",\n    },\n)\n\n# 显示结果\nif_III.show(result['III'], size=14)\n```\n\n> **在线体验**：若无本地 GPU 资源，可直接使用 [Google Colab 免费 tier](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fhuggingface\u002Fnotebooks\u002Fblob\u002Fmain\u002Fdiffusers\u002Fdeepfloyd_if_free_tier_google_colab.ipynb) 或 [Hugging Face Spaces](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FDeepFloyd\u002FIF) 进行尝试。","某独立游戏开发者正在为一款赛博朋克风格的视觉小说快速生成高质量的角色立绘和背景素材，急需在有限算力下实现照片级真实的画面效果。\n\n### 没有 IF 时\n- **画质与语义割裂**：使用传统模型生成的图像虽然分辨率尚可，但往往无法精准理解复杂的场景描述（如“霓虹灯反射在积水路面”），导致画面细节逻辑混乱。\n- **放大失真严重**：先生成低分图再借助普通算法放大，人物面部五官容易模糊或扭曲，缺乏真实皮肤的纹理质感。\n- **硬件门槛过高**：想要直接生成 1024x1024 的高清大图，通常需要多张高端显卡并行，个人开发者的单卡环境难以负荷。\n- **迭代成本高昂**：为了得到一张可用素材，需反复调整提示词并尝试不同模型组合，耗时数小时却难获满意结果。\n\n### 使用 IF 后\n- **深度语言理解**：IF 凭借强大的 T5 文本编码器，能精准捕捉“雨夜”、“金属光泽”等复杂修饰语，生成的图像完美还原了文字描述的物理光影逻辑。\n- **级联超分保真**：利用其独特的三级级联扩散架构，从 64px 逐步生成至 1024px，人物发丝与皮肤毛孔清晰可见，彻底解决了放大后的伪影问题。\n- **显存效率优化**：通过模块化设计和内存高效注意力机制，仅需单张 24GB 显存显卡即可跑通全套流程，让个人工作站也能产出电影级素材。\n- **工作流可控性强**：开发者可灵活干预中间层级（如仅重绘低分阶段或单独升级分辨率），大幅缩短了从创意到成图的调试周期。\n\nIF 将顶尖的文本理解力与高效的级联生成架构相结合，让个人开发者也能以极低算力成本轻松获得超越商业级的照片级图像合成能力。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdeep-floyd_IF_5f0c2e39.jpg","deep-floyd","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fdeep-floyd_feea5a8e.jpg","","https:\u002F\u002Fgithub.com\u002Fdeep-floyd",[79],{"name":80,"color":81,"percentage":82},"Python","#3572A5",100,7830,527,"2026-04-10T16:37:44","NOASSERTION",4,"未说明","必需 NVIDIA GPU。运行完整流程（IF-I-XL + IF-II-L + Stable x4）需 24GB 显存；仅运行前两级（IF-I-XL + IF-II-L）需 16GB 显存。建议使用支持 xformers 的显卡以优化内存效率。",{"notes":91,"python":88,"dependencies":92},"1. 必须安装 xformers 并设置环境变量 FORCE_MEM_EFFICIENT_ATTN=1 以启用内存高效注意力机制。\n2. 若使用 torch>=2.0.0，代码中需移除 enable_xformers_memory_efficient_attention() 调用。\n3. 使用 Diffusers 库并通过 CPU 卸载技术可将最低显存需求降至 14GB。\n4. 首次使用前需在 Hugging Face 接受许可协议并登录获取访问令牌。\n5. 模型采用级联结构：文本生成 64x64 图像 -> 超分至 256x256 -> 超分至 1024x1024。",[93,94,95,96,97,98,99,100],"deepfloyd_if==1.0.2rc0","xformers==0.0.16","diffusers","accelerate","transformers","safetensors","huggingface_hub","torch>=2.0.0 (可选，用于原生高效注意力)",[15],"2026-03-27T02:49:30.150509","2026-04-11T10:01:31.536634",[105,110,115,120,125,130],{"id":106,"question_zh":107,"answer_zh":108,"source_url":109},29380,"如何设置自定义分辨率或宽高比？","第一阶段（Stage 1）支持 80*80 像素及以上的分辨率（例如生成 1280*1280 图像）。如果在第二阶段（Stage 2）遇到 'unexpected keyword argument width' 错误，需要修改源码文件 `src\u002Fdiffusers\u002Fpipelines\u002Fdeepfloyd_if\u002Fpipeline_if_superresolution.py`。修改后，若不指定 width 参数，第二阶段可能会将图像压缩为 256*256，因此建议参考官方提供的修改链接进行调整以支持自定义宽高比。","https:\u002F\u002Fgithub.com\u002Fdeep-floyd\u002FIF\u002Fissues\u002F82",{"id":111,"question_zh":112,"answer_zh":113,"source_url":114},29381,"遇到 'CUDA out of memory' 显存不足错误如何解决？","如果单张显卡显存不足（如 24GB），可以尝试以下方案：\n1. 将模型分散到多张 GPU 上运行（例如将 Stage I, II, III 和 T5Embedder 分别指定到 cuda:0, cuda:1, cuda:2, cuda:3）。\n2. 如果使用 diffusers 实现，可以启用 CPU offload（需要约 32GB 系统内存）。\n3. 尝试将数据类型设置为 float16：`t5 = T5Embedder(device='cuda:0', torch_dtype=torch.float16)`。\n4. 即使设置了 `os.environ[\"FORCE_MEM_EFFICIENT_ATTN\"] = \"1\"`，在某些卡（如 3090）上可能仍需上述调整。","https:\u002F\u002Fgithub.com\u002Fdeep-floyd\u002FIF\u002Fissues\u002F85",{"id":116,"question_zh":117,"answer_zh":118,"source_url":119},29382,"T5Embedder 在 CUDA 上报错但在 CPU 上正常，如何处理？","这通常是因为显存不足或数据类型不匹配。如果在 GPU 上运行编码器及所有三个阶段，仅模型就需要约 23GB 显存，加上运行内存，24GB 显存的显卡可能不够。解决方案包括：\n1. 启用 CPU offload（需约 32GB 系统内存）。\n2. 显式指定数据类型为 float16：`t5 = T5Embedder(device='cuda:0', torch_dtype=torch.float16)`，因为模型默认使用 bfloat16，某些环境可能不支持。","https:\u002F\u002Fgithub.com\u002Fdeep-floyd\u002FIF\u002Fissues\u002F79",{"id":121,"question_zh":122,"answer_zh":123,"source_url":124},29383,"使用 torch>=2.0.0 时需要做什么特殊配置？","如果使用 `torch>=2.0.0`，必须删除代码中所有的 `enable_xformers_memory_efficient_attention()` 函数调用。注意不需要修改仓库本身的源码，只需在你实际运行的代码文件（如 README 中的示例脚本或 Jupyter Notebook）中删除这三处调用（每个阶段一处）。","https:\u002F\u002Fgithub.com\u002Fdeep-floyd\u002FIF\u002Fissues\u002F57",{"id":126,"question_zh":127,"answer_zh":128,"source_url":129},29384,"打开 Notebook 时提示 'Unreadable Notebook' 或 'NotJSONError' 怎么办？","这是因为 Notebook 文件使用了 Git LFS 存储，直接下载可能只获取了指针文件而非实际内容。解决方法是前往 Hugging Face 仓库下载可用的 Notebook 文件，地址为：https:\u002F\u002Fhuggingface.co\u002FDeepFloyd\u002FIF-I-XL-v1.0\u002Ftree\u002Fmain\u002Fnotebooks","https:\u002F\u002Fgithub.com\u002Fdeep-floyd\u002FIF\u002Fissues\u002F29",{"id":131,"question_zh":132,"answer_zh":133,"source_url":134},29385,"下载模型权重时提示 'Repository not found' 是怎么回事？","该问题通常是由于模型权重暂时未公开或链接失效导致的。根据维护者回复，权重是可用的，如果遇到 'Repo not found'，可能是发布初期的临时状态，请稍后再试或检查 Hugging Face 上的最新模型页面（如 DeepFloyd\u002FIF-I-XL-v1.0 等）。","https:\u002F\u002Fgithub.com\u002Fdeep-floyd\u002FIF\u002Fissues\u002F16",[136,141],{"id":137,"version":138,"summary_zh":139,"released_at":140},198153,"v1.0.1","- 将主模型 `IF-I-IF` 重命名为 `IF-I-XL`\n- 将 `notebooks` 目录迁移至 Hugging Face 仓库：https:\u002F\u002Fhuggingface.co\u002FDeepFloyd\u002FIF-notebooks；今后请将新笔记本保存在那里；\n- 添加了一个额外的 Kaggle 笔记本（提供更多免费 GPU 资源），介绍如何生成 1k 分辨率的图片：[![Kaggle](https:\u002F\u002Fkaggle.com\u002Fstatic\u002Fimages\u002Fopen-in-kaggle.svg)](https:\u002F\u002Fwww.kaggle.com\u002Fcode\u002Fshonenkov\u002Fdeepfloyd-if-4-3b-generator-of-pictures)","2023-04-28T12:17:09",{"id":142,"version":143,"summary_zh":144,"released_at":145},198154,"v1.0.0","- 初始版本","2023-04-27T13:04:38"]