[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-mit-han-lab--once-for-all":3,"tool-mit-han-lab--once-for-all":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 真正成长为懂上",142651,2,"2026-04-06T23:34:12",[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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107888,"2026-04-06T11:32:50",[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":67,"readme_en":68,"readme_zh":69,"quickstart_zh":70,"use_case_zh":71,"hero_image_url":72,"owner_login":73,"owner_name":74,"owner_avatar_url":75,"owner_bio":76,"owner_company":77,"owner_location":77,"owner_email":77,"owner_twitter":78,"owner_website":79,"owner_url":80,"languages":81,"stars":94,"forks":95,"last_commit_at":96,"license":97,"difficulty_score":32,"env_os":98,"env_gpu":99,"env_ram":100,"env_deps":101,"category_tags":108,"github_topics":109,"view_count":32,"oss_zip_url":77,"oss_zip_packed_at":77,"status":17,"created_at":116,"updated_at":117,"faqs":118,"releases":153},4732,"mit-han-lab\u002Fonce-for-all","once-for-all","[ICLR 2020] Once for All: Train One Network and Specialize it for Efficient Deployment","Once-for-All 是一个创新的深度学习框架，旨在解决神经网络在不同硬件设备上高效部署的难题。传统方法通常需要为每种特定的硬件约束（如手机、边缘设备或 FPGA）重新训练专用模型，耗时且资源消耗巨大。Once-for-All 颠覆了这一流程，主张“一次训练，多次专用”：只需训练一个包含大量子网络结构的超网，即可从中直接提取出适应各种延迟、能耗和精度要求的专用子模型，无需再次训练。\n\n该项目由麻省理工学院韩松团队提出，曾荣获 ICLR 2020 最佳论文提名，并在多项国际低功耗视觉挑战赛中夺冠。其核心亮点在于强大的灵活性与卓越的性能，例如在移动端设置下仍能保持 80% 以上的 ImageNet 顶级准确率，且在多种硬件平台上表现优于经典的 MobileNetV3。此外，它还提供了包括 ResNet50 在内的多种预训练模型支持。\n\nOnce-for-All 非常适合 AI 研究人员、算法工程师以及需要在多样化终端设备部署模型的开发者使用。无论是希望探索神经架构搜索（NAS）前沿技术的研究者，还是追求极致推理效率的工程团队，都能通过它快速获得针对特定场景优化的高质量模型，大幅降低部署","Once-for-All 是一个创新的深度学习框架，旨在解决神经网络在不同硬件设备上高效部署的难题。传统方法通常需要为每种特定的硬件约束（如手机、边缘设备或 FPGA）重新训练专用模型，耗时且资源消耗巨大。Once-for-All 颠覆了这一流程，主张“一次训练，多次专用”：只需训练一个包含大量子网络结构的超网，即可从中直接提取出适应各种延迟、能耗和精度要求的专用子模型，无需再次训练。\n\n该项目由麻省理工学院韩松团队提出，曾荣获 ICLR 2020 最佳论文提名，并在多项国际低功耗视觉挑战赛中夺冠。其核心亮点在于强大的灵活性与卓越的性能，例如在移动端设置下仍能保持 80% 以上的 ImageNet 顶级准确率，且在多种硬件平台上表现优于经典的 MobileNetV3。此外，它还提供了包括 ResNet50 在内的多种预训练模型支持。\n\nOnce-for-All 非常适合 AI 研究人员、算法工程师以及需要在多样化终端设备部署模型的开发者使用。无论是希望探索神经架构搜索（NAS）前沿技术的研究者，还是追求极致推理效率的工程团队，都能通过它快速获得针对特定场景优化的高质量模型，大幅降低部署门槛与时间成本。目前该工具已集成至 PyTorch Hub，并支持通过 pip 一键安装，方便用户立即上手体验。","# Once-for-All: Train One Network and Specialize it for Efficient Deployment [[arXiv]](https:\u002F\u002Farxiv.org\u002Fabs\u002F1908.09791) [[Slides]](https:\u002F\u002Ffile.lzhu.me\u002Fprojects\u002FOnceForAll\u002FOFA%20Slides.pdf) [[Video]](https:\u002F\u002Fyoutu.be\u002Fa_OeT8MXzWI)\n```BibTex\n@inproceedings{\n  cai2020once,\n  title={Once for All: Train One Network and Specialize it for Efficient Deployment},\n  author={Han Cai and Chuang Gan and Tianzhe Wang and Zhekai Zhang and Song Han},\n  booktitle={International Conference on Learning Representations},\n  year={2020},\n  url={https:\u002F\u002Farxiv.org\u002Fpdf\u002F1908.09791.pdf}\n}\n```\n**[News]** Once-for-All is available at [PyTorch Hub](https:\u002F\u002Fpytorch.org\u002Fhub\u002Fpytorch_vision_once_for_all) now!\n\n**[News]** Once-for-All (OFA) Network is adopted by [SONY Neural Architecture Search Library](https:\u002F\u002Fgithub.com\u002Fsony\u002Fnnabla-nas).\n\n**[News]** Once-for-All (OFA) Network is adopted by [ADI MAX78000\u002FMAX78002 Model Training and Synthesis Tool](https:\u002F\u002Fgithub.com\u002FMaximIntegratedAI\u002Fai8x-training).\n\n**[News]** Once-for-All (OFA) Network is adopted by Alibaba and ranked 1st in the open division of the MLPerf Inference Benchmark ([Datacenter](https:\u002F\u002Fmlcommons.org\u002Fen\u002Finference-datacenter-10\u002F) and [Edge](https:\u002F\u002Fmlcommons.org\u002Fen\u002Finference-edge-10\u002F)).\n\n**[News]** First place in the [CVPR 2020 Low-Power Computer Vision Challenge](https:\u002F\u002Flpcv.ai\u002F2020CVPR\u002Fintroduction), CPU detection and FPGA track.\n\n**[News]** OFA-ResNet50 is released. \n\n**[News]** The [hands-on tutorial](https:\u002F\u002Fhangzhang.org\u002FCVPR2020\u002F) of OFA is released! [![](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fmit-han-lab\u002Fonce-for-all\u002Fblob\u002Fmaster\u002Ftutorial\u002Fofa.ipynb)\n\n**[News]** OFA is available via pip! Run **```pip install ofa```** to install the whole OFA codebase. \n\n**[News]** First place in the 4th [Low-Power Computer Vision Challenge](https:\u002F\u002Flpcv.ai\u002Fcompetitions\u002F2019), both classification and detection track.\n\n**[News]** First place in the 3rd [Low-Power Computer Vision Challenge](https:\u002F\u002Flpcv.ai\u002Fcompetitions\u002F2019), DSP track at ICCV’19 using the Once-for-all Network.\n\n## Train once, specialize for many deployment scenarios\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_once-for-all_readme_f698de81758e.png)\n\n## 80% top1 ImageNet accuracy under mobile setting\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_once-for-all_readme_6267b89f0e9c.png)\n\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_once-for-all_readme_359004fe4935.png)\n\n## Consistently outperforms MobileNetV3 on Diverse hardware platforms\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_once-for-all_readme_88812db256f4.png)\n\n## OFA-ResNet50 [[How to use]](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fonce-for-all\u002Fblob\u002Fmaster\u002Ftutorial\u002Fofa_resnet50_example.ipynb)\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_once-for-all_readme_e8526f2cdcae.png\" width=\"60%\" \u002F>\n\n## How to use \u002F evaluate **OFA Networks**\n### Use\n```python\n\"\"\" OFA Networks.\n    Example: ofa_network = ofa_net('ofa_mbv3_d234_e346_k357_w1.0', pretrained=True)\n\"\"\" \nfrom ofa.model_zoo import ofa_net\nofa_network = ofa_net(net_id, pretrained=True)\n    \n# Randomly sample sub-networks from OFA network\nofa_network.sample_active_subnet()\nrandom_subnet = ofa_network.get_active_subnet(preserve_weight=True)\n    \n# Manually set the sub-network\nofa_network.set_active_subnet(ks=7, e=6, d=4)\nmanual_subnet = ofa_network.get_active_subnet(preserve_weight=True)\n```\n\n### Evaluate\n\n`python eval_ofa_net.py --path 'Your path to imagenet' --net ofa_mbv3_d234_e346_k357_w1.0 `\n\n| OFA Network         | Design Space | Resolution | Width Multiplier |  Depth |  Expand Ratio |  kernel Size | \n|----------------------|:----------:|:----------:|:---------:|:------------:|:---------:|:------------:|\n| ofa_resnet50 | ResNet50D | 128 - 224 | 0.65, 0.8, 1.0 | 0, 1, 2 | 0.2, 0.25, 0.35 | 3 |\n| ofa_mbv3_d234_e346_k357_w1.0 | MobileNetV3 | 128 - 224 | 1.0 | 2, 3, 4 | 3, 4, 6 | 3, 5, 7 |\n| ofa_mbv3_d234_e346_k357_w1.2 | MobileNetV3 | 160 - 224 | 1.2 | 2, 3, 4 | 3, 4, 6 | 3, 5, 7 |\n| ofa_proxyless_d234_e346_k357_w1.3 | ProxylessNAS | 128 - 224 | 1.3 | 2, 3, 4 | 3, 4, 6 | 3, 5, 7 |\n\n## How to use \u002F evaluate **OFA Specialized Networks** \n### Use\n```python\n\"\"\" OFA Specialized Networks.\nExample: net, image_size = ofa_specialized('flops@595M_top1@80.0_finetune@75', pretrained=True)\n\"\"\" \nfrom ofa.model_zoo import ofa_specialized\nnet, image_size = ofa_specialized(net_id, pretrained=True)\n```\n\n### Evaluate\n\n`python eval_specialized_net.py --path 'Your path to imagent' --net flops@595M_top1@80.0_finetune@75 `\n\n\n| Model Name | Details | Top-1 (%)    | Top-5 (%)    | #Params |  #MACs | \n|----------------------|:----------:|:----------:|:----------:|:---------:|:------------:| \n|   **ResNet50 Design Space** |\n| ofa-resnet50D-41 | resnet50D_MAC@4.1B_top1@79.8 | 79.8 | 94.7 | 30.9M | 4.1B |\n| ofa-resnet50D-37 | resnet50D_MAC@3.7B_top1@79.7 | 79.7 | 94.7 | 26.5M | 3.7B |\n| ofa-resnet50D-30 | resnet50D_MAC@3.0B_top1@79.3 | 79.3 | 94.5 | 28.7M | 3.0B |\n| ofa-resnet50D-24 | resnet50D_MAC@2.4B_top1@79.0 | 79.0 | 94.2 | 29.0M | 2.4B |\n| ofa-resnet50D-18 | resnet50D_MAC@1.8B_top1@78.3 | 78.3 | 94.0 | 20.7M | 1.8B |\n| ofa-resnet50D-12 | resnet50D_MAC@1.2B_top1@77.1_finetune@25 | 77.1 | 93.3 | 19.3M | 1.2B |\n| ofa-resnet50D-09 | resnet50D_MAC@0.9B_top1@76.3_finetune@25 | 76.3 | 92.9 | 14.5M | 0.9B |\n| ofa-resnet50D-06 | resnet50D_MAC@0.6B_top1@75.0_finetune@25 | 75.0 | 92.1 | 9.6M | 0.6B |\n|   **FLOPs** |\n| ofa-595M| flops@595M_top1@80.0_finetune@75          | 80.0     | 94.9     | 9.1M   | 595M |\n| ofa-482M | flops@482M_top1@79.6_finetune@75          | 79.6     | 94.8     | 9.1M   | 482M |\n| ofa-389M | flops@389M_top1@79.1_finetune@75          | 79.1     | 94.5     | 8.4M   | 389M |\n|  **LG G8** |\n| ofa-lg-24 | LG-G8_lat@24ms_top1@76.4_finetune@25      | 76.4     | 93.0     | 5.8M   | 230M |\n| ofa-lg-16 | LG-G8_lat@16ms_top1@74.7_finetune@25      | 74.7     | 92.0     | 5.8M   | 151M |\n| ofa-lg-11 | LG-G8_lat@11ms_top1@73.0_finetune@25      | 73.0     | 91.1     | 5.0M   | 103M |\n| ofa-lg-8 | LG-G8_lat@8ms_top1@71.1_finetune@25       | 71.1     | 89.7     | 4.1M   | 74M  |\n|  **Samsung S7 Edge** |\n| ofa-s7edge-88 | s7edge_lat@88ms_top1@76.3_finetune@25     | 76.3     | 92.9     | 6.4M   | 219M |\n| ofa-s7edge-58| s7edge_lat@58ms_top1@74.7_finetune@25     | 74.7     | 92.0     | 4.6M   | 145M |\n| ofa-s7edge-41 | s7edge_lat@41ms_top1@73.1_finetune@25     | 73.1     | 91.0     | 4.7M   | 96M |\n| ofa-s7edge-29 | s7edge_lat@29ms_top1@70.5_finetune@25     | 70.5     | 89.5     | 3.8M   | 66M  |\n|  **Samsung Note8** |\n| ofa-note8-65 | note8_lat@65ms_top1@76.1_finetune@25      | 76.1     | 92.7     | 5.3M   | 220M |\n| ofa-note8-49 | note8_lat@49ms_top1@74.9_finetune@25      | 74.9     | 92.1     | 6.0M   | 164M |\n| ofa-note8-31 | note8_lat@31ms_top1@72.8_finetune@25      | 72.8     | 90.8     | 4.6M   | 101M |\n| ofa-note8-22 | note8_lat@22ms_top1@70.4_finetune@25      | 70.4     | 89.3     | 4.3M   | 67M  |\n|  **Samsung Note10** |\n| ofa-note10-64 | note10_lat@64ms_top1@80.2_finetune@75     | 80.2     | 95.1     | 9.1M   | 743M |\n| ofa-note10-50 | note10_lat@50ms_top1@79.7_finetune@75     | 79.7     | 94.9     | 9.1M   | 554M |\n| ofa-note10-41 | note10_lat@41ms_top1@79.3_finetune@75     | 79.3     | 94.5     | 9.0M   | 457M |\n| ofa-note10-30 | note10_lat@30ms_top1@78.4_finetune@75     | 78.4     | 94.2     | 7.5M   | 339M |\n| ofa-note10-22 | note10_lat@22ms_top1@76.6_finetune@25     | 76.6     | 93.1     | 5.9M   | 237M |\n| ofa-note10-16 | note10_lat@16ms_top1@75.5_finetune@25     | 75.5     | 92.3     | 4.9M   | 163M |\n| ofa-note10-11 | note10_lat@11ms_top1@73.6_finetune@25     | 73.6     | 91.2     | 4.3M   | 110M |\n| ofa-note10-08 | note10_lat@8ms_top1@71.4_finetune@25      | 71.4     | 89.8     | 3.8M   | 79M  |\n|  **Google Pixel1** |\n| ofa-pixel1-143 | pixel1_lat@143ms_top1@80.1_finetune@75     | 80.1     | 95.0     | 9.2M   | 642M |\n| ofa-pixel1-132 | pixel1_lat@132ms_top1@79.8_finetune@75     | 79.8     | 94.9     | 9.2M   | 593M |\n| ofa-pixel1-79 | pixel1_lat@79ms_top1@78.7_finetune@75     | 78.7     | 94.2     | 8.2M   | 356M |\n| ofa-pixel1-58 | pixel1_lat@58ms_top1@76.9_finetune@75     | 76.9     | 93.3     | 5.8M   | 230M |\n| ofa-pixel1-40 | pixel1_lat@40ms_top1@74.9_finetune@25     | 74.9     | 92.1     | 6.0M   | 162M |\n| ofa-pixel1-28 | pixel1_lat@28ms_top1@73.3_finetune@25     | 73.3     | 91.0     | 5.2M   | 109M |\n| ofa-pixel1-20 | pixel1_lat@20ms_top1@71.4_finetune@25     | 71.4     | 89.8     | 4.3M   | 77M |\n|  **Google Pixel2** |\n| ofa-pixel2-62 | pixel2_lat@62ms_top1@75.8_finetune@25      | 75.8     | 92.7     | 5.8M   | 208M |\n| ofa-pixel2-50 | pixel2_lat@50ms_top1@74.7_finetune@25      | 74.7     | 91.9     | 4.7M   | 166M |\n| ofa-pixel2-35 | pixel2_lat@35ms_top1@73.4_finetune@25      | 73.4     | 91.1     | 5.1M   | 113M |\n| ofa-pixel2-25 | pixel2_lat@25ms_top1@71.5_finetune@25      | 71.5     | 90.1     | 4.1M   | 79M  |\n|  **1080ti GPU (Batch Size 64)** |\n| ofa-1080ti-27 | 1080ti_gpu64@27ms_top1@76.4_finetune@25      | 76.4     | 93.0     | 6.5M   | 397M |\n| ofa-1080ti-22 | 1080ti_gpu64@22ms_top1@75.3_finetune@25      | 75.3     | 92.4     | 5.2M   | 313M |\n| ofa-1080ti-15 | 1080ti_gpu64@15ms_top1@73.8_finetune@25      | 73.8     | 91.3     | 6.0M   | 226M |\n| ofa-1080ti-12 | 1080ti_gpu64@12ms_top1@72.6_finetune@25      | 72.6     | 90.9     | 5.9M   | 165M  |\n|  **V100 GPU (Batch Size 64)** |\n| ofa-v100-11 | v100_gpu64@11ms_top1@76.1_finetune@25      | 76.1     | 92.7     | 6.2M   | 352M |\n| ofa-v100-09 | v100_gpu64@9ms_top1@75.3_finetune@25      | 75.3     | 92.4     | 5.2M   | 313M |\n| ofa-v100-06 | v100_gpu64@6ms_top1@73.0_finetune@25      | 73.0     | 91.1     | 4.9M   | 179M |\n| ofa-v100-05 | v100_gpu64@5ms_top1@71.6_finetune@25      | 71.6     | 90.3     | 5.2M   | 141M  |\n|  **Jetson TX2 GPU (Batch Size 16)** |\n| ofa-tx2-96 | tx2_gpu16@96ms_top1@75.8_finetune@25      | 75.8     | 92.7     | 6.2M   | 349M |\n| ofa-tx2-80 | tx2_gpu16@80ms_top1@75.4_finetune@25      | 75.4     | 92.4     | 5.2M   | 313M |\n| ofa-tx2-47 | tx2_gpu16@47ms_top1@72.9_finetune@25      | 72.9     | 91.1     | 4.9M   | 179M |\n| ofa-tx2-35 | tx2_gpu16@35ms_top1@70.3_finetune@25      | 70.3     | 89.4     | 4.3M   | 121M  |\n|  **Intel Xeon CPU with MKL-DNN (Batch Size 1)** |\n| ofa-cpu-17 | cpu_lat@17ms_top1@75.7_finetune@25      | 75.7     | 92.6     | 4.9M   | 365M |\n| ofa-cpu-15 | cpu_lat@15ms_top1@74.6_finetune@25      | 74.6     | 92.0     | 4.9M   | 301M |\n| ofa-cpu-11 | cpu_lat@11ms_top1@72.0_finetune@25      | 72.0     | 90.4     | 4.4M   | 160M |\n| ofa-cpu-10 | cpu_lat@10ms_top1@71.1_finetune@25      | 71.1     | 89.9     | 4.2M   | 143M  |\n\n## How to train **OFA Networks**\n```bash\nmpirun -np 32 -H \u003Cserver1_ip>:8,\u003Cserver2_ip>:8,\u003Cserver3_ip>:8,\u003Cserver4_ip>:8 \\\n    -bind-to none -map-by slot \\\n    -x NCCL_DEBUG=INFO -x LD_LIBRARY_PATH -x PATH \\\n    python train_ofa_net.py\n```\nor \n```bash\nhorovodrun -np 32 -H \u003Cserver1_ip>:8,\u003Cserver2_ip>:8,\u003Cserver3_ip>:8,\u003Cserver4_ip>:8 \\\n    python train_ofa_net.py\n```\n\n## Introduction Video\n\n[![Watch the video](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_once-for-all_readme_10955e8f6d49.png)](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=a_OeT8MXzWI&feature=youtu.be)\n\n## Hands-on Tutorial Video\n\n[![Watch the video](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_once-for-all_readme_58577355f002.jpg)](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=wrsid5tvuSM)\n\n\n## Requirement\n* Python 3.6+\n* Pytorch 1.4.0+\n* ImageNet Dataset \n* Horovod\n\n## Related work on automated and efficient deep learning:\n[ProxylessNAS: Direct Neural Architecture Search on Target Task and Hardware](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1812.00332.pdf) (ICLR’19)\n\n[AutoML for Architecting Efficient and Specialized Neural Networks](https:\u002F\u002Fieeexplore.ieee.org\u002Fabstract\u002Fdocument\u002F8897011) (IEEE Micro)\n\n[AMC: AutoML for Model Compression and Acceleration on Mobile Devices](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1802.03494.pdf) (ECCV’18)\n\n[HAQ: Hardware-Aware Automated Quantization](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1811.08886.pdf)  (CVPR’19, oral)\n","# 一次训练，多次部署：训练一个网络并将其专业化以实现高效部署 [[arXiv]](https:\u002F\u002Farxiv.org\u002Fabs\u002F1908.09791) [[幻灯片]](https:\u002F\u002Ffile.lzhu.me\u002Fprojects\u002FOnceForAll\u002FOFA%20Slides.pdf) [[视频]](https:\u002F\u002Fyoutu.be\u002Fa_OeT8MXzWI)\n```BibTex\n@inproceedings{\n  cai2020once,\n  title={Once for All: Train One Network and Specialize it for Efficient Deployment},\n  author={Han Cai and Chuang Gan and Tianzhe Wang and Zhekai Zhang and Song Han},\n  booktitle={International Conference on Learning Representations},\n  year={2020},\n  url={https:\u002F\u002Farxiv.org\u002Fpdf\u002F1908.09791.pdf}\n}\n```\n**[新闻]** Once-for-All 现已在 [PyTorch Hub](https:\u002F\u002Fpytorch.org\u002Fhub\u002Fpytorch_vision_once_for_all) 上可用！\n\n**[新闻]** Once-for-All (OFA) 网络已被 [SONY 神经架构搜索库](https:\u002F\u002Fgithub.com\u002Fsony\u002Fnnabla-nas) 采用。\n\n**[新闻]** Once-for-All (OFA) 网络已被 [ADI MAX78000\u002FMAX78002 模型训练与合成工具](https:\u002F\u002Fgithub.com\u002FMaximIntegratedAI\u002Fai8x-training) 采用。\n\n**[新闻]** Once-for-All (OFA) 网络已被阿里巴巴采用，并在 MLPerf 推理基准测试的开放组中排名第一（数据中心 [Datacenter](https:\u002F\u002Fmlcommons.org\u002Fen\u002Finference-datacenter-10\u002F) 和边缘 [Edge](https:\u002F\u002Fmlcommons.org\u002Fen\u002Finference-edge-10\u002F))。\n\n**[新闻]** 在 [CVPR 2020 低功耗计算机视觉挑战赛](https:\u002F\u002Flpcv.ai\u002F2020CVPR\u002Fintroduction) 中获得第一名，涵盖 CPU 检测和 FPGA 赛道。\n\n**[新闻]** OFA-ResNet50 已发布。\n\n**[新闻]** OFA 的 [动手教程](https:\u002F\u002Fhangzhang.org\u002FCVPR2020\u002F) 已发布！ [![](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fmit-han-lab\u002Fonce-for-all\u002Fblob\u002Fmaster\u002Ftutorial\u002Fofa.ipynb)\n\n**[新闻]** OFA 现可通过 pip 安装！运行 **```pip install ofa```** 即可安装完整的 OFA 代码库。\n\n**[新闻]** 在第四届 [低功耗计算机视觉挑战赛](https:\u002F\u002Flpcv.ai\u002Fcompetitions\u002F2019) 中获得第一名，包括分类和检测两个赛道。\n\n**[新闻]** 在第三届 [低功耗计算机视觉挑战赛](https:\u002F\u002Flpcv.ai\u002Fcompetitions\u002F2019) 中获得第一名，使用 Once-for-all 网络在 ICCV’19 的 DSP 赛道上获胜。\n\n## 一次训练，针对多种部署场景进行专业化\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_once-for-all_readme_f698de81758e.png)\n\n## 在移动设备环境下达到 80% 的 ImageNet Top-1 准确率\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_once-for-all_readme_6267b89f0e9c.png)\n\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_once-for-all_readme_359004fe4935.png)\n\n## 在多种硬件平台上持续优于 MobileNetV3\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_once-for-all_readme_88812db256f4.png)\n\n## OFA-ResNet50 [[使用方法]](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fonce-for-all\u002Fblob\u002Fmaster\u002Ftutorial\u002Fofa_resnet50_example.ipynb)\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_once-for-all_readme_e8526f2cdcae.png\" width=\"60%\" \u002F>\n\n## 如何使用\u002F评估 **OFA 网络**\n### 使用\n```python\n\"\"\" OFA 网络。\n    示例：ofa_network = ofa_net('ofa_mbv3_d234_e346_k357_w1.0', pretrained=True)\n\"\"\" \nfrom ofa.model_zoo import ofa_net\nofa_network = ofa_net(net_id, pretrained=True)\n    \n# 从 OFA 网络中随机采样子网络\nofa_network.sample_active_subnet()\nrandom_subnet = ofa_network.get_active_subnet(preserve_weight=True)\n    \n# 手动设置子网络\nofa_network.set_active_subnet(ks=7, e=6, d=4)\nmanual_subnet = ofa_network.get_active_subnet(preserve_weight=True)\n```\n\n### 评估\n\n`python eval_ofa_net.py --path '您的 ImageNet 数据路径' --net ofa_mbv3_d234_e346_k357_w1.0 `\n\n| OFA 网络         | 设计空间 | 分辨率 | 宽度倍数 |  深度 |  扩展比 |  卷积核大小 | \n|----------------------|:----------:|:----------:|:---------:|:------------:|:---------:|:------------:|\n| ofa_resnet50 | ResNet50D | 128 - 224 | 0.65, 0.8, 1.0 | 0, 1, 2 | 0.2, 0.25, 0.35 | 3 |\n| ofa_mbv3_d234_e346_k357_w1.0 | MobileNetV3 | 128 - 224 | 1.0 | 2, 3, 4 | 3, 4, 6 | 3, 5, 7 |\n| ofa_mbv3_d234_e346_k357_w1.2 | MobileNetV3 | 160 - 224 | 1.2 | 2, 3, 4 | 3, 4, 6 | 3, 5, 7 |\n| ofa_proxyless_d234_e346_k357_w1.3 | ProxylessNAS | 128 - 224 | 1.3 | 2, 3, 4 | 3, 4, 6 | 3, 5, 7 |\n\n## 如何使用\u002F评估 **OFA 专业化网络** \n### 使用\n```python\n\"\"\" OFA 专业化网络。\n示例：net, image_size = ofa_specialized('flops@595M_top1@80.0_finetune@75', pretrained=True)\n\"\"\" \nfrom ofa.model_zoo import ofa_specialized\nnet, image_size = ofa_specialized(net_id, pretrained=True)\n```\n\n### 评估\n\n`python eval_specialized_net.py --path '您指向 imagent 的路径' --net flops@595M_top1@80.0_finetune@75 `\n\n\n| 模型名称 | 详情 | Top-1 (%)    | Top-5 (%)    | 参数量 |  计算量 | \n|----------------------|:----------:|:----------:|:----------:|:---------:|:------------:| \n|   **ResNet50 设计空间** |\n| ofa-resnet50D-41 | resnet50D_MAC@4.1B_top1@79.8 | 79.8 | 94.7 | 30.9M | 4.1B |\n| ofa-resnet50D-37 | resnet50D_MAC@3.7B_top1@79.7 | 79.7 | 94.7 | 26.5M | 3.7B |\n| ofa-resnet50D-30 | resnet50D_MAC@3.0B_top1@79.3 | 79.3 | 94.5 | 28.7M | 3.0B |\n| ofa-resnet50D-24 | resnet50D_MAC@2.4B_top1@79.0 | 79.0 | 94.2 | 29.0M | 2.4B |\n| ofa-resnet50D-18 | resnet50D_MAC@1.8B_top1@78.3 | 78.3 | 94.0 | 20.7M | 1.8B |\n| ofa-resnet50D-12 | resnet50D_MAC@1.2B_top1@77.1_finetune@25 | 77.1 | 93.3 | 19.3M | 1.2B |\n| ofa-resnet50D-09 | resnet50D_MAC@0.9B_top1@76.3_finetune@25 | 76.3 | 92.9 | 14.5M | 0.9B |\n| ofa-resnet50D-06 | resnet50D_MAC@0.6B_top1@75.0_finetune@25 | 75.0 | 92.1 | 9.6M | 0.6B |\n|   **FLOPs** |\n| ofa-595M| flops@595M_top1@80.0_finetune@75          | 80.0     | 94.9     | 9.1M   | 595M |\n| ofa-482M | flops@482M_top1@79.6_finetune@75          | 79.6     | 94.8     | 9.1M   | 482M |\n| ofa-389M | flops@389M_top1@79.1_finetune@75          | 79.1     | 94.5     | 8.4M   | 389M |\n|  **LG G8** |\n| ofa-lg-24 | LG-G8_lat@24ms_top1@76.4_finetune@25      | 76.4     | 93.0     | 5.8M   | 230M |\n| ofa-lg-16 | LG-G8_lat@16ms_top1@74.7_finetune@25      | 74.7     | 92.0     | 5.8M   | 151M |\n| ofa-lg-11 | LG-G8_lat@11ms_top1@73.0_finetune@25      | 73.0     | 91.1     | 5.0M   | 103M |\n| ofa-lg-8 | LG-G8_lat@8ms_top1@71.1_finetune@25       | 71.1     | 89.7     | 4.1M   | 74M  |\n|  **Samsung S7 Edge** |\n| ofa-s7edge-88 | s7edge_lat@88ms_top1@76.3_finetune@25     | 76.3     | 92.9     | 6.4M   | 219M |\n| ofa-s7edge-58| s7edge_lat@58ms_top1@74.7_finetune@25     | 74.7     | 92.0     | 4.6M   | 145M |\n| ofa-s7edge-41 | s7edge_lat@41ms_top1@73.1_finetune@25     | 73.1     | 91.0     | 4.7M   | 96M |\n| ofa-s7edge-29 | s7edge_lat@29ms_top1@70.5_finetune@25     | 70.5     | 89.5     | 3.8M   | 66M  |\n|  **Samsung Note8** |\n| ofa-note8-65 | note8_lat@65ms_top1@76.1_finetune@25      | 76.1     | 92.7     | 5.3M   | 220M |\n| ofa-note8-49 | note8_lat@49ms_top1@74.9_finetune@25      | 74.9     | 92.1     | 6.0M   | 164M |\n| ofa-note8-31 | note8_lat@31ms_top1@72.8_finetune@25      | 72.8     | 90.8     | 4.6M   | 101M |\n| ofa-note8-22 | note8_lat@22ms_top1@70.4_finetune@25      | 70.4     | 89.3     | 4.3M   | 67M  |\n|  **Samsung Note10** |\n| ofa-note10-64 | note10_lat@64ms_top1@80.2_finetune@75     | 80.2     | 95.1     | 9.1M   | 743M |\n| ofa-note10-50 | note10_lat@50ms_top1@79.7_finetune@75     | 79.7     | 94.9     | 9.1M   | 554M |\n| ofa-note10-41 | note10_lat@41ms_top1@79.3_finetune@75     | 79.3     | 94.5     | 9.0M   | 457M |\n| ofa-note10-30 | note10_lat@30ms_top1@78.4_finetune@75     | 78.4     | 94.2     | 7.5M   | 339M |\n| ofa-note10-22 | note10_lat@22ms_top1@76.6_finetune@25     | 76.6     | 93.1     | 5.9M   | 237M |\n| ofa-note10-16 | note10_lat@16ms_top1@75.5_finetune@25     | 75.5     | 92.3     | 4.9M   | 163M |\n| ofa-note10-11 | note10_lat@11ms_top1@73.6_finetune@25     | 73.6     | 91.2     | 4.3M   | 110M |\n| ofa-note10-08 | note10_lat@8ms_top1@71.4_finetune@25      | 71.4     | 89.8     | 3.8M   | 79M  |\n|  **Google Pixel1** |\n| ofa-pixel1-143 | pixel1_lat@143ms_top1@80.1_finetune@75     | 80.1     | 95.0     | 9.2M   | 642M |\n| ofa-pixel1-132 | pixel1_lat@132ms_top1@79.8_finetune@75     | 79.8     | 94.9     | 9.2M   | 593M |\n| ofa-pixel1-79 | pixel1_lat@79ms_top1@78.7_finetune@75     | 78.7     | 94.2     | 8.2M   | 356M |\n| ofa-pixel1-58 | pixel1_lat@58ms_top1@76.9_finetune@75     | 76.9     | 93.3     | 5.8M   | 230M |\n| ofa-pixel1-40 | pixel1_lat@40ms_top1@74.9_finetune@25     | 74.9     | 92.1     | 6.0M   | 162M |\n| ofa-pixel1-28 | pixel1_lat@28ms_top1@73.3_finetune@25     | 73.3     | 91.0     | 5.2M   | 109M |\n| ofa-pixel1-20 | pixel1_lat@20ms_top1@71.4_finetune@25     | 71.4     | 89.8     | 4.3M   | 77M |\n|  **Google Pixel2** |\n| ofa-pixel2-62 | pixel2_lat@62ms_top1@75.8_finetune@25      | 75.8     | 92.7     | 5.8M   | 208M |\n| ofa-pixel2-50 | pixel2_lat@50ms_top1@74.7_finetune@25      | 74.7     | 91.9     | 4.7M   | 166M |\n| ofa-pixel2-35 | pixel2_lat@35ms_top1@73.4_finetune@25      | 73.4     | 91.1     | 5.1M   | 113M |\n| ofa-pixel2-25 | pixel2_lat@25ms_top1@71.5_finetune@25      | 71.5     | 90.1     | 4.1M   | 79M  |\n|  **1080ti GPU (批量大小 64)** |\n| ofa-1080ti-27 | 1080ti_gpu64@27ms_top1@76.4_finetune@25      | 76.4     | 93.0     | 6.5M   | 397M |\n| ofa-1080ti-22 | 1080ti_gpu64@22ms_top1@75.3_finetune@25      | 75.3     | 92.4     | 5.2M   | 313M |\n| ofa-1080ti-15 | 1080ti_gpu64@15ms_top1@73.8_finetune@25      | 73.8     | 91.3     | 6.0M   | 226M |\n| ofa-1080ti-12 | 1080ti_gpu64@12ms_top1@72.6_finetune@25      | 72.6     | 90.9     | 5.9M   | 165M  |\n|  **V100 GPU (批量大小 64)** |\n| ofa-v100-11 | v100_gpu64@11ms_top1@76.1_finetune@25      | 76.1     | 92.7     | 6.2M   | 352M |\n| ofa-v100-09 | v100_gpu64@9ms_top1@75.3_finetune@25      | 75.3     | 92.4     | 5.2M   | 313M |\n| ofa-v100-06 | v100_gpu64@6ms_top1@73.0_finetune@25      | 73.0     | 91.1     | 4.9M   | 179M |\n| ofa-v100-05 | v100_gpu64@5ms_top1@71.6_finetune@25      | 71.6     | 90.3     | 4.2M   | 141M  |\n|  **Jetson TX2 GPU (批量大小 16)** |\n| ofa-tx2-96 | tx2_gpu16@96ms_top1@75.8_finetune@25      | 75.8     | 92.7     | 6.2M   | 349M |\n| ofa-tx2-80 | tx2_gpu16@80ms_top1@75.4_finetune@25      | 75.4     | 92.4     | 5.2M   | 313M |\n| ofa-tx2-47 | tx2_gpu16@47ms_top1@72.9_finetune@25      | 72.9     | 91.1     | 4.9M   | 179M |\n| ofa-tx2-35 | tx2_gpu16@35ms_top1@70.3_finetune@25      | 70.3     | 89.4     | 4.3M   | 121M  |\n|  **Intel Xeon CPU with MKL-DNN (批量大小 1)** |\n| ofa-cpu-17 | cpu_lat@17ms_top1@75.7_finetune@25      | 75.7     | 92.6     | 4.9M   | 365M |\n| ofa-cpu-15 | cpu_lat@15ms_top1@74.6_finetune@25      | 74.6     | 92.0     | 4.9M   | 301M |\n| ofa-cpu-11 | cpu_lat@11ms_top1@72.0_finetune@25      | 72.0     | 90.4     | 4.4M   | 160M |\n| ofa-cpu-10 | cpu_lat@10ms_top1@71.1_finetune@25      | 71.1     | 89.9     | 4.2M   | 143M  |\n\n## 如何训练 **OFA 网络**\n```bash\nmpirun -np 32 -H \u003Cserver1_ip>:8,\u003Cserver2_ip>:8,\u003Cserver3_ip>:8,\u003Cserver4_ip>:8 \\\n    -bind-to none -map-by slot \\\n    -x NCCL_DEBUG=INFO -x LD_LIBRARY_PATH -x PATH \\\n    python train_ofa_net.py\n```\n或 \n```bash\nhorovodrun -np 32 -H \u003Cserver1_ip>:8,\u003Cserver2_ip>:8,\u003Cserver3_ip>:8,\u003Cserver4_ip>:8 \\\n    python train_ofa_net.py\n```\n\n## 介绍视频\n\n[![观看视频](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_once-for-all_readme_10955e8f6d49.png)](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=a_OeT8MXzWI&feature=youtu.be)\n\n## 实操教程视频\n\n[![观看视频](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_once-for-all_readme_58577355f002.jpg)](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=wrsid5tvuSM)\n\n\n## 需求\n* Python 3.6+\n* Pytorch 1.4.0+\n* ImageNet 数据集 \n* Horovod\n\n## 自动化且高效的深度学习相关工作：\n[ProxylessNAS：针对目标任务与硬件的直接神经架构搜索]（ICLR’19）\n\n[用于构建高效且专用神经网络的AutoML]（IEEE Micro）\n\n[AMC：面向移动设备模型压缩与加速的AutoML]（ECCV’18）\n\n[HAQ：面向硬件的自动化量化]（CVPR’19，口头报告）","# Once-for-All (OFA) 快速上手指南\n\nOnce-for-All (OFA) 是一种创新的神经网络架构搜索方法，只需训练一次超大网络，即可从中提取出适应不同硬件平台（如手机、GPU、FPGA 等）和不同延迟约束的专用子网络，无需重新训练。\n\n## 1. 环境准备\n\n在开始之前，请确保您的开发环境满足以下要求：\n\n*   **操作系统**: Linux (推荐 Ubuntu)\n*   **Python**: 3.6 或更高版本\n*   **PyTorch**: 1.4.0 或更高版本\n*   **分布式训练框架**: Horovod (用于训练 OFA 母网络，若仅使用预训练模型可忽略)\n*   **数据集**: ImageNet 数据集 (用于评估或重新训练)\n\n**依赖安装建议：**\n建议使用 `pip` 进行安装。国内用户可配置清华源或阿里源以加速下载：\n```bash\npip install torch torchvision -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\npip install horovod -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n```\n\n## 2. 安装步骤\n\nOFA 已发布到 PyPI，可以通过以下命令直接安装完整代码库：\n\n```bash\npip install ofa\n```\n\n如果您希望使用最新代码或贡献代码，也可以从 GitHub 克隆：\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fonce-for-all.git\ncd once-for-all\npip install -e .\n```\n\n## 3. 基本使用\n\nOFA 提供了两种主要的使用模式：直接使用**预训练的专用子网络**（推荐大多数开发者使用），或者从**母网络中采样\u002F自定义子网络**。\n\n### 模式一：加载预训练的专用网络 (最简单)\n\n针对特定硬件（如 Pixel1, Samsung Note10）或特定计算量（FLOPs）优化过的模型可以直接加载使用。\n\n```python\nfrom ofa.model_zoo import ofa_specialized\n\n# 示例：加载一个在 595M FLOPs 约束下优化，Top-1 准确率为 80.0% 的模型\n# net_id 格式通常为：约束条件_性能指标_微调轮次\nnet, image_size = ofa_specialized('flops@595M_top1@80.0_finetune@75', pretrained=True)\n\n# 此时 net 即为准备好的 PyTorch 模型，可直接用于推理\nprint(f\"Model loaded. Input image size: {image_size}\")\n```\n\n常用模型 ID 参考（详见官方文档表格）：\n*   `flops@595M_top1@80.0_finetune@75`: 通用高效模型\n*   `pixel1_lat@143ms_top1@80.1_finetune@75`: 针对 Google Pixel1 优化\n*   `note10_lat@64ms_top1@80.2_finetune@75`: 针对 Samsung Note10 优化\n\n### 模式二：从母网络采样或自定义子网络\n\n如果您需要探索特定的架构参数（如核大小、深度、扩展率），可以加载母网络并动态生成子网络。\n\n```python\nfrom ofa.model_zoo import ofa_net\n\n# 1. 加载预训练的 OFA 母网络 (以 MobileNetV3 搜索空间为例)\nofa_network = ofa_net('ofa_mbv3_d234_e346_k357_w1.0', pretrained=True)\n\n# 2. 方式 A：随机采样一个子网络\nofa_network.sample_active_subnet()\nrandom_subnet = ofa_network.get_active_subnet(preserve_weight=True)\n\n# 3. 方式 B：手动设置子网络参数\n# ks: kernel size, e: expand ratio, d: depth\nofa_network.set_active_subnet(ks=7, e=6, d=4)\nmanual_subnet = ofa_network.get_active_subnet(preserve_weight=True)\n\n# manual_subnet 即为提取出的专用模型，权重已继承自母网络\n```\n\n### 模型评估\n\n如果您本地有 ImageNet 验证集，可以使用提供的脚本评估模型性能：\n\n**评估专用网络：**\n```bash\npython eval_specialized_net.py --path 'Your path to imagenet' --net flops@595M_top1@80.0_finetune@75\n```\n\n**评估母网络中的子网络：**\n```bash\npython eval_ofa_net.py --path 'Your path to imagenet' --net ofa_mbv3_d234_e346_k357_w1.0\n```","某边缘计算团队需将图像分类模型部署到从低端 IoT 传感器到高端工业网关等十余种不同算力的硬件设备上。\n\n### 没有 once-for-all 时\n- **重复训练成本高昂**：针对每种硬件约束（如延迟、能耗），团队必须从头单独训练一个专用模型，耗费数周 GPU 机时。\n- **架构搜索效率低下**：为寻找最优网络结构，需在每个设备上反复进行神经架构搜索（NAS），开发周期被严重拉长。\n- **存储与维护困难**：最终需维护十几个独立的模型文件，占用大量存储空间，且版本迭代更新极其繁琐。\n- **性能妥协明显**：受限于单点优化的局限，部分极端受限设备上的模型精度难以突破瓶颈，无法兼顾效率与准确率。\n\n### 使用 once-for-all 后\n- **一次训练全域覆盖**：只需训练一个超网（Supernet），即可从中直接提取适配任意硬件约束的子网，训练时间缩短 90% 以上。\n- **秒级专属模型生成**：无需重新搜索或训练，通过调整深度、宽度等参数，几分钟内即可生成针对特定芯片的最优子网。\n- **统一模型仓库管理**：所有专用设备共享同一套权重文件，大幅降低存储开销，模型更新只需替换超网即可同步所有端侧。\n- **精度与效率双优**：在移动端及嵌入式设备上，生成的子网在保持极低延迟的同时，ImageNet 顶一准确率稳定超过 80%，优于手动设计的 MobileNetV3。\n\nonce-for-all 通过“训练一次，按需特化”的模式，彻底解决了多场景部署中效率与精度的矛盾，让异构硬件适配变得像搭积木一样简单高效。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_once-for-all_f698de81.png","mit-han-lab","MIT HAN Lab","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fmit-han-lab_65e6a38d.png","Efficient AI Computing. PI: Song Han",null,"songhan_mit","https:\u002F\u002Fhanlab.mit.edu","https:\u002F\u002Fgithub.com\u002Fmit-han-lab",[82,86,90],{"name":83,"color":84,"percentage":85},"Python","#3572A5",78,{"name":87,"color":88,"percentage":89},"Jupyter Notebook","#DA5B0B",22,{"name":91,"color":92,"percentage":93},"Shell","#89e051",0,1947,343,"2026-04-02T08:53:01","MIT","Linux","训练必需：需多卡 NVIDIA GPU 环境（示例命令使用 32 卡），依赖 Horovod 和 NCCL；推理未强制要求 GPU，支持 CPU (Intel Xeon + MKL-DNN) 及多种边缘设备 (Jetson, FPGA 等)。具体显存和 CUDA 版本未在文中明确说明。","未说明",{"notes":102,"python":103,"dependencies":104},"该工具主要用于神经架构搜索 (NAS) 和模型部署优化。训练阶段需要分布式环境（支持 mpirun 或 horovodrun），示例显示需 32 个进程。预训练模型可通过 PyTorch Hub 或 pip (pip install ofa) 获取。支持针对特定硬件（如手机、GPU、CPU）延迟或算力约束自动采样专用子网络。","3.6+",[105,106,107],"pytorch>=1.4.0","horovod","mpirun (OpenMPI)",[15,14],[110,111,112,113,114,115],"tinyml","edge-ai","efficient-model","acceleration","nas","automl","2026-03-27T02:49:30.150509","2026-04-07T09:55:34.086146",[119,124,129,134,139,144,149],{"id":120,"question_zh":121,"answer_zh":122,"source_url":123},21507,"遇到 'ImportError: Extension horovod.torch has not been built' 错误如何解决？","该错误通常是由于环境配置问题（如 Docker 容器中未启用 Nvidia 驱动）导致的，而非代码库本身的问题。建议检查是否使用了 Docker，如果是，请确保容器正确配置了 CUDA 支持。如果不是 Docker 环境，请尝试使用 HOROVOD_WITH_PYTORCH=1 重新安装 Horovod 以调试构建错误。","https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fonce-for-all\u002Fissues\u002F19",{"id":125,"question_zh":126,"answer_zh":127,"source_url":128},21508,"无法下载 Supernet 预训练权重或出现连接错误怎么办？","维护者已更新代码中的 URL 链接，现在会自动从备份服务器下载检查点。如果仍然遇到服务器宕机或 Google Drive 链接权限错误（如 'Access denied'），请耐心等待维护者修复链接或查看项目 README 中是否有最新的备用下载方式（如 Google Drive 共享链接）。","https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fonce-for-all\u002Fissues\u002F10",{"id":130,"question_zh":131,"answer_zh":132,"source_url":133},21509,"如何在 CIFAR-10\u002F100 等非 ImageNet 数据集上训练 OFA Supernet？","可以使用代码库中现有的类（如 OFAMobileNetV3）和脚本（如 progressive_shrinking.py）进行训练。关键步骤是将 CIFAR 图像预处理为符合 ImageNet 的输入尺寸（例如通过随机裁剪调整为 224x224）。注意，由于类别数量不同（CIFAR-100 为 100 类，ImageNet 为 1000 类），直接加载官方预训练模型会因维度不匹配而失败，因此建议从头训练 Supernet 或修改分类头以适应新数据集。","https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fonce-for-all\u002Fissues\u002F32",{"id":135,"question_zh":136,"answer_zh":137,"source_url":138},21510,"在渐进式收缩（Progressive Shrinking）验证阶段遇到 'CUDA out of memory' 错误如何解决？","该错误通常是因为验证时的批量大小（batch_size）设置过大。在 `reset_running_statistics` 函数中，默认计算的 batch_size 可能在多卡或小显存环境下导致溢出。解决方案是手动修改代码，硬编码一个较小的 batch_size。例如，将原本动态计算 batch_size 的逻辑改为固定值，以确保在验证子网时显存足够。","https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fonce-for-all\u002Fissues\u002F31",{"id":140,"question_zh":141,"answer_zh":142,"source_url":143},21511,"下载 ResNet50 Supernet 时遇到 Google Drive 'Access denied' 或链接失效错误怎么办？","这通常是因为文件访问次数过多或权限设置问题。维护者通常会定期更新失效的 URL 链接。如果遇到此错误，请检查项目是否发布了新的下载链接，或者稍后重试。维护者已在相关 Issue 中确认并更新了链接以恢复下载功能。","https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fonce-for-all\u002Fissues\u002F83",{"id":145,"question_zh":146,"answer_zh":147,"source_url":148},21512,"如何将 PyTorch 格式的 OFA 专用模型转换为 Tensorflow-Lite 以进行端侧推理延迟测试？","直接使用 ONNX 转换可能会遇到形状不匹配等错误（如 'Shape must be rank 2 but is rank 1'）。推荐的替代方案是先实现 Keras 版本的模型，然后使用 TensorFlow Lite Converter (v2.4) 将其转换为 TFLite 模型。转换成功后，可使用 tf lite benchmark 工具在目标设备上获取延迟数据表。","https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fonce-for-all\u002Fissues\u002F35",{"id":150,"question_zh":151,"answer_zh":152,"source_url":138},21513,"使用 Horovod 多卡训练时，为什么所有进程的显存都集中在同一张显卡上？","这通常是因为环境变量配置不当，导致 Horovod 未能正确识别或分配不同的 GPU。在使用 `horovodrun` 命令时，请确保正确设置了 `-H` 参数以及 CUDA_VISIBLE_DEVICES 环境变量，以便每个进程绑定到独立的物理 GPU 上。",[154],{"id":155,"version":156,"summary_zh":157,"released_at":158},127508,"v0.1","Once-for-All v0.1 的官方 PyTorch 实现","2020-06-16T04:25:52"]