[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-FlyMyAI--flymyai-lora-trainer":3,"tool-FlyMyAI--flymyai-lora-trainer":61},[4,18,26,36,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},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 真正成长为懂上",147882,2,"2026-04-09T11:32:47",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108111,"2026-04-08T11:23:26",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,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},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",[35,15,13,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":72,"owner_name":73,"owner_avatar_url":74,"owner_bio":75,"owner_company":76,"owner_location":76,"owner_email":77,"owner_twitter":76,"owner_website":78,"owner_url":79,"languages":80,"stars":85,"forks":86,"last_commit_at":87,"license":88,"difficulty_score":10,"env_os":89,"env_gpu":90,"env_ram":91,"env_deps":92,"category_tags":102,"github_topics":76,"view_count":32,"oss_zip_url":76,"oss_zip_packed_at":76,"status":17,"created_at":103,"updated_at":104,"faqs":105,"releases":135},5871,"FlyMyAI\u002Fflymyai-lora-trainer","flymyai-lora-trainer","Qwen-Image text to image lora trainer","flymyai-lora-trainer 是一款开源的 AI 模型微调工具，专为 Qwen-Image、Qwen-Image-Edit 及 FLUX.1-dev 等主流文生图模型设计。它核心解决了用户希望以低成本、高效率的方式定制专属图像生成风格或角色的难题。通过训练 LoRA（低秩适应）层，用户无需重新训练庞大的基础模型，仅需少量数据集即可让模型学会特定的画风、人物特征或编辑逻辑。\n\n这款工具特别适合具备一定技术基础的开发者、AI 研究人员以及需要批量定制模型内容的设计团队使用。其技术亮点在于全面兼容 Hugging Face `diffusers` 生态，支持通过简单的 YAML 文件进行配置，大幅降低了操作门槛。此外，它针对显存资源有限的场景进行了优化，支持在小于 24GB 显存的 GPU 上运行训练流程，并提供了完善的数据集验证脚本，确保训练数据的规范性。对于需要进行可控图像编辑（如基于参考图修改）的用户，flymyai-lora-trainer 也提供了专门的支持路径，是实现高质量人像与角色定制的理想选择。","# LoRA Training for Qwen-Image, Qwen-Image-Edit & FLUX.1-dev\n\nAn open-source implementation for training LoRA (Low-Rank Adaptation) layers for Qwen\u002FQwen-Image, Qwen\u002FQwen-Image-Edit, and FLUX.1-dev models by [FlyMy.AI](https:\u002F\u002Fflymy.ai).\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_2091053e9469.png\" alt=\"FlyMy.AI Logo\" width=\"256\">\n\u003C\u002Fp>\n\n## Star History\n\n[![Star History Chart](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_fb49a5cef69c.png)](https:\u002F\u002Fwww.star-history.com\u002F#FlyMyAI\u002Fflymyai-lora-trainer&Date)\n\n## 🌟 About FlyMy.AI\n\nAgentic Infra for GenAI. FlyMy.AI is a B2B infrastructure for building and running GenAI Media agents.\n\n\n**🔗 Useful Links:**\n- 🌐 [Official Website](https:\u002F\u002Fflymy.ai)\n- 📚 [Documentation](https:\u002F\u002Fdocs.flymy.ai\u002Fintro)\n- 💬 [Discord Community](https:\u002F\u002Fdiscord.com\u002Finvite\u002Ft6hPBpSebw)\n- 🤗 [Pre-trained Qwen LoRA Model](https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fqwen-image-realism-lora)\n- 🤗 [Pre-trained FLUX LoRA Model](https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fflux-dev-anne-hathaway-lora)\n- 🚀 [Train Your Own FLUX LoRA](https:\u002F\u002Fapp.flymy.ai\u002Fmodels\u002Fflymyai\u002Fflux-lora-trainer-fast)\n- 🐦 [X (Twitter)](https:\u002F\u002Fx.com\u002Fflymyai)\n- 💼 [LinkedIn](https:\u002F\u002Flinkedin.com\u002Fcompany\u002Fflymyai)\n- 📺 [YouTube](https:\u002F\u002Fyoutube.com\u002F@flymyai)\n- 📸 [Instagram](https:\u002F\u002Fwww.instagram.com\u002Fflymy_ai)\n\n## 🚀 Features\n\n- LoRA-based fine-tuning for efficient training\n- Support for Qwen-Image, Qwen-Image-Edit, and FLUX.1-dev models\n- Compatible with Hugging Face `diffusers`\n- Easy configuration via YAML\n- Control-based image editing with LoRA\n- Open-source implementation for LoRA training\n- Full training support for Qwen-Image\n- High-quality portrait and character training for FLUX\n\n## 📅 Updates\n\n**16.10.2025**\n- ✅ Added FLUX.1-dev LoRA training support\n- ✅ Added pre-trained FLUX LoRA model example\n\n**02.09.2025**\n- ✅ Added full training for Qwen-Image and Qwen-Image-Edit\n\n**20.08.2025**\n- ✅ Added Qwen-Image-Edit LoRA trainer support\n\n**09.08.2025**\n- ✅ Add pipeline for train for \u003C 24GiB GPU\n\n**08.08.2025**\n- ✅ Added comprehensive dataset preparation instructions\n- ✅ Added dataset validation script (`utils\u002Fvalidate_dataset.py`)\n- ✅ Freeze model weights during training\n\n## ⚠️ Project Status\n\n**🚧 Under Development:** We are actively working on improving the code and adding test coverage. The project is in the refinement stage but ready for use.\n\n**📋 Development Plans:**\n- ✅ Basic code is working\n- ✅ Training functionality implemented\n- ✅ FLUX.1-dev support added\n- 🔄 Performance optimization in progress\n- 🔜 Test coverage coming soon\n\n---\n\n## 📦 Installation\n\n**Requirements:**\n- Python 3.10\n\n1. Clone the repository and navigate into it:\n   ```bash\n   git clone https:\u002F\u002Fgithub.com\u002FFlyMyAI\u002Fflymyai-lora-trainer\n   cd flymyai-lora-trainer\n   ```\n\n2. Install required packages:\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n3. Install the latest `diffusers` from GitHub:\n   ```bash\n   pip install git+https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdiffusers\n   ```\n\n4. Download pre-trained LoRA weights (optional):\n   ```bash\n   # Qwen LoRA weights\n   git clone https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fqwen-image-realism-lora\n   \n   # FLUX LoRA weights\n   git clone https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fflux-dev-anne-hathaway-lora\n   \n   # Or download specific files\n   wget https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fqwen-image-realism-lora\u002Fresolve\u002Fmain\u002Fflymy_realism.safetensors\n   wget https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fflux-dev-anne-hathaway-lora\u002Fresolve\u002Fmain\u002Fpytorch_lora_weights.safetensors\n   ```\n\n---\n\n## 📁 Data Preparation\n\n### Dataset Structure for Training\n\nThe training data should follow the same format for both Qwen and FLUX models, where each image has a corresponding text file with the same name:\n\n```\ndataset\u002F\n├── img1.png\n├── img1.txt\n├── img2.jpg\n├── img2.txt\n├── img3.png\n├── img3.txt\n└── ...\n```\n\n### Dataset Structure for Qwen-Image-Edit Training\n\nFor control-based image editing, the dataset should be organized with separate directories for target images\u002Fcaptions and control images:\n\n```\ndataset\u002F\n├── images\u002F           # Target images and their captions\n│   ├── image_001.jpg\n│   ├── image_001.txt\n│   ├── image_002.jpg\n│   ├── image_002.txt\n│   └── ...\n└── control\u002F          # Control images\n    ├── image_001.jpg\n    ├── image_002.jpg\n    └── ...\n```\n### Data Format Requirements\n\n1. **Images**: Support common formats (PNG, JPG, JPEG, WEBP)\n2. **Text files**: Plain text files containing image descriptions\n3. **File naming**: Each image must have a corresponding text file with the same base name\n\n### Example Data Structure\n\n```\nmy_training_data\u002F\n├── portrait_001.png\n├── portrait_001.txt\n├── landscape_042.jpg\n├── landscape_042.txt\n├── abstract_design.png\n├── abstract_design.txt\n└── style_reference.jpg\n└── style_reference.txt\n```\n\n### Text File Content Examples\n\n**For FLUX character training (portrait_001.txt):**\n```\nohwx woman, professional headshot, studio lighting, elegant pose, looking at camera\n```\n\n**For Qwen landscape training (landscape_042.txt):**\n```\nMountain landscape at sunset, dramatic clouds, golden hour lighting, wide angle view\n```\n\n**For FLUX portrait training (abstract_design.txt):**\n```\nohwx woman, modern portrait style, soft lighting, artistic composition\n```\n\n### Data Preparation Tips\n\n1. **Image Quality**: Use high-resolution images (recommended 1024x1024 or higher)\n2. **Description Quality**: Write detailed, accurate descriptions of your images\n3. **Consistency**: Maintain consistent style and quality across your dataset\n4. **Dataset Size**: For good results, use at least 10-50 image-text pairs\n5. **Trigger Words**: \n   - For FLUX character training: Use \"ohwx woman\" or \"ohwx man\" as trigger words\n   - For Qwen training: No specific trigger words required\n6. **Auto-generate descriptions**: You can generate image descriptions automatically using [Florence-2](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fgokaygokay\u002FFlorence-2)\n\n### Quick Data Validation\n\nYou can verify your data structure using the included validation utility:\n\n```bash\npython utils\u002Fvalidate_dataset.py --path path\u002Fto\u002Fyour\u002Fdataset\n```\n\nThis will check that:\n- Each image has a corresponding text file\n- All files follow the correct naming convention\n- Report any missing files or inconsistencies\n\n---\n\n## 🏁 Start Training on \u003C 24gb vram\n\nTo begin training with your configuration file (e.g., `train_lora_4090.yaml`), run:\n\n```bash\naccelerate launch train_4090.py --config .\u002Ftrain_configs\u002Ftrain_lora_4090.yaml\n```\n![Sample Output](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_8403cd7270da.jpg)\n\n\n## 🏁 Training\n\n# Qwen Models Training\n\n## Qwen-Image LoRA Training\n\nTo begin training with your configuration file (e.g., `train_lora.yaml`), run:\n\n```bash\naccelerate launch train.py --config .\u002Ftrain_configs\u002Ftrain_lora.yaml\n```\n\nMake sure `train_lora.yaml` is correctly set up with paths to your dataset, model, output directory, and other parameters.\n\n\n### Qwen-Image Full Training\n\nTo begin training with your configuration file (e.g., `train_full_qwen_image.yaml`), run:\n\n```bash\naccelerate launch train_full_qwen_image.py --config .\u002Ftrain_configs\u002Ftrain_full_qwen_image.yaml\n```\n\nMake sure `train_full_qwen_image.yaml` is correctly set up with paths to your dataset, model, output directory, and other parameters.\nThe proposed method was tested on an NVIDIA H200 GPU environment.\n#### Loading Trained Full Model\n\nAfter training, you can load your trained model from the checkpoint directory for inference.\n\n**Simple Example:**\n\n```python\nfrom diffusers import QwenImagePipeline, QwenImageTransformer2DModel, AutoencoderKLQwenImage\nimport torch\nfrom omegaconf import OmegaConf\nimport os\n\ndef load_trained_model(checkpoint_path):\n    \"\"\"Load trained model from checkpoint\"\"\"\n    print(f\"Loading trained model from: {checkpoint_path}\")\n    \n    # Load config to get original model path\n    config_path = os.path.join(checkpoint_path, \"config.yaml\")\n    config = OmegaConf.load(config_path)\n    original_model_path = config.pretrained_model_name_or_path\n    \n    # Load trained transformer\n    transformer_path = os.path.join(checkpoint_path, \"transformer\")\n    transformer = QwenImageTransformer2DModel.from_pretrained(\n        transformer_path,\n        torch_dtype=torch.bfloat16,\n        low_cpu_mem_usage=True\n    )\n    transformer.to(\"cuda\")\n    transformer.eval()\n    \n    # Load VAE from original model\n    vae = AutoencoderKLQwenImage.from_pretrained(\n        original_model_path,\n        subfolder=\"vae\",\n        torch_dtype=torch.bfloat16\n    )\n    vae.to(\"cuda\")\n    vae.eval()\n    \n    # Create pipeline\n    pipe = QwenImagePipeline.from_pretrained(\n        original_model_path,\n        transformer=transformer,\n        vae=vae,\n        torch_dtype=torch.bfloat16\n    )\n    pipe.to(\"cuda\")\n    \n    print(\"Model loaded successfully!\")\n    return pipe\n\n# Usage\ncheckpoint_path = \"\u002Fpath\u002Fto\u002Fyour\u002Fcheckpoint\"\npipe = load_trained_model(checkpoint_path)\n\n# Generate image\nprompt = \"A beautiful landscape with mountains and lake\"\nimage = pipe(\n    prompt=prompt,\n    width=768,\n    height=768,\n    num_inference_steps=30,\n    true_cfg_scale=5,\n    generator=torch.Generator(device=\"cuda\").manual_seed(42)\n)\n\n# Save result\noutput_image = image.images[0]\noutput_image.save(\"generated_image.png\")\n```\n\n**Complete Example Script:**\n\n```bash\npython inference_trained_model_gpu_optimized.py\n```\n\n**Checkpoint Structure:**\n\nThe trained model is saved in the following structure:\n```\ncheckpoint\u002F\n├── config.yaml          # Training configuration\n└── transformer\u002F         # Trained transformer weights\n    ├── config.json\n    ├── diffusion_pytorch_model.safetensors.index.json\n    └── diffusion_pytorch_model-00001-of-00005.safetensors\n    └── ... (multiple shard files)\n```\n\n\n### Qwen-Image-Edit LoRA Training\n\nFor control-based image editing training, use the specialized training script:\n\n```bash\naccelerate launch train_qwen_edit_lora.py --config .\u002Ftrain_configs\u002Ftrain_lora_qwen_edit.yaml\n```\n\n#### Configuration for Qwen-Image-Edit\n\nThe configuration file `train_lora_qwen_edit.yaml` should include:\n\n- `img_dir`: Path to target images and captions directory (e.g., `.\u002Fextracted_dataset\u002Ftrain\u002Fimages`)\n- `control_dir`: Path to control images directory (e.g., `.\u002Fextracted_dataset\u002Ftrain\u002Fcontrol`)\n- Other standard LoRA training parameters\n\n## 🧪 Usage\n\n### Qwen-Image-Edit Full Training\n\nTo begin training with your configuration file (e.g., `train_full_qwen_edit.yaml`), run:\n\n```bash\naccelerate launch train_full_qwen_edit.py --config .\u002Ftrain_configs\u002Ftrain_full_qwen_edit.yaml\n```\n\n---\n\n### 🔧 Qwen-Image Initialization\n\n```python\nfrom diffusers import DiffusionPipeline\nimport torch\n\nmodel_name = \"Qwen\u002FQwen-Image\"\n\n# Load the pipeline\nif torch.cuda.is_available():\n    torch_dtype = torch.bfloat16\n    device = \"cuda\"\nelse:\n    torch_dtype = torch.float32\n    device = \"cpu\"\n\npipe = DiffusionPipeline.from_pretrained(model_name, torch_dtype=torch_dtype)\npipe = pipe.to(device)\n```\n\n### 🔧 Qwen-Image-Edit Initialization\n\n```python\nfrom diffusers import QwenImageEditPipeline\nimport torch\nfrom PIL import Image\n\n# Load the pipeline\npipeline = QwenImageEditPipeline.from_pretrained(\"Qwen\u002FQwen-Image-Edit\")\npipeline.to(torch.bfloat16)\npipeline.to(\"cuda\")\n```\n\n### 🔌 Load LoRA Weights\n\nFor Qwen-Image:\n```python\n# Load LoRA weights\npipe.load_lora_weights('flymy-ai\u002Fqwen-image-realism-lora', adapter_name=\"lora\")\n```\n\nFor Qwen-Image-Edit:\n```python\n# Load trained LoRA weights\npipeline.load_lora_weights(\"\u002Fpath\u002Fto\u002Fyour\u002Ftrained\u002Flora\u002Fpytorch_lora_weights.safetensors\")\n```\n\n### 🎨 Generate Image with Qwen-Image LoRA\nYou can find LoRA weights [here](https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fqwen-image-realism-lora)\n\nNo trigger word required\n```python\nprompt = '''Super Realism portrait of a teenager woman of African descent, serene calmness, arms crossed, illuminated by dramatic studio lighting, sunlit park in the background, adorned with delicate jewelry, three-quarter view, sun-kissed skin with natural imperfections, loose shoulder-length curls, slightly squinting eyes, environmental street portrait with text \"FLYMY AI\" on t-shirt.'''\nnegative_prompt =  \" \"\nimage = pipe(\n    prompt=prompt,\n    negative_prompt=negative_prompt,\n    width=1024,\n    height=1024,\n    num_inference_steps=50,\n    true_cfg_scale=5,\n    generator=torch.Generator(device=\"cuda\").manual_seed(346346)\n)\n\n# Display the image (in Jupyter or save to file)\nimage.show()\n# or\nimage.save(\"output.png\")\n```\n\n### 🎨 Edit Image with Qwen-Image-Edit LoRA\n\n```python\n# Load input image\nimage = Image.open(\"\u002Fpath\u002Fto\u002Fyour\u002Finput\u002Fimage.jpg\").convert(\"RGB\")\n\n# Define editing prompt\nprompt = \"Make a shot in the same scene of the person moving further away from the camera, keeping the camera steady to maintain focus on the central subject, gradually zooming out to capture more of the surrounding environment as the figure becomes less detailed in the distance.\"\n\n# Generate edited image\ninputs = {\n    \"image\": image,\n    \"prompt\": prompt,\n    \"generator\": torch.manual_seed(0),\n    \"true_cfg_scale\": 4.0,\n    \"negative_prompt\": \" \",\n    \"num_inference_steps\": 50,\n}\n\nwith torch.inference_mode():\n    output = pipeline(**inputs)\n    output_image = output.images[0]\n    output_image.save(\"edited_image.png\")\n```\n\n### 🖼️ Sample Output - Qwen-Image\n\n![Sample Output](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_3f6f186e03b8.png)\n\n### 🖼️ Sample Output - Qwen-Image-Edit\n\n**Input Image:**\n\n![Input Image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_0a1c8fe7ba7e.jpg)\n\n**Prompt:** \n\"Make a shot in the same scene of the left hand securing the edge of the cutting board while the right hand tilts it, causing the chopped tomatoes to slide off into the pan, camera angle shifts slightly to the left to center more on the pan.\"\n\n**Output without LoRA:**\n\n![Output without LoRA](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_0a1c8fe7ba7e.jpg)\n\n**Output with LoRA:**\n\n![Output with LoRA](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_bec60c97ac57.jpg)\n\n---\n\n# FLUX.1-dev Models Training\n\n## FLUX.1-dev LoRA Training\n\nFLUX.1-dev is a powerful text-to-image model that excels at generating high-quality portraits and character images. Our LoRA training implementation allows you to fine-tune FLUX for specific characters or styles.\n\n### Start FLUX Training\n\nTo begin FLUX LoRA training with your configuration file, run:\n\n```bash\naccelerate launch train_flux_lora.py --config .\u002Ftrain_configs\u002Ftrain_flux_config.yaml\n```\n\nMake sure `train_flux_config.yaml` is correctly set up with paths to your dataset, model, output directory, and other parameters.\n\n### 🔧 FLUX.1-dev Initialization\n\n```python\nfrom diffusers import DiffusionPipeline\nimport torch\n\nmodel_name = \"black-forest-labs\u002FFLUX.1-dev\"\n\n# Load the pipeline\nif torch.cuda.is_available():\n    torch_dtype = torch.bfloat16\n    device = \"cuda\"\nelse:\n    torch_dtype = torch.float32\n    device = \"cpu\"\n\npipe = DiffusionPipeline.from_pretrained(model_name, torch_dtype=torch_dtype)\npipe = pipe.to(device)\n```\n\n### 🔌 Load FLUX LoRA Weights\n\n```python\n# Load LoRA weights\npipe.load_lora_weights('flymy-ai\u002Fflux-dev-anne-hathaway-lora', adapter_name=\"lora\")\n```\n\n### 🎨 Generate Image with FLUX LoRA\n\nYou can find our pre-trained FLUX LoRA weights [here](https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fflux-dev-anne-hathaway-lora)\n\n**Trigger word required: \"ohwx woman\"**\n\n```python\nprompt = '''Portrait of ohwx woman, professional headshot, studio lighting, elegant pose, looking at camera, soft shadows, high quality, detailed facial features, cinematic lighting, 85mm lens, shallow depth of field'''\nnegative_prompt = \"blurry, low quality, distorted, bad anatomy\"\nimage = pipe(\n    prompt=prompt,\n    negative_prompt=negative_prompt,\n    width=1024,\n    height=1024,\n    num_inference_steps=30,\n    guidance_scale=3.5,\n    generator=torch.Generator(device=\"cuda\").manual_seed(346346)\n)\n\n# Display the image (in Jupyter or save to file)\nimage.images[0].show()\n# or\nimage.images[0].save(\"output.png\")\n```\n\n### 🖼️ Sample FLUX Output\n\n![Sample FLUX Output](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_3f6f186e03b8.png)\n\n## 🎨 FLUX Generation Examples\n\nBelow are examples of images generated with our FLUX Anne Hathaway LoRA model:\n\n### Casual Portrait Selfie\n\n**Prompt**: _\"ohwx woman portrait selfie\"_\n\n![Casual Portrait Selfie](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_d0dde7abb51d.png)\n\n### Artistic Double Exposure\n\n**Prompt**: _\"ohwx woman perfectly symmetrical young female face close-up, presented with double exposure overlay blending nature textures like leaves and water\"_\n\n![Artistic Double Exposure](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_33964f759b49.png)\n\n### Golden Hour Macro Portrait\n\n**Prompt**: _\"ohwx woman Macro photography style close-up of female face with light makeup, focused on eyes and lips, illuminated by golden hour sunlight for warm tones\"_\n\n![Golden Hour Macro Portrait](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_793fa637b872.png)\n\n### Cozy Portrait with Panda\n\n**Prompt**: _\"Close-up of ohwx woman in brown knitted turtleneck sweater. Sitting with big black and white panda, hugging it, looking at camera\"_\n\n![Cozy Portrait with Panda](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_4f1df840d8df.png)\n\n### 🚀 Train Your Own FLUX LoRA\n\nWant to train your own FLUX LoRA model? Use our online training platform:\n\n**[🚀 Train Your Own FLUX LoRA on FlyMy.AI](https:\u002F\u002Fapp.flymy.ai\u002Fmodels\u002Fflymyai\u002Fflux-lora-trainer-fast)**\n\nFeatures:\n- ✅ Easy-to-use web interface\n- ✅ No local GPU required\n- ✅ Optimized training pipeline\n- ✅ Fast training times\n- ✅ Professional results\n\n---\n\n## 🎛️ Using with ComfyUI\n\nWe provide ready-to-use ComfyUI workflows that work with both our Qwen and FLUX trained LoRA models. Follow these steps to set up and use the workflows:\n\n### Setup Instructions\n\n1. **Download the latest ComfyUI**:\n   - Visit the [ComfyUI GitHub repository](https:\u002F\u002Fgithub.com\u002Fcomfyanonymous\u002FComfyUI)\n   - Clone or download the latest version\n\n2. **Install ComfyUI**:\n   - Follow the installation instructions from the [ComfyUI repository](https:\u002F\u002Fgithub.com\u002Fcomfyanonymous\u002FComfyUI?tab=readme-ov-file#installing)\n   - Make sure all dependencies are properly installed\n\n3. **Download model weights**:\n   \n   **For Qwen-Image:**\n   - Go to [Qwen-Image ComfyUI weights](https:\u002F\u002Fhuggingface.co\u002FComfy-Org\u002FQwen-Image_ComfyUI\u002Ftree\u002Fmain)\n   - Download all the model files\n   \n   **For FLUX.1-dev:**\n   - Go to [FLUX.1-dev model](https:\u002F\u002Fhuggingface.co\u002Fblack-forest-labs\u002FFLUX.1-dev)\n   - Download all the model files\n\n4. **Place model weights in ComfyUI**:\n   - Copy the downloaded model files to the appropriate folders in `ComfyUI\u002Fmodels\u002F`\n   - Follow the folder structure as specified in the model repositories\n\n5. **Download our pre-trained LoRA weights**:\n   - **Qwen LoRA:** [flymy-ai\u002Fqwen-image-realism-lora](https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fqwen-image-realism-lora)\n   - **FLUX LoRA:** [flymy-ai\u002Fflux-dev-anne-hathaway-lora](https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fflux-dev-anne-hathaway-lora)\n   - Download the LoRA `.safetensors` files\n\n6. **Place LoRA weights in ComfyUI**:\n   - Copy the LoRA files to `ComfyUI\u002Fmodels\u002Floras\u002F`\n\n7. **Load the workflow**:\n   - Open ComfyUI in your browser\n   - **For Qwen:** Load `qwen_image_lora_example.json`\n   - **For FLUX:** Load `flux_anne_hathaway_lora_example.json`\n   - The workflows are pre-configured to work with our LoRA models\n\n### Workflow Features\n\n- ✅ Pre-configured for Qwen-Image + LoRA inference\n- ✅ Pre-configured for FLUX.1-dev + LoRA inference\n- ✅ Optimized settings for best quality output\n- ✅ Easy prompt and parameter adjustment\n- ✅ Compatible with all our trained LoRA models\n\nThe ComfyUI workflows provide a user-friendly interface for generating images with our trained LoRA models without needing to write Python code.\n\n### 🖼️ Workflow Screenshot\n\n![ComfyUI Workflow](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_c7d09ddabce8.png)\n\n---\n\n## 🤝 Support\n\nIf you have questions or suggestions, join our community:\n- 🌐 [FlyMy.AI](https:\u002F\u002Fflymy.ai)\n- 💬 [Discord Community](https:\u002F\u002Fdiscord.com\u002Finvite\u002Ft6hPBpSebw)\n- 🐦 [Follow us on X](https:\u002F\u002Fx.com\u002Fflymyai)\n- 💼 [Connect on LinkedIn](https:\u002F\u002Flinkedin.com\u002Fcompany\u002Fflymyai)\n- 📧 [Support](mailto:support@flymy.ai)\n\n**⭐ Don't forget to star the repository if you like it!**\n","# LoRA 训练：适用于 Qwen-Image、Qwen-Image-Edit 和 FLUX.1-dev\n\n由 [FlyMy.AI](https:\u002F\u002Fflymy.ai) 提供的开源实现，用于训练 Qwen\u002FQwen-Image、Qwen\u002FQwen-Image-Edit 以及 FLUX.1-dev 模型的 LoRA（低秩适应）层。\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_2091053e9469.png\" alt=\"FlyMy.AI Logo\" width=\"256\">\n\u003C\u002Fp>\n\n## 星标历史\n\n[![Star History Chart](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_fb49a5cef69c.png)](https:\u002F\u002Fwww.star-history.com\u002F#FlyMyAI\u002Fflymyai-lora-trainer&Date)\n\n## 🌟 关于 FlyMy.AI\n\n面向生成式 AI 的代理基础设施。FlyMy.AI 是一家面向 B2B 的基础设施提供商，致力于构建和运行生成式 AI 媒体代理。\n\n\n**🔗 有用链接：**\n- 🌐 [官方网站](https:\u002F\u002Fflymy.ai)\n- 📚 [文档](https:\u002F\u002Fdocs.flymy.ai\u002Fintro)\n- 💬 [Discord 社区](https:\u002F\u002Fdiscord.com\u002Finvite\u002Ft6hPBpSebw)\n- 🤗 [预训练的 Qwen LoRA 模型](https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fqwen-image-realism-lora)\n- 🤗 [预训练的 FLUX LoRA 模型](https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fflux-dev-anne-hathaway-lora)\n- 🚀 [训练您自己的 FLUX LoRA](https:\u002F\u002Fapp.flymy.ai\u002Fmodels\u002Fflymyai\u002Fflux-lora-trainer-fast)\n- 🐦 [X (Twitter)](https:\u002F\u002Fx.com\u002Fflymyai)\n- 💼 [LinkedIn](https:\u002F\u002Flinkedin.com\u002Fcompany\u002Fflymyai)\n- 📺 [YouTube](https:\u002F\u002Fyoutube.com\u002F@flymyai)\n- 📸 [Instagram](https:\u002F\u002Fwww.instagram.com\u002Fflymy_ai)\n\n## 🚀 特性\n\n- 基于 LoRA 的微调，实现高效训练\n- 支持 Qwen-Image、Qwen-Image-Edit 和 FLUX.1-dev 模型\n- 兼容 Hugging Face `diffusers`\n- 通过 YAML 文件轻松配置\n- 利用 LoRA 进行基于控制的图像编辑\n- LoRA 训练的开源实现\n- 完整支持 Qwen-Image 的训练\n- 高质量的人像与角色训练，适用于 FLUX 模型\n\n## 📅 更新\n\n**2025年10月16日**\n- ✅ 添加了 FLUX.1-dev 的 LoRA 训练支持\n- ✅ 添加了预训练的 FLUX LoRA 模型示例\n\n**2025年9月2日**\n- ✅ 添加了 Qwen-Image 和 Qwen-Image-Edit 的完整训练功能\n\n**2025年8月20日**\n- ✅ 添加了 Qwen-Image-Edit 的 LoRA 训练支持\n\n**2025年8月9日**\n- ✅ 添加了适用于显存小于 24GiB GPU 的训练流程\n\n**2025年8月8日**\n- ✅ 添加了全面的数据集准备说明\n- ✅ 添加了数据集验证脚本 (`utils\u002Fvalidate_dataset.py`)\n- ✅ 在训练过程中冻结模型权重\n\n## ⚠️ 项目状态\n\n**🚧 开发中：** 我们正在积极改进代码并增加测试覆盖率。该项目目前处于优化阶段，但已可投入使用。\n\n**📋 开发计划：**\n- ✅ 基础代码已可用\n- ✅ 已实现训练功能\n- ✅ 已添加 FLUX.1-dev 支持\n- 🔄 正在进行性能优化\n- 🔜 测试覆盖率即将推出\n\n---\n\n## 📦 安装\n\n**要求：**\n- Python 3.10\n\n1. 克隆仓库并进入目录：\n   ```bash\n   git clone https:\u002F\u002Fgithub.com\u002FFlyMyAI\u002Fflymyai-lora-trainer\n   cd flymyai-lora-trainer\n   ```\n\n2. 安装所需依赖包：\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n3. 从 GitHub 安装最新版 `diffusers`：\n   ```bash\n   pip install git+https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdiffusers\n   ```\n\n4. 下载预训练的 LoRA 权重（可选）：\n   ```bash\n   # Qwen LoRA 权重\n   git clone https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fqwen-image-realism-lora\n   \n   # FLUX LoRA 权重\n   git clone https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fflux-dev-anne-hathaway-lora\n   \n   # 或者直接下载特定文件\n   wget https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fqwen-image-realism-lora\u002Fresolve\u002Fmain\u002Fflymy_realism.safetensors\n   wget https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fflux-dev-anne-hathaway-lora\u002Fresolve\u002Fmain\u002Fpytorch_lora_weights.safetensors\n   ```\n\n---\n\n## 📁 数据准备\n\n### 训练用数据集结构\n\n无论是 Qwen 还是 FLUX 模型，训练数据都应遵循相同的格式：每张图片都对应一个同名的文本文件。\n\n```\ndataset\u002F\n├── img1.png\n├── img1.txt\n├── img2.jpg\n├── img2.txt\n├── img3.png\n├── img3.txt\n└── ...\n```\n\n### Qwen-Image-Edit 训练用数据集结构\n\n对于基于控制的图像编辑，数据集应分为目标图像及描述和控制图像两个独立目录：\n\n```\ndataset\u002F\n├── images\u002F           # 目标图像及其描述\n│   ├── image_001.jpg\n│   ├── image_001.txt\n│   ├── image_002.jpg\n│   ├── image_002.txt\n│   └── ...\n└── control\u002F          # 控制图像\n    ├── image_001.jpg\n    ├── image_002.jpg\n    └── ...\n```\n\n### 数据格式要求\n\n1. **图像**：支持常见格式（PNG、JPG、JPEG、WEBP）\n2. **文本文件**：包含图像描述的纯文本文件\n3. **文件命名**：每张图像必须有一个与其同名的文本文件\n\n### 示例数据结构\n\n```\nmy_training_data\u002F\n├── portrait_001.png\n├── portrait_001.txt\n├── landscape_042.jpg\n├── landscape_042.txt\n├── abstract_design.png\n├── abstract_design.txt\n└── style_reference.jpg\n└── style_reference.txt\n```\n\n### 文本文件内容示例\n\n**针对 FLUX 角色训练（portrait_001.txt）：**\n```\nohwx 女性，专业人像照，影棚灯光，优雅姿势，直视镜头\n```\n\n**针对 Qwen 风景训练（landscape_042.txt）：**\n```\n日落时分的山地景观，壮丽云海，金色时刻的光线，广角视角\n```\n\n**针对 FLUX 人像训练（abstract_design.txt）：**\n```\nohwx 女性，现代人像风格，柔和光线，艺术构图\n```\n\n### 数据准备提示\n\n1. **图像质量**：使用高分辨率图像（建议 1024×1024 或更高）\n2. **描述质量**：撰写详细且准确的图像描述\n3. **一致性**：确保数据集中风格和质量的一致性\n4. **数据集规模**：为获得良好效果，建议至少使用 10–50 组图像-文本对\n5. **触发词**：\n   - 对于 FLUX 角色训练：使用“ohwx 女性”或“ohwx 男性”作为触发词\n   - 对于 Qwen 训练：无需特定触发词\n6. **自动生成描述**：您可以使用 [Florence-2](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fgokaygokay\u002FFlorence-2) 自动生成功能来生成图像描述。\n\n### 快速数据验证\n\n您可以使用附带的验证工具来检查数据结构：\n\n```bash\npython utils\u002Fvalidate_dataset.py --path path\u002Fto\u002Fyour\u002Fdataset\n```\n\n该工具将检查：\n- 每张图像是否都有对应的文本文件\n- 所有文件是否遵循正确的命名规范\n- 报告任何缺失的文件或不一致之处\n\n---\n\n## 🏁 在显存小于 24GB 的设备上开始训练\n\n要使用您的配置文件（例如 `train_lora_4090.yaml`）开始训练，请运行：\n\n```bash\naccelerate launch train_4090.py --config .\u002Ftrain_configs\u002Ftrain_lora_4090.yaml\n```\n![示例输出](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_8403cd7270da.jpg)\n\n\n## 🏁 训练\n\n# Qwen 模型训练\n\n## Qwen-Image LoRA 训练\n\n要使用您的配置文件（例如 `train_lora.yaml`）开始训练，请运行：\n\n```bash\naccelerate launch train.py --config .\u002Ftrain_configs\u002Ftrain_lora.yaml\n```\n\n请确保 `train_lora.yaml` 已正确设置好数据集路径、模型路径、输出目录及其他参数。\n\n### Qwen-Image 全模型训练\n\n要使用你的配置文件（例如 `train_full_qwen_image.yaml`）开始训练，请运行：\n\n```bash\naccelerate launch train_full_qwen_image.py --config .\u002Ftrain_configs\u002Ftrain_full_qwen_image.yaml\n```\n\n请确保 `train_full_qwen_image.yaml` 已正确设置，包含数据集、模型、输出目录及其他参数的路径。\n所提出的方法在 NVIDIA H200 GPU 环境上进行了测试。\n#### 加载训练好的全模型\n\n训练完成后，你可以从检查点目录加载训练好的模型以进行推理。\n\n**简单示例：**\n\n```python\nfrom diffusers import QwenImagePipeline, QwenImageTransformer2DModel, AutoencoderKLQwenImage\nimport torch\nfrom omegaconf import OmegaConf\nimport os\n\ndef load_trained_model(checkpoint_path):\n    \"\"\"从检查点加载训练好的模型\"\"\"\n    print(f\"从 {checkpoint_path} 加载训练好的模型\")\n    \n    # 加载配置文件以获取原始模型路径\n    config_path = os.path.join(checkpoint_path, \"config.yaml\")\n    config = OmegaConf.load(config_path)\n    original_model_path = config.pretrained_model_name_or_path\n    \n    # 加载训练好的 Transformer\n    transformer_path = os.path.join(checkpoint_path, \"transformer\")\n    transformer = QwenImageTransformer2DModel.from_pretrained(\n        transformer_path,\n        torch_dtype=torch.bfloat16,\n        low_cpu_mem_usage=True\n    )\n    transformer.to(\"cuda\")\n    transformer.eval()\n    \n    # 从原始模型加载 VAE\n    vae = AutoencoderKLQwenImage.from_pretrained(\n        original_model_path,\n        subfolder=\"vae\",\n        torch_dtype=torch.bfloat16\n    )\n    vae.to(\"cuda\")\n    vae.eval()\n    \n    # 创建管道\n    pipe = QwenImagePipeline.from_pretrained(\n        original_model_path,\n        transformer=transformer,\n        vae=vae,\n        torch_dtype=torch.bfloat16\n    )\n    pipe.to(\"cuda\")\n    \n    print(\"模型加载成功！\")\n    return pipe\n\n# 使用方法\ncheckpoint_path = \"\u002Fpath\u002Fto\u002Fyour\u002Fcheckpoint\"\npipe = load_trained_model(checkpoint_path)\n\n# 生成图像\nprompt = \"一幅美丽的山水风景画\"\nimage = pipe(\n    prompt=prompt,\n    width=768,\n    height=768,\n    num_inference_steps=30,\n    true_cfg_scale=5,\n    generator=torch.Generator(device=\"cuda\").manual_seed(42)\n)\n\n# 保存结果\noutput_image = image.images[0]\noutput_image.save(\"generated_image.png\")\n```\n\n**完整示例脚本：**\n\n```bash\npython inference_trained_model_gpu_optimized.py\n```\n\n**检查点结构：**\n\n训练好的模型以如下结构保存：\n```\ncheckpoint\u002F\n├── config.yaml          # 训练配置文件\n└── transformer\u002F         # 训练好的 Transformer 权重\n    ├── config.json\n    ├── diffusion_pytorch_model.safetensors.index.json\n    └── diffusion_pytorch_model-00001-of-00005.safetensors\n    └── ... (多个分片文件)\n```\n\n\n### Qwen-Image-Edit LoRA 训练\n\n对于基于控制的图像编辑训练，使用专门的训练脚本：\n\n```bash\naccelerate launch train_qwen_edit_lora.py --config .\u002Ftrain_configs\u002Ftrain_lora_qwen_edit.yaml\n```\n\n#### Qwen-Image-Edit 的配置\n\n配置文件 `train_lora_qwen_edit.yaml` 应包含以下内容：\n\n- `img_dir`: 目标图像和说明文字目录的路径（例如 `.\u002Fextracted_dataset\u002Ftrain\u002Fimages`）\n- `control_dir`: 控制图像目录的路径（例如 `.\u002Fextracted_dataset\u002Ftrain\u002Fcontrol`）\n- 其他标准的 LoRA 训练参数\n\n## 🧪 使用方法\n\n### Qwen-Image-Edit 全模型训练\n\n要使用你的配置文件（例如 `train_full_qwen_edit.yaml`）开始训练，请运行：\n\n```bash\naccelerate launch train_full_qwen_edit.py --config .\u002Ftrain_configs\u002Ftrain_full_qwen_edit.yaml\n```\n\n---\n\n### 🔧 Qwen-Image 初始化\n\n```python\nfrom diffusers import DiffusionPipeline\nimport torch\n\nmodel_name = \"Qwen\u002FQwen-Image\"\n\n# 加载管道\nif torch.cuda.is_available():\n    torch_dtype = torch.bfloat16\n    device = \"cuda\"\nelse:\n    torch_dtype = torch.float32\n    device = \"cpu\"\n\npipe = DiffusionPipeline.from_pretrained(model_name, torch_dtype=torch_dtype)\npipe = pipe.to(device)\n```\n\n### 🔧 Qwen-Image-Edit 初始化\n\n```python\nfrom diffusers import QwenImageEditPipeline\nimport torch\nfrom PIL import Image\n\n# 加载管道\npipeline = QwenImageEditPipeline.from_pretrained(\"Qwen\u002FQwen-Image-Edit\")\npipeline.to(torch.bfloat16)\npipeline.to(\"cuda\")\n```\n\n### 🔌 加载 LoRA 权重\n\n对于 Qwen-Image：\n```python\n# 加载 LoRA 权重\npipe.load_lora_weights('flymy-ai\u002Fqwen-image-realism-lora', adapter_name=\"lora\")\n```\n\n对于 Qwen-Image-Edit：\n```python\n# 加载训练好的 LoRA 权重\npipeline.load_lora_weights(\"\u002Fpath\u002Fto\u002Fyour\u002Ftrained\u002Flora\u002Fpytorch_lora_weights.safetensors\")\n```\n\n### 🎨 使用 Qwen-Image LoRA 生成图像\n你可以在 [这里](https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fqwen-image-realism-lora) 找到 LoRA 权重。\n\n无需触发词\n```python\nprompt = '''一位非洲裔青少年女性的超写实肖像，神情宁静安详，双臂交叉，被戏剧性的影棚灯光照亮，背景是阳光明媚的公园，佩戴精致的珠宝，四分之三侧面像，肌肤晒得健康自然，带有天然瑕疵，披散着及肩的卷发，眼睛微微眯起，环境为街头人像，T恤上印有“FLYMY AI”字样。'''\nnegative_prompt =  \" \"\nimage = pipe(\n    prompt=prompt,\n    negative_prompt=negative_prompt,\n    width=1024,\n    height=1024,\n    num_inference_steps=50,\n    true_cfg_scale=5,\n    generator=torch.Generator(device=\"cuda\").manual_seed(346346)\n)\n\n# 显示图像（在 Jupyter 中或保存到文件）\nimage.show()\n# 或\nimage.save(\"output.png\")\n```\n\n### 🎨 使用 Qwen-Image-Edit LoRA 编辑图像\n\n```python\n# 加载输入图像\nimage = Image.open(\"\u002Fpath\u002Fto\u002Fyour\u002Finput\u002Fimage.jpg\").convert(\"RGB\")\n\n# 定义编辑提示\nprompt = \"在同一场景中拍摄一张画面，人物逐渐远离相机，保持相机稳定以聚焦于主体，同时镜头慢慢拉远，捕捉更多周围环境，远处的人物细节逐渐模糊。\"\n\n# 生成编辑后的图像\ninputs = {\n    \"image\": image,\n    \"prompt\": prompt,\n    \"generator\": torch.manual_seed(0),\n    \"true_cfg_scale\": 4.0,\n    \"negative_prompt\": \" \",\n    \"num_inference_steps\": 50,\n}\n\nwith torch.inference_mode():\n    output = pipeline(**inputs)\n    output_image = output.images[0]\n    output_image.save(\"edited_image.png\")\n```\n\n### 🖼️ 示例输出 - Qwen-Image\n\n![示例输出](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_3f6f186e03b8.png)\n\n### 🖼️ 示例输出 - Qwen-Image-Edit\n\n**输入图像：**\n\n![输入图像](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_0a1c8fe7ba7e.jpg)\n\n**提示：**\n“在同一场景中拍摄一张画面，左手固定砧板边缘，右手倾斜砧板，使切碎的番茄滑入锅中，摄像机角度略微向左移动，以便更集中地拍摄锅中的食材。”\n\n**无 LoRA 输出：**\n\n![无 LoRA 输出](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_0a1c8fe7ba7e.jpg)\n\n**LoRA 输出：**\n\n![LoRA 输出](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_bec60c97ac57.jpg)\n\n---\n\n# FLUX.1-dev 模型训练\n\n## FLUX.1-dev LoRA 训练\n\nFLUX.1-dev 是一款功能强大的文生图模型，特别擅长生成高质量的人像和角色图像。我们的 LoRA 训练实现允许您针对特定角色或风格对 FLUX 进行微调。\n\n### 开始 FLUX 训练\n\n要使用您的配置文件开始 FLUX LoRA 训练，请运行：\n\n```bash\naccelerate launch train_flux_lora.py --config .\u002Ftrain_configs\u002Ftrain_flux_config.yaml\n```\n\n请确保 `train_flux_config.yaml` 已正确设置，包含数据集、模型、输出目录等路径及其他参数。\n\n### 🔧 FLUX.1-dev 初始化\n\n```python\nfrom diffusers import DiffusionPipeline\nimport torch\n\nmodel_name = \"black-forest-labs\u002FFLUX.1-dev\"\n\n# 加载管道\nif torch.cuda.is_available():\n    torch_dtype = torch.bfloat16\n    device = \"cuda\"\nelse:\n    torch_dtype = torch.float32\n    device = \"cpu\"\n\npipe = DiffusionPipeline.from_pretrained(model_name, torch_dtype=torch_dtype)\npipe = pipe.to(device)\n```\n\n### 🔌 加载 FLUX LoRA 权重\n\n```python\n# 加载 LoRA 权重\npipe.load_lora_weights('flymy-ai\u002Fflux-dev-anne-hathaway-lora', adapter_name=\"lora\")\n```\n\n### 🎨 使用 FLUX LoRA 生成图像\n\n您可以在此处找到我们预训练的 FLUX LoRA 权重：[https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fflux-dev-anne-hathaway-lora](https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fflux-dev-anne-hathaway-lora)\n\n**需要触发词：“ohwx woman”**\n\n```python\nprompt = '''ohwx 女性的肖像，专业头像，影棚灯光，优雅姿势，直视镜头，柔和阴影，高质量，细致面部特征，电影级灯光，85mm 镜头，浅景深'''\nnegative_prompt = \"模糊，低质量，扭曲，解剖结构错误\"\nimage = pipe(\n    prompt=prompt,\n    negative_prompt=negative_prompt，\n    宽度=1024，\n    高度=1024，\n    推理步数=30，\n    引导系数=3.5，\n    生成器=torch.Generator(device=\"cuda\").manual_seed(346346)\n)\n\n# 显示图像（在 Jupyter 中）或保存到文件\nimage.images[0].show()\n# 或\nimage.images[0].save(\"output.png\")\n```\n\n### 🖼️ FLUX 输出示例\n\n![FLUX 输出示例](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_3f6f186e03b8.png)\n\n## 🎨 FLUX 生成示例\n\n以下是使用我们的 FLUX Anne Hathaway LoRA 模型生成的图像示例：\n\n### 休闲人像自拍\n\n**提示词**：_“ohwx 女性肖像自拍”_\n\n![休闲人像自拍](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_d0dde7abb51d.png)\n\n### 艺术双曝光\n\n**提示词**：_“ohwx 女性完美对称的年轻女性脸部特写，以双曝光叠加呈现，融合树叶和水等自然纹理”_\n\n![艺术双曝光](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_33964f759b49.png)\n\n### 黄金时段微距人像\n\n**提示词**：_“ohwx 女性微距摄影风格的女性脸部特写，化着淡妆，重点突出眼睛和嘴唇，在黄金时段阳光下呈现出温暖色调”_\n\n![黄金时段微距人像](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_793fa637b872.png)\n\n### 温馨熊猫人像\n\n**提示词**：_“ohwx 女性身穿棕色针织高领毛衣的特写。她与一只黑白相间的胖熊猫依偎在一起，抱着它，直视镜头”_\n\n![温馨熊猫人像](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_4f1df840d8df.png)\n\n### 🚀 训练您自己的 FLUX LoRA\n\n想训练属于您自己的 FLUX LoRA 模型吗？请使用我们的在线训练平台：\n\n**[🚀 在 FlyMy.AI 上训练您自己的 FLUX LoRA](https:\u002F\u002Fapp.flymy.ai\u002Fmodels\u002Fflymyai\u002Fflux-lora-trainer-fast)**\n\n特点：\n- ✅ 简单易用的网页界面\n- ✅ 无需本地 GPU\n- ✅ 优化的训练流程\n- ✅ 快速训练时间\n- ✅ 专业级效果\n\n---\n\n## 🎛️ 与 ComfyUI 结合使用\n\n我们提供了开箱即用的 ComfyUI 工作流，可同时用于我们训练的 Qwen 和 FLUX LoRA 模型。请按照以下步骤设置并使用这些工作流：\n\n### 设置说明\n\n1. **下载最新版 ComfyUI**：\n   - 访问 [ComfyUI GitHub 仓库](https:\u002F\u002Fgithub.com\u002Fcomfyanonymous\u002FComfyUI)\n   - 克隆或下载最新版本\n\n2. **安装 ComfyUI**：\n   - 按照 [ComfyUI 仓库](https:\u002F\u002Fgithub.com\u002Fcomfyanonymous\u002FComfyUI?tab=readme-ov-file#installing) 中的安装说明操作\n   - 确保所有依赖项均已正确安装\n\n3. **下载模型权重**：\n\n   **对于 Qwen-Image：**\n   - 前往 [Qwen-Image ComfyUI 权重](https:\u002F\u002Fhuggingface.co\u002FComfy-Org\u002FQwen-Image_ComfyUI\u002Ftree\u002Fmain)\n   - 下载所有模型文件\n\n   **对于 FLUX.1-dev：**\n   - 前往 [FLUX.1-dev 模型](https:\u002F\u002Fhuggingface.co\u002Fblack-forest-labs\u002FFLUX.1-dev)\n   - 下载所有模型文件\n\n4. **将模型权重放入 ComfyUI**：\n   - 将下载的模型文件复制到 `ComfyUI\u002Fmodels\u002F` 中的相应文件夹\n   - 按照模型仓库中指定的文件夹结构进行操作\n\n5. **下载我们预训练的 LoRA 权重**：\n   - **Qwen LoRA：** [flymy-ai\u002Fqwen-image-realism-lora](https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fqwen-image-realism-lora)\n   - **FLUX LoRA：** [flymy-ai\u002Fflux-dev-anne-hathaway-lora](https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fflux-dev-anne-hathaway-lora)\n   - 下载 LoRA 的 `.safetensors` 文件\n\n6. **将 LoRA 权重放入 ComfyUI**：\n   - 将 LoRA 文件复制到 `ComfyUI\u002Fmodels\u002Floras\u002F` 目录中\n\n7. **加载工作流**：\n   - 在浏览器中打开 ComfyUI\n   - **对于 Qwen：** 加载 `qwen_image_lora_example.json`\n   - **对于 FLUX：** 加载 `flux_anne_hathaway_lora_example.json`\n   - 这些工作流已预先配置好，可与我们的 LoRA 模型配合使用\n\n### 工作流特点\n\n- ✅ 预先配置用于 Qwen-Image + LoRA 推理\n- ✅ 预先配置用于 FLUX.1-dev + LoRA 推理\n- ✅ 优化的设置以获得最佳画质\n- ✅ 方便调整提示词和参数\n- ✅ 兼容我们训练的所有 LoRA 模型\n\nComfyUI 工作流提供了一个用户友好的界面，让您无需编写 Python 代码即可使用我们训练好的 LoRA 模型生成图像。\n\n### 🖼️ 工作流截图\n\n![ComfyUI 工作流](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_readme_c7d09ddabce8.png)\n\n---\n\n## 🤝 支持\n\n如果您有任何问题或建议，请加入我们的社区：\n- 🌐 [FlyMy.AI](https:\u002F\u002Fflymy.ai)\n- 💬 [Discord 社区](https:\u002F\u002Fdiscord.com\u002Finvite\u002Ft6hPBpSebw)\n- 🐦 [在 X 上关注我们](https:\u002F\u002Fx.com\u002Fflymyai)\n- 💼 [在 LinkedIn 上联系我们](https:\u002F\u002Flinkedin.com\u002Fcompany\u002Fflymyai)\n- 📧 [支持邮箱](mailto:support@flymy.ai)\n\n**⭐ 如果您喜欢这个项目，请别忘了给仓库点个赞！**","# flymyai-lora-trainer 快速上手指南\n\nflymyai-lora-trainer 是一个开源工具，支持对 **Qwen-Image**、**Qwen-Image-Edit** 和 **FLUX.1-dev** 模型进行 LoRA（低秩适应）微调训练。本指南将帮助你快速完成环境搭建并开始训练。\n\n## 环境准备\n\n在开始之前，请确保你的开发环境满足以下要求：\n\n*   **操作系统**: Linux (推荐) 或 Windows (需配置相应 CUDA 环境)\n*   **Python 版本**: 3.10\n*   **GPU 显存**: \n    *   标准训练：建议 24GB 及以上 (如 RTX 3090\u002F4090, A10\u002FA100)\n    *   低显存优化：支持 \u003C 24GB 显存方案 (见训练章节)\n*   **依赖库**: PyTorch (需支持 CUDA), `diffusers` (最新版)\n\n## 安装步骤\n\n### 1. 克隆项目\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FFlyMyAI\u002Fflymyai-lora-trainer\ncd flymyai-lora-trainer\n```\n\n### 2. 安装基础依赖\n建议使用国内镜像源加速安装（如清华源）：\n```bash\npip install -r requirements.txt -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n```\n\n### 3. 安装最新版 diffusers\n官方要求从 GitHub 安装最新的 `diffusers` 以支持新模型特性：\n```bash\npip install git+https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdiffusers\n```\n\n### 4. (可选) 下载预训练权重\n如果你只想测试推理或作为参考，可以下载官方提供的预训练 LoRA 权重：\n```bash\n# Qwen LoRA 权重\nwget https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fqwen-image-realism-lora\u002Fresolve\u002Fmain\u002Fflymy_realism.safetensors\n\n# FLUX LoRA 权重\nwget https:\u002F\u002Fhuggingface.co\u002Fflymy-ai\u002Fflux-dev-anne-hathaway-lora\u002Fresolve\u002Fmain\u002Fpytorch_lora_weights.safetensors\n```\n\n## 基本使用\n\n### 第一步：准备数据集\n\n训练数据需要成对的图像和文本描述文件，文件名必须一致（仅扩展名不同）。\n\n**目录结构示例：**\n```text\ndataset\u002F\n├── img1.png\n├── img1.txt          # 内容：A beautiful portrait of a woman...\n├── img2.jpg\n├── img2.txt          # 内容：A landscape with mountains...\n└── ...\n```\n\n**针对 Qwen-Image-Edit (可控编辑) 的特殊结构：**\n```text\ndataset\u002F\n├── images\u002F           # 目标图像及其描述\n│   ├── image_001.jpg\n│   ├── image_001.txt\n│   └── ...\n└── control\u002F          # 控制图像 (无需 txt)\n    ├── image_001.jpg\n    └── ...\n```\n\n**数据准备提示：**\n*   **格式**: 支持 PNG, JPG, WEBP。\n*   **分辨率**: 推荐 1024x1024 或更高。\n*   **数量**: 建议至少准备 10-50 张图片以获得良好效果。\n*   **触发词**: \n    *   FLUX 人物训练：建议在描述中加入 `ohwx woman` 或 `ohwx man`。\n    *   Qwen 训练：无需特定触发词。\n*   **验证**: 运行以下命令检查数据集格式是否正确：\n    ```bash\n    python utils\u002Fvalidate_dataset.py --path path\u002Fto\u002Fyour\u002Fdataset\n    ```\n\n### 第二步：配置训练参数\n\n复制并修改配置文件（位于 `train_configs\u002F` 目录下），主要调整以下字段：\n*   `img_dir`: 数据集路径\n*   `output_dir`: 模型保存路径\n*   `pretrained_model_name_or_path`: 基座模型路径或 HuggingFace ID\n*   `resolution`: 训练分辨率\n\n### 第三步：开始训练\n\n根据显卡显存大小选择对应的启动脚本。\n\n#### 方案 A：显存 \u003C 24GB (优化版)\n适用于消费级显卡（如 3080, 4070 等）：\n```bash\naccelerate launch train_4090.py --config .\u002Ftrain_configs\u002Ftrain_lora_4090.yaml\n```\n\n#### 方案 B：标准训练 (Qwen-Image LoRA)\n适用于 24GB+ 显存：\n```bash\naccelerate launch train.py --config .\u002Ftrain_configs\u002Ftrain_lora.yaml\n```\n\n#### 方案 C：Qwen-Image 全量微调\n```bash\naccelerate launch train_full_qwen_image.py --config .\u002Ftrain_configs\u002Ftrain_full_qwen_image.yaml\n```\n\n#### 方案 D：Qwen-Image-Edit LoRA 训练\n```bash\naccelerate launch train_qwen_edit_lora.py --config .\u002Ftrain_configs\u002Ftrain_lora_qwen_edit.yaml\n```\n\n### 第四步：加载与推理 (Python 示例)\n\n训练完成后，你可以使用以下代码加载生成的 LoRA 权重进行绘图（以 Qwen-Image 为例）：\n\n```python\nfrom diffusers import DiffusionPipeline\nimport torch\n\n# 1. 初始化基座模型\nmodel_name = \"Qwen\u002FQwen-Image\"\npipe = DiffusionPipeline.from_pretrained(model_name, torch_dtype=torch.bfloat16)\npipe.to(\"cuda\")\n\n# 2. 加载训练好的 LoRA 权重\n# 替换为你的本地路径或 HF 仓库地址\npipe.load_lora_weights(\".\u002Foutput_dir\u002Fcheckpoint-1000\", adapter_name=\"my_lora\")\npipe.set_adapters([\"my_lora\"], [1.0]) # 设置权重比例\n\n# 3. 生成图像\nprompt = \"A futuristic cityscape at night, cyberpunk style, neon lights\"\nimage = pipe(\n    prompt=prompt,\n    width=1024,\n    height=1024,\n    num_inference_steps=30,\n    generator=torch.Generator(device=\"cuda\").manual_seed(42)\n).images[0]\n\n# 4. 保存结果\nimage.save(\"result.png\")\n```\n\n> **注意**：对于 FLUX 模型，请使用 `FluxPipeline` 并加载 `.safetensors` 格式的 LoRA 文件；对于 Qwen-Image-Edit，请使用 `QwenImageEditPipeline` 并传入 control_image 参数。","一家独立游戏工作室急需为新作生成风格统一的角色立绘，但现有通用模型无法还原其独特的手绘美术风格。\n\n### 没有 flymyai-lora-trainer 时\n- **风格割裂严重**：直接使用原生 Qwen-Image 或 FLUX.1-dev 模型生成的角色，虽然细节丰富，但完全丢失了工作室特有的笔触和上色风格，导致素材无法直接商用。\n- **微调门槛极高**：尝试自行编写训练代码时，面临显存优化难题，普通消费级显卡（\u003C24GiB）频繁爆显存，且缺乏针对 Qwen-Image-Edit 的控制编辑支持。\n- **数据整理繁琐**：手动构建数据集极易出错，缺乏自动验证脚本，常因图片与文本标签不匹配导致训练中途失败，浪费数小时算力。\n- **迭代周期漫长**：每次调整风格都需要重新配置复杂的训练环境，从准备数据到产出可用模型往往耗时数天，严重拖慢美术迭代进度。\n\n### 使用 flymyai-lora-trainer 后\n- **风格完美复刻**：利用其对 Qwen-Image 和 FLUX.1-dev 的全量训练支持，仅用少量样本即可训练出高度还原手绘质感的 LoRA 模型，生成图可直接融入游戏管线。\n- **低显存友好**：借助专为 \u003C24GiB GPU 优化的训练管道，开发者在单张 RTX 3090 上也能流畅运行全流程，无需昂贵的高端集群。\n- **流程自动化**：通过内置的数据集验证脚本（`validate_dataset.py`）和清晰的 YAML 配置，自动检查图文对应关系，将数据准备时间从数小时缩短至几分钟。\n- **高效可控迭代**：支持基于控制图的图像编辑训练，美术人员可快速调整角色姿态或局部细节，实现“上午提需求，下午出成品”的敏捷开发。\n\nflymyai-lora-trainer 将高门槛的模型定制化训练转化为标准化的工作流，让中小团队也能低成本拥有专属的 AI 美术资产生产线。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FFlyMyAI_flymyai-lora-trainer_8403cd72.jpg","FlyMyAI","FlyMy.AI","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FFlyMyAI_c13448e9.png","Agentic AI Cloud",null,"O_o@flymy.ai","https:\u002F\u002Fflymy.ai","https:\u002F\u002Fgithub.com\u002FFlyMyAI",[81],{"name":82,"color":83,"percentage":84},"Python","#3572A5",100,726,63,"2026-04-07T08:10:34","NOASSERTION","Linux","必需 NVIDIA GPU。支持显存小于 24GB 的显卡（如 RTX 4090），官方测试环境为 NVIDIA H200。需支持 CUDA（具体版本未说明，通常需配合 PyTorch 版本）。","未说明",{"notes":93,"python":94,"dependencies":95},"1. 必须从 GitHub 安装最新版的 `diffusers` 库，而非 PyPI 版本。\n2. 项目提供专门脚本 (`train_4090.py`) 以支持在显存小于 24GB 的 GPU 上进行训练。\n3. 训练 Qwen-Image 全量模型时建议在高性能 GPU（如 H200）环境下运行。\n4. 数据集准备需确保每张图像都有同名的文本描述文件，并提供了验证脚本。","3.10",[96,97,98,99,100,101],"torch","diffusers (GitHub 最新版)","accelerate","omegaconf","Pillow","transformers",[15,14],"2026-03-27T02:49:30.150509","2026-04-09T21:34:16.139636",[106,111,116,121,126,131],{"id":107,"question_zh":108,"answer_zh":109,"source_url":110},26640,"加载模型分片（shards）时出现内存溢出（OOM）错误，即使拥有大内存（如 32GB\u002F64GB）也会失败，如何解决？","这是由于默认参数加载导致 CPU 内存不足。请在加载 transformer 模型时添加 `low_cpu_mem_usage=True` 和 `use_safetensors=True` 参数。示例代码如下：\n\n```python\nflux_transformer = QwenImageTransformer2DModel.from_pretrained(\n    args.pretrained_model_name_or_path,\n    subfolder=\"transformer\",\n    low_cpu_mem_usage=True,\n    use_safetensors=True,\n    torch_dtype=torch.bfloat16\n)\n```\n\n此外，确保系统拥有足够的物理内存（建议 64GB 以上），如果是 WSL 用户，需检查 `.wslconfig` 配置以确保容器能访问宿主机的全部内存。","https:\u002F\u002Fgithub.com\u002FFlyMyAI\u002Fflymyai-lora-trainer\u002Fissues\u002F11",{"id":112,"question_zh":113,"answer_zh":114,"source_url":115},26641,"在 24GB 或 48GB 显存的机器上训练 qwen-image-edit LoRA 时报告 OOM，官方文档称 24GB 即可运行，该如何优化配置？","需要在配置文件中进行以下关键设置以降低内存占用：\n1. 设置 `quantize: true` 启用量化。\n2. 设置 `adam8bit: true` 使用 8 位 Adam 优化器。\n3. 设置 `save_cache_on_disk: true` 将缓存保存到磁盘而非内存。\n4. 确保 `mixed_precision` 设置为 \"bf16\"。\n\n如果仍然报错，请检查是否使用了 WSL，WSL 默认可能未分配全部主机内存，需创建 `.wslconfig` 文件调整内存限制。","https:\u002F\u002Fgithub.com\u002FFlyMyAI\u002Fflymyai-lora-trainer\u002Fissues\u002F32",{"id":117,"question_zh":118,"answer_zh":119,"source_url":120},26642,"在 Windows 上安装依赖时，deepspeed 编译报错 \"fatal error LNK1181: 无法打开输入文件'aio.lib'\" 或 \"No module named 'cpuinfo'\"，如何解决？","这是 Windows 环境下缺少特定依赖导致的编译错误。请按以下步骤操作：\n1. 在安装 requirements 之前，先手动安装 cpuinfo 模块：\n   `pip install py-cpuinfo`\n2. 如果仍然遇到 `aio.lib` 链接错误，这通常是因为 Windows 下 deepspeed 的某些算子编译需要特定的构建环境。如果不需要 deepspeed 的高级功能（如多卡分布式训练），可以尝试在 requirements 中移除或注释掉 deepspeed 相关行，或者寻找预编译的 deepspeed wheel 包。对于单卡用户（如仅有一张 5090\u002F4090），通常可以不安装 deepspeed 或使用简化版配置。","https:\u002F\u002Fgithub.com\u002FFlyMyAI\u002Fflymyai-lora-trainer\u002Fissues\u002F24",{"id":122,"question_zh":123,"answer_zh":124,"source_url":125},26643,"训练时报错 `KeyError: '.txt'` 或 `RecursionError`，提示找不到文本嵌入或递归深度超限，原因是什么？","该问题通常由数据集路径配置错误或文件名不匹配引起。具体原因及解决方法如下：\n1. **路径问题**：如果在配置文件中使用相对路径（如 `..\u002Fdatasets\u002Fimages\u002F123.jpg`），代码分割文件名时可能会错误地提取出 `.txt` 作为键。请尝试使用绝对路径，或检查代码中处理文件名的逻辑。\n2. **文件缺失或不匹配**：确保 `img_dir` 目录下的每张图像（例如 `image_001.jpg`）都有一个同名的 `.txt` 文件（即 `image_001.txt`），且该文件包含对应的提示词（prompt）。\n3. **配置检查**：确认配置文件中的 `img_dir` 指向包含图像的文件夹，`control_dir`（如有）指向控制图像文件夹。如果 `.txt` 文件缺失、命名不一致或位于其他目录，数据加载器会失败。","https:\u002F\u002Fgithub.com\u002FFlyMyAI\u002Fflymyai-lora-trainer\u002Fissues\u002F59",{"id":127,"question_zh":128,"answer_zh":129,"source_url":130},26644,"使用高分辨率图片（如 3000*2000）训练时直接发生内存溢出（Killed -9），即使拥有多张 4090 和大内存，该如何调整？","高分辨率图片会急剧增加显存和系统内存的消耗。解决方案包括：\n1. **降低分辨率**：将训练图片预处理为较小的分辨率（如 1024x1024 或 900x600），不要直接使用 3000px 级别的原始图片进行训练。\n2. **检查 Batch Size**：确保 `train_batch_size` 设置为 1，并适当增加 `gradient_accumulation_steps` 来模拟更大的 batch size。\n3. **开启优化选项**：务必开启 `quantize: true` 和 `adam8bit: true`。\n即使硬件配置很高（如 3 张 4090 + 128GB 内存），未经优化的超大分辨率加载过程仍会导致操作系统触发 OOM Killer 杀死进程。","https:\u002F\u002Fgithub.com\u002FFlyMyAI\u002Fflymyai-lora-trainer\u002Fissues\u002F17",{"id":132,"question_zh":133,"answer_zh":134,"source_url":130},26645,"训练完成后，在 ComfyUI 中使用生成的 LoRA 模型，发现生成的图像效果不符合预期或与训练目标不一致，可能是什么原因？","这通常不是训练代码本身的错误，而是由以下因素导致：\n1. **触发词（Trigger Words）**：检查在 ComfyUI 中调用 LoRA 时是否正确使用了训练时的触发词。\n2. **权重设置**：尝试调整 LoRA 的权重系数（通常在 0.6 到 1.0 之间），过高的权重可能导致图像崩坏。\n3. **基础模型匹配**：确保 ComfyUI 中加载的基础模型（Base Model）版本与训练时使用的 `pretrained_model_name_or_path` 完全一致（例如都是 Qwen-Image-Edit 的同一版本）。\n4. **数据质量**：如果训练集图片分辨率过高或未进行适当的裁剪预处理，也可能导致模型学习到噪声而非特征。建议复训时统一将图片调整为标准分辨率（如 1024）。",[136],{"id":137,"version":138,"summary_zh":139,"released_at":140},171866,"1.0.0","新增了在消费级显卡（显存小于24 GiB）上训练通义千问图像LoRA的支持\r\n\r\n本次发布引入了一套轻量级的训练流程和配置，专为在显存不足24 GiB的GPU上运行通义千问LoRA微调而优化：\n\n- 兼容消费级显卡\n- 在不牺牲训练质量的前提下优化显存使用\n- 提供开箱即用的配置，便于快速部署\n- 支持与ComfyUI兼容的LoRA输出","2025-08-09T15:02:56"]