[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-DingXiaoH--RepLKNet-pytorch":3,"tool-DingXiaoH--RepLKNet-pytorch":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 真正成长为懂上",156804,2,"2026-04-15T11:34:33",[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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108322,"2026-04-10T11:39:34",[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},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[52,13,15,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":32,"last_commit_at":59,"category_tags":60,"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":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":77,"owner_email":78,"owner_twitter":76,"owner_website":76,"owner_url":79,"languages":80,"stars":85,"forks":86,"last_commit_at":87,"license":88,"difficulty_score":89,"env_os":90,"env_gpu":91,"env_ram":92,"env_deps":93,"category_tags":103,"github_topics":76,"view_count":32,"oss_zip_url":76,"oss_zip_packed_at":76,"status":17,"created_at":104,"updated_at":105,"faqs":106,"releases":137},7771,"DingXiaoH\u002FRepLKNet-pytorch","RepLKNet-pytorch","Scaling Up Your Kernels to 31x31: Revisiting Large Kernel Design in CNNs (CVPR 2022)","RepLKNet-pytorch 是计算机视觉领域经典论文《Scaling Up Your Kernels to 31x31》的官方 PyTorch 实现，旨在重新探索卷积神经网络（CNN）中的大核设计。传统 CNN 受限于计算效率，通常使用较小的卷积核（如 3x3），这限制了模型捕捉长距离依赖关系的能力。RepLKNet 通过引入结构重参数化技术，成功将卷积核尺寸扩展至 31x31，在保持推理速度不变的前提下，显著扩大了有效感受野，从而大幅提升了图像分类、语义分割及目标检测等任务的性能表现。\n\n该项目不仅提供了完整的预训练模型（涵盖 ImageNet、Cityscapes、COCO 等主流数据集），还开源了可视化有效感受野的工具及详细的训练指令，极大地降低了复现门槛。其核心技术亮点在于利用高效的深度卷积算子替代标准卷积，并兼容多种深度学习框架。RepLKNet-pytorch 非常适合从事计算机视觉算法研究的科研人员、希望优化模型性能的开发者以及需要高性能骨干网络的企业工程师使用。无论是进行学术创新还是工业级落地，它都能为构建更强大的视觉系统提供坚实的技术支撑。","# RepLKNet-pytorch (CVPR 2022)\n\nThis is the official PyTorch implementation of **RepLKNet**, from the following CVPR-2022 paper:\n\nScaling Up Your Kernels to 31x31: Revisiting Large Kernel Design in CNNs.\n\nThe paper is now released on arXiv: https:\u002F\u002Farxiv.org\u002Fabs\u002F2203.06717.\n\nUpdate: **all the pretrained models, ImageNet-1K models, and Cityscapes\u002FADE20K\u002FCOCO models have been released**. \n\nUpdate: **released a script to visualize the Effective Receptive Field (ERF). To get the ERF of your own model, you only need to add a few lines of code!**\n\nUpdate: **released the training commands and more examples**. \n\nIf you find the paper or this repository helpful, please consider citing\n\n        @article{replknet,\n        title={Scaling Up Your Kernels to 31x31: Revisiting Large Kernel Design in CNNs},\n        author={Ding, Xiaohan and Zhang, Xiangyu and Zhou, Yizhuang and Han, Jungong and Ding, Guiguang and Sun, Jian},\n        journal={arXiv preprint arXiv:2203.06717},\n        year={2022}\n        }\n\n## Other implementations\n\n| framework | link |\n|:---:|:---:|\n|MegEngine (official)|https:\u002F\u002Fgithub.com\u002Fmegvii-research\u002FRepLKNet|\n|PyTorch (official)|https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch|\n|Tensorflow|https:\u002F\u002Fgithub.com\u002Fshkarupa-alex\u002Ftfreplknet|\n|PaddlePaddle|https:\u002F\u002Fgithub.com\u002FBR-IDL\u002FPaddleViT\u002Ftree\u002Fdevelop\u002Fimage_classification\u002FRepLKNet|\n| ... | |\n\nMore re-implementations are welcomed.\n\n## Use our efficient large-kernel convolution with PyTorch\n\nWe have released an example for **PyTorch**. Please check ```setup.py``` and ```depthwise_conv2d_implicit_gemm.py``` (**a replacement of torch.nn.Conv2d**) in https:\u002F\u002Fgithub.com\u002FMegEngine\u002Fcutlass\u002Ftree\u002Fmaster\u002Fexamples\u002F19_large_depthwise_conv2d_torch_extension.\n\n1. ```unzip cutlass.zip```, enter the directory. This version of cutlass works fine with our large-kernel implementation and multiple python versions. You may alternatively use the cutlass branch maintained by the MegEngine team (clone https:\u002F\u002Fgithub.com\u002FMegEngine\u002Fcutlass), but you may need to be more careful with your python version (see [this issue](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fissues\u002F34)).\n2. ```cd examples\u002F19_large_depthwise_conv2d_torch_extension```\n3. ```.\u002Fsetup.py install --user```. If you get errors, check your ```CUDA_HOME```.\n4. A quick check: ```python depthwise_conv2d_implicit_gemm.py```\n5. Add ```WHERE_YOU_CLONED_CUTLASS\u002Fexamples\u002F19_large_depthwise_conv2d_torch_extension``` into your ```PYTHONPATH``` so that you can ```from depthwise_conv2d_implicit_gemm import DepthWiseConv2dImplicitGEMM``` anywhere. Then you may use ```DepthWiseConv2dImplicitGEMM``` as a replacement of ```nn.Conv2d```.\n6. ```export LARGE_KERNEL_CONV_IMPL=WHERE_YOU_CLONED_CUTLASS\u002Fexamples\u002F19_large_depthwise_conv2d_torch_extension``` so that RepLKNet will use the efficient implementation. Or you may simply modify the related code (```get_conv2d```) in ```replknet.py```.\n\nIt should work with a wide range of GPUs and PyTorch\u002FCUDA versions. We suggest you try first and check the environments only if you get any errors. Our latest testes used both\n\n1. Ubuntu 18.04 + CUDA 11.3 + nvcc 11.3 + cudnn 8.2.0 + python 3.8.12 + pytorch 1.10 + gcc 7.3.0 + nccl 2.10.3 + NVIDIA driver 450.102.04 + V100 and A100 GPUs\n2. Ubuntu 18.04 + CUDA 10.2 + nvcc 10.0 + cudnn 7.6.5 + python 3.6.9 + pytorch 1.9 + gcc 7.5.0 + nccl 2.7.8 + NVIDIA driver 460.32.03 + 2080Ti and V100 GPUs\n\nIt is reported (see [here](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fissues\u002F34)) that a python version mismatch may result in an error (```forward_fp32.cu(212): error: more than one instance of constructor \"cutlass::Tensor4DCoord::Tensor4DCoord\" ...``` or ```cutlass\u002Finclude\u002Fcutlass\u002Ffast_math.h(741): error: no suitable conversion function from \"__half\" to \"float\" exists```). Please upgrade or downgrade your python. We sincerely thank @sleeplessai and @ewrfcas for sharing their experience.\n\nOur implementation mentioned in the paper has been integrated into MegEngine. The engine will automatically use it. If you would like to use it in other frameworks like Tensorflow, you may need to compile our released cuda sources (the ```*.cu``` files in the above example should work with other frameworks) and use some tools to load them, just like ```cutlass``` and ```torch.utils.cpp_extension``` in the PyTorch example. Would be appreciated if you could share with us your experience.\n\nYou may refer to the MegEngine source code: https:\u002F\u002Fgithub.com\u002FMegEngine\u002FMegEngine\u002Ftree\u002F8a2e92bd6c5ac02807b27d174dce090ee391000b\u002Fdnn\u002Fsrc\u002Fcuda\u002Fconv_bias\u002Fchanwise.\n\nPull requests (e.g., better or other implementations or implementations on other frameworks) are welcomed.\n\n## Catalog\n- [x] Model code\n- [x] PyTorch pretrained models\n- [x] PyTorch large-kernel conv impl\n- [x] PyTorch training code\n- [x] PyTorch downstream models\n- [x] PyTorch downstream code\n- [x] A script to visualize the ERF\n- [x] How to obtain the shape bias\n\n\u003C!-- ✅ ⬜️  -->\n\n## Results and Pre-trained Models\n\n### ImageNet-1K Models\n\n| name | resolution |ImageNet-1K acc | #params | FLOPs | ImageNet-1K pretrained model |\n|:---:|:---:|:---:|:---:| :---:|:---:|\n|RepLKNet-31B|224x224|83.5| 79M   |  15.3G   |[Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1azQUiCxK9feYVkkrPqwVPBtNsTzDrX7S\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1gspbbfqooMtegt_DO1TUeA?pwd=lknt)|\n|RepLKNet-31B|384x384|84.8| 79M   |  45.1G   |[Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1vo-P3XB6mRLUeDzmgv90dOu73uCeLfZN\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1WhLaCKKv4NuKc3qMYECOIQ?pwd=lknt)|\n\n\n\n### ImageNet-22K Models\n\n| name | resolution |ImageNet-1K acc | #params | FLOPs | 22K pretrained model | 1K finetuned model |\n|:---:|:---:|:---:|:---:| :---:|:---:|:---:|\n|RepLKNet-31B|224x224|  85.2  |  79M  |  15.3G  |[Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1PYJiMszZYNrkZOeYwjccvxX8UHMALB7z\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1YiQSn7VJDiNWX1IWg19O6g?pwd=lknt)|[Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1DslZ2voXZQR1QoFY9KnbsHAeF84hzS0s\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F169wDunCdop-jQM8K-AX27g?pwd=lknt)|\n|RepLKNet-31B|384x384|  86.0  |  79M  | 45.1G   | - |[Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1Sc46BWdXXm2fVP-K_hKKU_W8vAB-0duX\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F11-F3JIKEzSOU7KUhebUWEQ?pwd=lknt)|\n|RepLKNet-31L|384x384|  86.6  |  172M  |  96.0G  |[Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F16jcPsPwo5rko7ojWS9k_W-svHX-iFknY\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1KWazk_cOVYoLuuVJc_9HxA?pwd=lknt)|[Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1JYXoNHuRvC33QV1pmpzMTKEni1hpWfBl\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1MWIsPXJJV4mTEtgcKv3F3w?pwd=lknt)|\n\n\n### MegData-73M Models\n\n| name | resolution |ImageNet-1K acc | #params | FLOPs | MegData-73M pretrained model | 1K finetuned model |\n|:---:|:---:|:---:|:---:| :---:| :---:|:---:|\n|RepLKNet-XL| 320x320 | 87.8 | 335M | 128.7G | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1CBHAEUlCzoHfiAQmMIjZhDMAIyHUmAAj\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F168Wb2P3rSp23-DCpNG3aCQ?pwd=lknt) | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1tPC60El34GntXByIRHb-z-Apm4Y5LX1T\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1C1bJJLz9O28ChZ4NcxjUsw?pwd=lknt)|\n\n\n\n## Evaluation\n\nFor RepLKNet-31B\u002FL with 224x224 or 384x384, we use the \"IMAGENET_DEFAULT_MEAN\u002FSTD\" for preprocessing (see [here](https:\u002F\u002Fgithub.com\u002Frwightman\u002Fpytorch-image-models\u002Fblob\u002F73ffade1f8203a611c9cdd6df437b436b780daca\u002Ftimm\u002Fdata\u002Fconstants.py#L2)). For examples,\n```\npython -m torch.distributed.launch --nproc_per_node=8 main.py --model RepLKNet-31B --batch_size 32 --eval True --resume RepLKNet-31B_ImageNet-1K_224.pth --input_size 224\n```\nor\n```\npython -m torch.distributed.launch --nproc_per_node=8 main.py --model RepLKNet-31L --batch_size 32 --eval True --resume RepLKNet-31L_ImageNet-22K-to-1K_384.pth --input_size 384\n```\nFor RepLKNet-XL, please note that we used ```mean=[0.5,0.5,0.5]``` and ```std=[0.5,0.5,0.5]``` for preprocessing on MegData73M dataset as well as finetuning on ImageNet-1K. This mean\u002Fstd setting is also referred to as \"IMAGENET_INCEPTION_MEAN\u002FSTD\" in timm, see [here](https:\u002F\u002Fgithub.com\u002Frwightman\u002Fpytorch-image-models\u002Fblob\u002F73ffade1f8203a611c9cdd6df437b436b780daca\u002Ftimm\u002Fdata\u002Fconstants.py#L4). Add ```--imagenet_default_mean_and_std false``` to use this mean\u002Fstd setting (see [here](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fblob\u002Fmain\u002Fdatasets.py#L58)). As noted in the paper, we did not use small kernels for re-parameterization.\n```\npython -m torch.distributed.launch --nproc_per_node=8 main.py --model RepLKNet-XL --batch_size 32 --eval true --resume RepLKNet-XL_MegData73M_ImageNet1K.pth --imagenet_default_mean_and_std false --input_size 320\n```\n\nTo verify the equivalency of Structural Re-parameterization (i.e., the outputs before and after ```structural_reparam```), add ```--with_small_kernel_merged true```.\n\n\n## Training\n\nYou may use multi-node training on a SLURM cluster with [submitit](https:\u002F\u002Fgithub.com\u002Ffacebookincubator\u002Fsubmitit). Please install:\n```\npip install submitit\n```\nIf you have limited GPU memory (e.g., 2080Ti), use ```--use_checkpoint true``` to save GPU memory.\n\n### Pretrain RepLKNet-31B on ImageNet-1K\nSingle machine (note ```--update_freq 4```):\n```\npython -m torch.distributed.launch --nproc_per_node=8 main.py --model RepLKNet-31B --drop_path 0.5 --batch_size 64 --lr 4e-3 --update_freq 4 --model_ema true --model_ema_eval true --data_path \u002Fpath\u002Fto\u002Fimagenet-1k --warmup_epochs 10 --epochs 300 --output_dir your_training_dir\n```\nFour machines (note ```--update_freq 1```):\n```\npython run_with_submitit.py --nodes 4 --ngpus 8 --model RepLKNet-31B --drop_path 0.5 --batch_size 64 --lr 4e-3 --update_freq 1 --model_ema true --model_ema_eval true --data_path \u002Fpath\u002Fto\u002Fimagenet-1k --warmup_epochs 10 --epochs 300 --job_dir your_training_dir\n```\nIn the following, we only present multi-machine commands. You may train with a single machine in a similar way.\n\n### Finetune the ImageNet-1K-pretrained (224x224) RepLKNet-31B with 384x384\n```\npython run_with_submitit.py --nodes 4 --ngpus 8 --model RepLKNet-31B --drop_path 0.8 --input_size 384 --batch_size 32 --lr 4e-4 --epochs 30 --weight_decay 1e-8 --update_freq 1 --cutmix 0 --mixup 0 --finetune RepLKNet-31B_ImageNet-1K_224.pth --model_ema true --model_ema_eval true --data_path \u002Fpath\u002Fto\u002Fimagenet-1k --warmup_epochs 1 --job_dir your_training_dir --layer_decay 0.7\n```\n### Pretrain RepLKNet-31B on ImageNet-22K\n```\npython run_with_submitit.py --nodes 16 --ngpus 8 --model RepLKNet-31B --drop_path 0.1 --batch_size 32 --lr 4e-3 --update_freq 1 --warmup_epochs 5 --epochs 90 --data_set image_folder --nb_classes 21841 --disable_eval true --data_path \u002Fpath\u002Fto\u002Fimagenet-22k --job_dir \u002Fpath\u002Fto\u002Fsave_results\n```\n### Finetune 22K-pretrained RepLKNet-31B on ImageNet-1K (224x224)\n```\npython run_with_submitit.py --nodes 2 --ngpus 8 --model RepLKNet-31B --drop_path 0.2 --input_size 224 --batch_size 32 --lr 4e-4 --epochs 30 --weight_decay 1e-8 --update_freq 1 --cutmix 0 --mixup 0 --finetune RepLKNet-31B_ImageNet-22K.pth --model_ema true --model_ema_eval true --data_path \u002Fpath\u002Fto\u002Fimagenet-1k --warmup_epochs 1 --job_dir your_training_dir --layer_decay 0.7\n```\n### Finetune 22K-pretrained RepLKNet-31B on ImageNet-1K (384x384)\n```\npython run_with_submitit.py --nodes 4 --ngpus 8 --model RepLKNet-31B --drop_path 0.3 --input_size 384 --batch_size 16 --lr 4e-4 --epochs 30 --weight_decay 1e-8 --update_freq 1 --cutmix 0 --mixup 0 --finetune RepLKNet-31B_ImageNet-22K.pth --model_ema true --model_ema_eval true --data_path \u002Fpath\u002Fto\u002Fimagenet-1k --warmup_epochs 1 --job_dir your_training_dir --layer_decay 0.7 --min_lr 3e-4\n```\n### Pretrain RepLKNet-31L on ImageNet-22K\n```\npython run_with_submitit.py --nodes 16 --ngpus 8 --model RepLKNet-31L --drop_path 0.1 --batch_size 32 --lr 4e-3 --update_freq 1 --warmup_epochs 5 --epochs 90 --data_set image_folder --nb_classes 21841 --disable_eval true --data_path \u002Fpath\u002Fto\u002Fimagenet-22k --job_dir \u002Fpath\u002Fto\u002Fsave_results\n```\n### Finetune 22K-pretrained RepLKNet-31L on ImageNet-1K (384x384)\n```\npython run_with_submitit.py --nodes 4 --ngpus 8 --model RepLKNet-31L --drop_path 0.3 --input_size 384 --batch_size 16 --lr 4e-4 --epochs 30 --weight_decay 1e-8 --update_freq 1 --cutmix 0 --mixup 0 --finetune RepLKNet-31L_ImageNet-22K.pth --model_ema true --model_ema_eval true --data_path \u002Fpath\u002Fto\u002Fimagenet-1k --warmup_epochs 1 --job_dir your_training_dir --layer_decay 0.7 --min_lr 3e-4\n```\n\n## Semantic Segmentation and Object Detection\n\nWe use MMSegmentation and MMDetection frameworks. Just clone MMSegmentation or MMDetection, and\n\n1. Put ```segmentation\u002Freplknet.py``` into ```mmsegmentation\u002Fmmseg\u002Fmodels\u002Fbackbones\u002F``` or ```mmdetection\u002Fmmdet\u002Fmodels\u002Fbackbones\u002F```. The only difference between ```segmentation\u002Freplknet.py``` and ```replknet.py``` is the ```@BACKBONES.register_module```.\n2. Add RepLKNet into ```mmsegmentation\u002Fmmseg\u002Fmodels\u002Fbackbones\u002F__init__.py``` or ```mmdetection\u002Fmmdet\u002Fmodels\u002Fbackbones\u002F__init__.py```. That is\n  ```\n  ...\n  from .replknet import RepLKNet\n  __all__ = ['ResNet', ..., 'RepLKNet']\n  ```\n3. Put ```segmentation\u002Fconfigs\u002F*.py``` into ```mmsegmentation\u002Fconfigs\u002Freplknet\u002F``` or ```detection\u002Fconfigs\u002F*.py``` into ```mmdetection\u002Fconfigs\u002Freplknet\u002F```\n4. Download and use our weights. For examples, to evaluate RepLKNet-31B + UperNet on Cityscapes\n  ```\n  python -m torch.distributed.launch --nproc_per_node=8 tools\u002Ftest.py configs\u002Freplknet\u002FRepLKNet-31B_1Kpretrain_upernet_80k_cityscapes_769.py RepLKNet-31B_ImageNet-1K_UperNet_Cityscapes.pth --launcher pytorch --eval mIoU\n  ```\n  or RepLKNet-31B + Cascade Mask R-CNN on COCO\n  ```\n  python -m torch.distributed.launch --nproc_per_node=8 tools\u002Ftest.py configs\u002Freplknet\u002FRepLKNet-31B_22Kpretrain_cascade_mask_rcnn_3x_coco.py RepLKNet-31B_ImageNet-22K_CascMaskRCNN_COCO.pth --eval bbox --launcher pytorch\n  ```\n5. Or you may finetune our released pretrained weights (see the tips below about the batch size and number of iterations)\n  ```\n  python -m torch.distributed.launch --nproc_per_node=8 tools\u002Ftrain.py configs\u002Freplknet\u002Fsome_config.py --launcher pytorch --options model.backbone.pretrained=some_pretrained_weights.pth\n  ```\n  \nWe have released all the Cityscapes\u002FADE20K\u002FCOCO model weights.\n \nSingle-scale (ss) and multi-scale (ms) mIoU tested with UperNet (FLOPs is computed with 2048×512 for the ImageNet-1K pretrained models and 2560×640 for the 22K and MegData73M pretrained models, following Swin): \n  \n| backbone | pretraining | dataset | train schedule | mIoU (ss) | mIoU (ms) | #params | FLOPs | download |\n|:---:|:---:|:---:|:---:| :---:| :---:|:---:|:---:|:---:|\n|RepLKNet-31B | ImageNet-1K | Cityscapes | 80k  | 83.1 | 83.5 | 110M | 2315G | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1j3YwToRqTHHi7ocln0iBz1tE6hItD_JO\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1lqrecK4KQUFt0KobFTFKTQ?pwd=lknt) |\n|RepLKNet-31B | ImageNet-1K | ADE20K     | 160k | 49.9 | 50.6 | 112M | 1170G | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1ZV1CP1KzeSdH6_wKw4ytVe9BlCGHf89s\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1xjNzR7Z82iqsrocRBFGLLw?pwd=lknt) |\n|RepLKNet-31B | ImageNet-22K| ADE20K     | 160k | 51.5 | 52.3 | 112M | 1829G | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1W2W4nD2HzTsG_yP9ppLYAqMo3T3JHBNW\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1fJF1FffgbFoRvzBOT3a_gA?pwd=lknt) |\n|RepLKNet-31L | ImageNet-22K| ADE20K     | 160k | 52.4 | 52.7 | 207M | 2404G | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1nrZ723LC3QYjcVHJm8jpOOcecfWMsjxL\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1W4hc2iuUyfB3UH7OWul60g?pwd=lknt) |\n|RepLKNet-XL  | MegData73M  | ADE20K     | 160k | 55.2 | 56.0 | 374M | 3431G | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F14GbBI8tdeEl_ECytDCdrfAfNm1McqMv4\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1TYSxbj2Zh_Rfq9-aGM3lyA?pwd=lknt) |\n\nCascade Mask R-CNN on COCO (FLOPs is computed with 1280x800):\n\n| backbone | pretraining | method | train schedule | AP_box | AP_mask | #params | FLOPs | download |\n|:---:|:---:|:---:|:---:| :---:| :---:|:---:|:---:|:---:|\n|RepLKNet-31B | ImageNet-1K | FCOS | 2x | 47.0 | - | 87M | 437G | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1g0jSpONBF2wJDXYhB7P3mbqAVE587Myi\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1VsQC073t8xEw7nzvJ2VHqQ?pwd=lknt) |\n|RepLKNet-31B | ImageNet-1K | Cascade Mask RCNN | 3x | 52.2 | 45.2 | 137M | 965G | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1XqWSkQZSLMIhyaQvaIhGbuFhdDoRJQ4Z\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F10uM9ypVwzxhOodOoZzhekQ?pwd=lknt) |\n|RepLKNet-31B | ImageNet-22K | Cascade Mask RCNN | 3x | 53.0 | 46.0 | 137M | 965G | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1faI-MiNuPidum6dC6dGADfYWe6J-bTAz\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1sO55h6GD9x8CxrCxxnFOHg?pwd=lknt) |\n|RepLKNet-31L | ImageNet-22K | Cascade Mask RCNN | 3x | 53.9 | 46.5 | 229M | 1321G | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1qLQONhIjCEuykhdy-wHx1Ah9lT3v2OXh\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F10VSqeiKowQlccZaQ_RB9nQ?pwd=lknt) |\n|RepLKNet-XL | MegData73M | Cascade Mask RCNN | 3x | 55.5 | 48.0 | 392M | 1958G | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1i0TqfwQJQUVHWdB5oyDgxlUUqzPZmIVr\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1AVCX86XVBpznstU5E88cyw?pwd=lknt) |\n\n## Tips on the pretraining or finetuning\n\n1. The mean\u002Fstd values on MegData73M are different from ImageNet. So we used ```mean=[0.5,0.5,0.5], std=[0.5,0.5,0.5]``` for pretraining RepLKNet-XL on MegData73M and finetuning on ImageNet-1K. Accordingly, we should let ```img_norm_cfg = dict(mean=[127.5, 127.5, 127.5], std=[127.5, 127.5, 127.5], to_rgb=True)``` in MMSegmentation and MMDetection. Please check [here](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fblob\u002Fmain\u002Fsegmentation\u002Fconfigs\u002FRepLKNet-XL_MegData73M_upernet_160k_ade20k_640.py#L31) and [here](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fblob\u002Fmain\u002Fdetection\u002Fconfigs\u002FRepLKNet-XL_MegData73Mpretrain_cascade_mask_rcnn_3x_coco.py#L22). For other models, we use the default ImageNet mean\u002Fstd.\n2. For RepLKNet-XL on ADE20K and COCO, we batch-normalize the intermediate feature maps before feeding them into the heads. Just use ```RepLKNet(..., norm_intermediate_features=True)```. We did not try such design on the other models, so we are not sure if it is significant. \n3. For RepLKNet-31B\u002FL on Cityscapes and ADE20K, we used 4 or 8 2080Ti nodes each with 8 GPUs, the batch size per GPU was smaller than the default (the default is 4 per GPU, see [here](https:\u002F\u002Fgithub.com\u002Fopen-mmlab\u002Fmmsegmentation\u002Fblob\u002Fmaster\u002Fconfigs\u002F_base_\u002Fdatasets\u002Fade20k.py#L35)), but the global batch size was larger. Accordingly, we reduced the number of iterations to ensure the same total training samples. Please check the comments in the config files. If you wish to train with our config files, please set the batch size and number of iterations according to your own situation.\n4. Lowering the learning rate for lower-level layers may improve the performance when finetuning on ImageNet-1K or downstream tasks, just like ConvNeXt and BeiT. We are not sure if the improvements would be significant. For ImageNet, [our implementation](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fblob\u002Fmain\u002Foptim_factory.py#L34) simply follows ConvNeXt and BeiT. For MMSegmentation and MMDetection, please raise an issue if you need a showcase, \n5. Tips on the drop_path_rate: bigger model, higher drop_path; bigger pretraining data, lower drop_path.\n\n## Visualizing the Effective Receptive Field\n\nWe have released our script to visualize and analyze the Effective Receptive Field (ERF). For example, to automatically download the ResNet-101 from torchvision and obtain the aggregated contribution score matrix,\n```\npython erf\u002Fvisualize_erf.py --model resnet101 --data_path \u002Fpath\u002Fto\u002Fimagenet-1k --save_path resnet101_erf_matrix.npy\n```\nThen calculate the high-contribution area ratio and visualize the ERF by\n```\npython erf\u002Fanalyze_erf.py --source resnet101_erf_matrix.npy --heatmap_save resnet101_heatmap.png\n```\nNote this plotting script works with matplotlib 3.3. If you use a higher version of matplotlib, see the comments [here](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fblob\u002Fmain\u002Ferf\u002Fanalyze_erf.py#L40).\n\nTo visualize your own model, first define a model that outputs the last feature map rather than the logits (following [this example](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fblob\u002Fmain\u002Ferf\u002Fresnet_for_erf.py#L25)), add the code for building model and loading weights [here](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fblob\u002Fmain\u002Ferf\u002Fvisualize_erf.py#L74), then\n```\npython erf\u002Fvisualize_erf.py --model your_model --weights \u002Fpath\u002Fto\u002Fyour\u002Fweights --data_path \u002Fpath\u002Fto\u002Fimagenet-1k --save_path your_model_erf_matrix.npy\n```\n\nTo reproduced the results in the paper, please download the RepLKNet-13 ([Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F15gohkZof_Qi4__jluUXacB_0Gvbuf5GI\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1a3ntckjrGRM4URMDDSP3Yw?pwd=lknt)) and RepLKNet-31 ([Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1aQQiGfCoiBYSw2Ms506-ZFpnC9V6891s\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1fqp57qWZ2Z5Y-Zr4rCO7jQ?pwd=lknt)) models trained in 120 epochs.\n\n## How to obtain the shape bias\n\n1. Install https:\u002F\u002Fgithub.com\u002Fbethgelab\u002Fmodel-vs-human\n2. Add your code for building model and loading weights in [this file](https:\u002F\u002Fgithub.com\u002Fbethgelab\u002Fmodel-vs-human\u002Fblob\u002Fmaster\u002Fmodelvshuman\u002Fmodels\u002Fpytorch\u002Fmodel_zoo.py). For example\n```\n@register_model(\"pytorch\")\ndef replknet(model_name, *args):\n    model = ...\n    model.load_state_dict(...)\n    return model\n```\n3. Modify examples\u002Fevaluate.py (```models = ['replknet']```) and examples\u002Fplotting_definition.py (```decision_makers.append(DecisionMaker(name_pattern=\"replknet\", ...))```), following its examples. \n\n\n## Acknowledgement\nThe released PyTorch training script is based on the code of [ConvNeXt](https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002FConvNeXt), which was built using the [timm](https:\u002F\u002Fgithub.com\u002Frwightman\u002Fpytorch-image-models) library, [DeiT](https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fdeit) and [BEiT](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Funilm\u002Ftree\u002Fmaster\u002Fbeit) repositories. \n\n## License\nThis project is released under the MIT license. Please see the [LICENSE](LICENSE) file for more information.\n\n## Contact\n\n**xiaohding@gmail.com** (The original Tsinghua mailbox dxh17@mails.tsinghua.edu.cn will expire in several months)\n\nGoogle Scholar Profile: https:\u002F\u002Fscholar.google.com\u002Fcitations?user=CIjw0KoAAAAJ&hl=en\n\nHomepage: https:\u002F\u002Fdingxiaohan.xyz\u002F\n\nMy open-sourced papers and repos: \n\nThe **Structural Re-parameterization Universe**:\n\n1. RepLKNet (CVPR 2022) **Powerful efficient architecture with very large kernels (31x31) and guidelines for using large kernels in model CNNs**\\\n[Scaling Up Your Kernels to 31x31: Revisiting Large Kernel Design in CNNs](https:\u002F\u002Farxiv.org\u002Fabs\u002F2203.06717)\\\n[code](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch).\n\n2. **RepOptimizer** uses **Gradient Re-parameterization** to train powerful models efficiently. The training-time model is as simple as the inference-time. It also addresses the problem of quantization.\\\n[Re-parameterizing Your Optimizers rather than Architectures](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2205.15242.pdf)\\\n[code](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepOptimizers).\n\n3. RepVGG (CVPR 2021) **A super simple and powerful VGG-style ConvNet architecture**. Up to **84.16%** ImageNet top-1 accuracy!\\\n[RepVGG: Making VGG-style ConvNets Great Again](https:\u002F\u002Farxiv.org\u002Fabs\u002F2101.03697)\\\n[code](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepVGG).\n\n4. RepMLP (CVPR 2022) **MLP-style building block and Architecture**\\\n[RepMLPNet: Hierarchical Vision MLP with Re-parameterized Locality](https:\u002F\u002Farxiv.org\u002Fabs\u002F2112.11081)\\\n[code](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepMLP).\n\n5. ResRep (ICCV 2021) **State-of-the-art** channel pruning (Res50, 55\\% FLOPs reduction, 76.15\\% acc)\\\n[ResRep: Lossless CNN Pruning via Decoupling Remembering and Forgetting](https:\u002F\u002Fopenaccess.thecvf.com\u002Fcontent\u002FICCV2021\u002Fpapers\u002FDing_ResRep_Lossless_CNN_Pruning_via_Decoupling_Remembering_and_Forgetting_ICCV_2021_paper.pdf)\\\n[code](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FResRep).\n\n6. ACB (ICCV 2019) is a CNN component without any inference-time costs. The first work of our Structural Re-parameterization Universe.\\\n[ACNet: Strengthening the Kernel Skeletons for Powerful CNN via Asymmetric Convolution Blocks](http:\u002F\u002Fopenaccess.thecvf.com\u002Fcontent_ICCV_2019\u002Fpapers\u002FDing_ACNet_Strengthening_the_Kernel_Skeletons_for_Powerful_CNN_via_Asymmetric_ICCV_2019_paper.pdf).\\\n[code](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FACNet). \n\n7. DBB (CVPR 2021) is a CNN component with higher performance than ACB and still no inference-time costs. Sometimes I call it ACNet v2 because \"DBB\" is 2 bits larger than \"ACB\" in ASCII (lol).\\\n[Diverse Branch Block: Building a Convolution as an Inception-like Unit](https:\u002F\u002Farxiv.org\u002Fabs\u002F2103.13425)\\\n[code](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FDiverseBranchBlock).\n\n**Model compression and acceleration**:\n\n1. (CVPR 2019) Channel pruning: [Centripetal SGD for Pruning Very Deep Convolutional Networks with Complicated Structure](http:\u002F\u002Fopenaccess.thecvf.com\u002Fcontent_CVPR_2019\u002Fhtml\u002FDing_Centripetal_SGD_for_Pruning_Very_Deep_Convolutional_Networks_With_Complicated_CVPR_2019_paper.html)\\\n[code](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FCentripetal-SGD)\n\n2. (ICML 2019) Channel pruning: [Approximated Oracle Filter Pruning for Destructive CNN Width Optimization](http:\u002F\u002Fproceedings.mlr.press\u002Fv97\u002Fding19a.html)\\\n[code](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FAOFP)\n\n3. (NeurIPS 2019) Unstructured pruning: [Global Sparse Momentum SGD for Pruning Very Deep Neural Networks](http:\u002F\u002Fpapers.nips.cc\u002Fpaper\u002F8867-global-sparse-momentum-sgd-for-pruning-very-deep-neural-networks.pdf)\\\n[code](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FGSM-SGD)\n\n\n\n\n\n","# RepLKNet-pytorch (CVPR 2022)\n\n这是 **RepLKNet** 的官方 PyTorch 实现，源自以下 CVPR-2022 论文：\n\n将卷积核扩大到 31x31：重新审视 CNN 中的大卷积核设计。\n\n该论文现已发布在 arXiv 上：https:\u002F\u002Farxiv.org\u002Fabs\u002F2203.06717。\n\n更新：**所有预训练模型、ImageNet-1K 模型以及 Cityscapes\u002FADE20K\u002FCOCO 模型均已发布**。\n\n更新：**发布了用于可视化有效感受野（ERF）的脚本。只需添加几行代码，即可获取您自己模型的有效感受野！**\n\n更新：**发布了训练命令及更多示例**。\n\n如果您觉得这篇论文或本仓库对您有所帮助，请考虑引用：\n\n        @article{replknet,\n        title={Scaling Up Your Kernels to 31x31: Revisiting Large Kernel Design in CNNs},\n        author={Ding, Xiaohan and Zhang, Xiangyu and Zhou, Yizhuang and Han, Jungong and Ding, Guiguang and Sun, Jian},\n        journal={arXiv preprint arXiv:2203.06717},\n        year={2022}\n        }\n\n## 其他实现\n\n| 框架 | 链接 |\n|:---:|:---:|\n|MegEngine（官方）|https:\u002F\u002Fgithub.com\u002Fmegvii-research\u002FRepLKNet|\n|PyTorch（官方）|https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch|\n|TensorFlow|https:\u002F\u002Fgithub.com\u002Fshkarupa-alex\u002Ftfreplknet|\n|PaddlePaddle|https:\u002F\u002Fgithub.com\u002FBR-IDL\u002FPaddleViT\u002Ftree\u002Fdevelop\u002Fimage_classification\u002FRepLKNet|\n| ... | |\n\n欢迎更多复现版本。\n\n## 使用我们的高效大卷积核卷积（PyTorch）\n\n我们已为 **PyTorch** 发布了一个示例。请查看 https:\u002F\u002Fgithub.com\u002FMegEngine\u002Fcutlass\u002Ftree\u002Fmaster\u002Fexamples\u002F19_large_depthwise_conv2d_torch_extension 中的 ```setup.py``` 和 ```depthwise_conv2d_implicit_gemm.py```（**替代 torch.nn.Conv2d**）。\n\n1. 解压 ```cutlass.zip``` 并进入目录。此版本的 cutlass 与我们的大卷积核实现以及多个 Python 版本兼容。您也可以使用 MegEngine 团队维护的 cutlass 分支（克隆 https:\u002F\u002Fgithub.com\u002FMegEngine\u002Fcutlass），但可能需要更注意您的 Python 版本（参见 [此问题](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fissues\u002F34)）。\n2. 进入 ```cd examples\u002F19_large_depthwise_conv2d_torch_extension```\n3. 运行 ```.\u002Fsetup.py install --user```。如果出现错误，请检查您的 ```CUDA_HOME```。\n4. 快速测试：```python depthwise_conv2d_implicit_gemm.py```\n5. 将 ```WHERE_YOU_CLONED_CUTLASS\u002Fexamples\u002F19_large_depthwise_conv2d_torch_extension``` 添加到您的 ```PYTHONPATH``` 中，以便您可以在任何地方 ```from depthwise_conv2d_implicit_gemm import DepthWiseConv2dImplicitGEMM```。然后您可以使用 ```DepthWiseConv2dImplicitGEMM``` 替代 ```nn.Conv2d```。\n6. 设置环境变量 ```export LARGE_KERNEL_CONV_IMPL=WHERE_YOU_CLONED_CUTLASS\u002Fexamples\u002F19_large_depthwise_conv2d_torch_extension```，这样 RepLKNet 就会使用高效的实现。或者您也可以直接修改 ```replknet.py``` 中的相关代码（```get_conv2d```）。\n\n它应该能在多种 GPU 和 PyTorch\u002FCUDA 版本上正常工作。我们建议您先尝试，只有在遇到错误时再检查环境。我们最新的测试使用了以下配置：\n\n1. Ubuntu 18.04 + CUDA 11.3 + nvcc 11.3 + cudnn 8.2.0 + python 3.8.12 + pytorch 1.10 + gcc 7.3.0 + nccl 2.10.3 + NVIDIA 驱动程序 450.102.04 + V100 和 A100 GPU\n2. Ubuntu 18.04 + CUDA 10.2 + nvcc 10.0 + cudnn 7.6.5 + python 3.6.9 + pytorch 1.9 + gcc 7.5.0 + nccl 2.7.8 + NVIDIA 驱动程序 460.32.03 + 2080Ti 和 V100 GPU\n\n据报道（参见 [这里](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fissues\u002F34)），Python 版本不匹配可能会导致错误（```forward_fp32.cu(212): error: more than one instance of constructor \"cutlass::Tensor4DCoord::Tensor4DCoord\" ...``` 或 ```cutlass\u002Finclude\u002Fcutlass\u002Ffast_math.h(741): error: no suitable conversion function from \"__half\" to \"float\" exists```)。请升级或降级您的 Python 版本。我们衷心感谢 @sleeplessai 和 @ewrfcas 分享他们的经验。\n\n我们在论文中提到的实现已被集成到 MegEngine 中，引擎会自动使用它。如果您想在其他框架如 TensorFlow 中使用，可能需要编译我们发布的 CUDA 源代码（上述示例中的 ```*.cu``` 文件应适用于其他框架），并使用一些工具来加载它们，就像 PyTorch 示例中的 ```cutlass``` 和 ```torch.utils.cpp_extension``` 一样。如果您能与我们分享您的经验，我们将不胜感激。\n\n您可以参考 MegEngine 的源代码：https:\u002F\u002Fgithub.com\u002FMegEngine\u002FMegEngine\u002Ftree\u002F8a2e92bd6c5ac02807b27d174dce090ee391000b\u002Fdnn\u002Fsrc\u002Fcuda\u002Fconv_bias\u002Fchanwise。\n\n欢迎提交 Pull 请求（例如更好的实现、其他实现或针对其他框架的实现）。\n\n## 目录\n- [x] 模型代码\n- [x] PyTorch 预训练模型\n- [x] PyTorch 大卷积核卷积实现\n- [x] PyTorch 训练代码\n- [x] PyTorch 下游模型\n- [x] PyTorch 下游代码\n- [x] 用于可视化 ERF 的脚本\n- [x] 如何获取形状偏差\n\n\u003C!-- ✅ ⬜️  -->\n\n## 结果与预训练模型\n\n### ImageNet-1K 模型\n\n| 名称 | 分辨率 | ImageNet-1K 准确率 | 参数量 | FLOPs | ImageNet-1K 预训练模型 |\n|:---:|:---:|:---:|:---:| :---:|:---:|\n|RepLKNet-31B|224x224|83.5| 79M   |  15.3G   |[Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1azQUiCxK9feYVkkrPqwVPBtNsTzDrX7S\u002Fview?usp=sharing), [百度网盘](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1gspbbfqooMtegt_DO1TUeA?pwd=lknt)|\n|RepLKNet-31B|384x384|84.8| 79M   |  45.1G   |[Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1vo-P3XB6mRLUeDzmgv90dOu73uCeLfZN\u002Fview?usp=sharing), [百度网盘](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1WhLaCKKv4NuKc3qMYECOIQ?pwd=lknt)|\n\n\n\n### ImageNet-22K 模型\n\n| 名称 | 分辨率 | ImageNet-1K 准确率 | 参数量 | FLOPs | 22K 预训练模型 | 1K 微调后模型 |\n|:---:|:---:|:---:|:---:| :---:|:---:|:---:|\n|RepLKNet-31B|224x224|  85.2  |  79M  |  15.3G  |[Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1PYJiMszZYNrkZOeYwjccvxX8UHMALB7z\u002Fview?usp=sharing), [百度网盘](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1YiQSn7VJDiNWX1IWg19O6g?pwd=lknt)|[Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1DslZ2voXZQR1QoFY9KnbsHAeF84hzS0s\u002Fview?usp=sharing), [百度网盘](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F169wDunCdop-jQM8K-AX27g?pwd=lknt)|\n|RepLKNet-31B|384x384|  86.0  |  79M  | 45.1G   | - |[Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1Sc46BWdXXm2fVP-K_hKKU_W8vAB-0duX\u002Fview?usp=sharing), [百度网盘](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F11-F3JIKEzSOU7KUhebUWEQ?pwd=lknt)|\n|RepLKNet-31L|384x384|  86.6  |  172M  |  96.0G  |[Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F16jcPsPwo5rko7ojWS9k_W-svHX-iFknY\u002Fview?usp=sharing), [百度网盘](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1KWazk_cOVYoLuuVJc_9HxA?pwd=lknt)|[Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1JYXoNHuRvC33QV1pmpzMTKEni1hpWfBl\u002Fview?usp=sharing), [百度网盘](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1MWIsPXJJV4mTEtgcKv3F3w?pwd=lknt)|\n\n### MegData-73M 模型\n\n| 名称 | 分辨率 | ImageNet-1K 准确率 | 参数量 | FLOPs | MegData-73M 预训练模型 | 1K 微调模型 |\n|:---:|:---:|:---:|:---:| :---:| :---:|:---:|\n|RepLKNet-XL| 320x320 | 87.8 | 335M | 128.7G | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1CBHAEUlCzoHfiAQmMIjZhDMAIyHUmAAj\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F168Wb2P3rSp23-DCpNG3aCQ?pwd=lknt) | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1tPC60El34GntXByIRHb-z-Apm4Y5LX1T\u002Fview?usp=sharing), [Baidu](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1C1bJJLz9O28ChZ4NcxjUsw?pwd=lknt)|\n\n\n\n## 评估\n\n对于分辨率为 224x224 或 384x384 的 RepLKNet-31B\u002FL，我们使用 \"IMAGENET_DEFAULT_MEAN\u002FSTD\" 进行预处理（参见 [此处](https:\u002F\u002Fgithub.com\u002Frwightman\u002Fpytorch-image-models\u002Fblob\u002F73ffade1f8203a611c9cdd6df437b436b780daca\u002Ftimm\u002Fdata\u002Fconstants.py#L2)）。例如：\n```\npython -m torch.distributed.launch --nproc_per_node=8 main.py --model RepLKNet-31B --batch_size 32 --eval True --resume RepLKNet-31B_ImageNet-1K_224.pth --input_size 224\n```\n或者\n```\npython -m torch.distributed.launch --nproc_per_node=8 main.py --model RepLKNet-31L --batch_size 32 --eval True --resume RepLKNet-31L_ImageNet-22K-to-1K_384.pth --input_size 384\n```\n\n对于 RepLKNet-XL，请注意，我们在 MegData73M 数据集以及 ImageNet-1K 上的微调中，均使用了 ```mean=[0.5,0.5,0.5]``` 和 ```std=[0.5,0.5,0.5]``` 进行预处理。这种均值和标准差设置在 timm 中也被称为 \"IMAGENET_INCEPTION_MEAN\u002FSTD\"，详见 [此处](https:\u002F\u002Fgithub.com\u002Frwightman\u002Fpytorch-image-models\u002Fblob\u002F73ffade1f8203a611c9cdd6df437b436b780daca\u002Ftimm\u002Fdata\u002Fconstants.py#L4)。要使用此均值和标准差设置，请添加 ```--imagenet_default_mean_and_std false```（参见 [此处](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fblob\u002Fmain\u002Fdatasets.py#L58)）。正如论文中所提到的，我们并未使用小卷积核进行重参数化。\n```\npython -m torch.distributed.launch --nproc_per_node=8 main.py --model RepLKNet-XL --batch_size 32 --eval true --resume RepLKNet-XL_MegData73M_ImageNet1K.pth --imagenet_default_mean_and_std false --input_size 320\n```\n\n为了验证结构重参数化的等价性（即在执行 ```structural_reparam``` 之前和之后的输出是否相同），请添加 ```--with_small_kernel_merged true```。\n\n## 训练\n\n您可以在 SLURM 集群上使用 [submitit](https:\u002F\u002Fgithub.com\u002Ffacebookincubator\u002Fsubmitit) 进行多节点训练。请先安装：\n```\npip install submitit\n```\n\n如果您 GPU 显存有限（例如 2080Ti），可以使用 ```--use_checkpoint true``` 来节省显存。\n\n### 在 ImageNet-1K 上预训练 RepLKNet-31B\n单机（注意 ```--update_freq 4```）：\n```\npython -m torch.distributed.launch --nproc_per_node=8 main.py --model RepLKNet-31B --drop_path 0.5 --batch_size 64 --lr 4e-3 --update_freq 4 --model_ema true --model_ema_eval true --data_path \u002Fpath\u002Fto\u002Fimagenet-1k --warmup_epochs 10 --epochs 300 --output_dir your_training_dir\n```\n\n四台机器（注意 ```--update_freq 1```）：\n```\npython run_with_submitit.py --nodes 4 --ngpus 8 --model RepLKNet-31B --drop_path 0.5 --batch_size 64 --lr 4e-3 --update_freq 1 --model_ema true --model_ema_eval true --data_path \u002Fpath\u002Fto\u002Fimagenet-1k --warmup_epochs 10 --epochs 300 --job_dir your_training_dir\n```\n\n以下仅列出多机命令。您也可以用类似的方式在单机上进行训练。\n\n### 将 ImageNet-1K 预训练的（224x224）RepLKNet-31B 微调至 384x384\n```\npython run_with_submitit.py --nodes 4 --ngpus 8 --model RepLKNet-31B --drop_path 0.8 --input_size 384 --batch_size 32 --lr 4e-4 --epochs 30 --weight_decay 1e-8 --update_freq 1 --cutmix 0 --mixup 0 --finetune RepLKNet-31B_ImageNet-1K_224.pth --model_ema true --model_ema_eval true --data_path \u002Fpath\u002Fto\u002Fimagenet-1k --warmup_epochs 1 --job_dir your_training_dir --layer_decay 0.7\n```\n\n### 在 ImageNet-22K 上预训练 RepLKNet-31B\n```\npython run_with_submitit.py --nodes 16 --ngpus 8 --model RepLKNet-31B --drop_path 0.1 --batch_size 32 --lr 4e-3 --update_freq 1 --warmup_epochs 5 --epochs 90 --data_set image_folder --nb_classes 21841 --disable_eval true --data_path \u002Fpath\u002Fto\u002Fimagenet-22k --job_dir \u002Fpath\u002Fto\u002Fsave_results\n```\n\n### 将 22K 预训练的 RepLKNet-31B 微调至 ImageNet-1K（224x224）\n```\npython run_with_submitit.py --nodes 2 --ngpus 8 --model RepLKNet-31B --drop_path 0.2 --input_size 224 --batch_size 32 --lr 4e-4 --epochs 30 --weight_decay 1e-8 --update_freq 1 --cutmix 0 --mixup 0 --finetune RepLKNet-31B_ImageNet-22K.pth --model_ema true --model_ema_eval true --data_path \u002Fpath\u002Fto\u002Fimagenet-1k --warmup_epochs 1 --job_dir your_training_dir --layer_decay 0.7\n```\n\n### 将 22K 预训练的 RepLKNet-31B 微调至 ImageNet-1K（384x384）\n```\npython run_with_submitit.py --nodes 4 --ngpus 8 --model RepLKNet-31B --drop_path 0.3 --input_size 384 --batch_size 16 --lr 4e-4 --epochs 30 --weight_decay 1e-8 --update_freq 1 --cutmix 0 --mixup 0 --finetune RepLKNet-31B_ImageNet-22K.pth --model_ema true --model_ema_eval true --data_path \u002Fpath\u002Fto\u002Fimagenet-1k --warmup_epochs 1 --job dir your training dir --layer decay 0.7 --min_lr 3e-4\n```\n\n### 在 ImageNet-22K 上预训练 RepLKNet-31L\n```\npython run_with_submitit.py --nodes 16 --ngpus 8 --model RepLKNet-31L --drop_path 0.1 --batch_size 32 --lr 4e-3 --update_freq 1 --warmup epochs 5 --epochs 90 --data_set image_folder --nb_classes 21841 --disable eval true --data path \u002Fpath\u002Fto\u002Fimagenet-22k --job dir \u002Fpath\u002Fto\u002Fsave results\n```\n\n### 将 22K 预训练的 RepLKNet-31L 微调至 ImageNet-1K（384x384）\n```\npython run_with_submitit.py --nodes 4 --ngpus 8 --model RepLKNet-31L --drop_path 0.3 --input size 384 --batch size 16 --lr 4e-4 --epochs 30 --weight decay 1e-8 --update freq 1 --cutmix 0 --mixup 0 --finetune RepLKNet-31L_ImageNet-22K.pth --model ema true --model ema eval true --data path \u002Fpath\u002Fto\u002Fimagenet-1k --warmup epochs 1 --job dir your training dir --layer decay 0.7 --min lr 3e-4\n```\n\n## 语义分割与目标检测\n\n我们使用 MMSegmentation 和 MMDetection 框架。只需克隆 MMSegmentation 或 MMDetection，然后：\n\n1. 将 `segmentation\u002Freplknet.py` 放入 `mmsegmentation\u002Fmmseg\u002Fmodels\u002Fbackbones\u002F` 或 `mmdetection\u002Fmmdet\u002Fmodels\u002Fbackbones\u002F` 目录中。`segmentation\u002Freplknet.py` 和 `replknet.py` 的唯一区别在于装饰器 `@BACKBONES.register_module`。\n2. 在 `mmsegmentation\u002Fmmseg\u002Fmodels\u002Fbackbones\u002F__init__.py` 或 `mmdetection\u002Fmmdet\u002Fmodels\u002Fbackbones\u002F__init__.py` 中添加 RepLKNet。具体如下：\n   ```\n   ...\n   from .replknet import RepLKNet\n   __all__ = ['ResNet', ..., 'RepLKNet']\n   ```\n3. 将 `segmentation\u002Fconfigs\u002F*.py` 文件放入 `mmsegmentation\u002Fconfigs\u002Freplknet\u002F` 目录，或将 `detection\u002Fconfigs\u002F*.py` 文件放入 `mmdetection\u002Fconfigs\u002Freplknet\u002F` 目录。\n4. 下载并使用我们的预训练权重。例如，在 Cityscapes 数据集上评估 RepLKNet-31B + UperNet：\n   ```\n   python -m torch.distributed.launch --nproc_per_node=8 tools\u002Ftest.py configs\u002Freplknet\u002FRepLKNet-31B_1Kpretrain_upernet_80k_cityscapes_769.py RepLKNet-31B_ImageNet-1K_UperNet_Cityscapes.pth --launcher pytorch --eval mIoU\n   ```\n   或者在 COCO 数据集上评估 RepLKNet-31B + Cascade Mask R-CNN：\n   ```\n   python -m torch.distributed.launch --nproc_per_node=8 tools\u002Ftest.py configs\u002Freplknet\u002FRepLKNet-31B_22Kpretrain_cascade_mask_rcnn_3x_coco.py RepLKNet-31B_ImageNet-22K_CascMaskRCNN_COCO.pth --eval bbox --launcher pytorch\n   ```\n5. 你也可以对已发布的预训练权重进行微调（有关批次大小和迭代次数的提示见下文）：\n   ```\n   python -m torch.distributed.launch --nproc_per_node=8 tools\u002Ftrain.py configs\u002Freplknet\u002Fsome_config.py --launcher pytorch --options model.backbone.pretrained=some_pretrained_weights.pth\n   ```\n\n我们已发布了所有 Cityscapes\u002FADE20K\u002FCOCO 数据集的模型权重。\n\n采用单尺度 (ss) 和多尺度 (ms) 测试的 mIoU 均基于 UperNet，FLOPs 计算时，ImageNet-1K 预训练模型使用 2048×512 分辨率，而 22K 和 MegData73M 预训练模型则使用 2560×640 分辨率，遵循 Swin 的做法：\n\n| 主干网络 | 预训练数据集 | 数据集     | 训练计划       | mIoU (ss) | mIoU (ms) | 参数量 | FLOPs    | 下载链接                     |\n|:---:|:---:|:---:|:---:| :---:| :---:|:---:|:---:|:---:|\n| RepLKNet-31B | ImageNet-1K | Cityscapes | 8万次迭代     | 83.1      | 83.5      | 1.1亿  | 2315G    | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1j3YwToRqTHHi7ocln0iBz1tE6hItD_JO\u002Fview?usp=sharing), [百度网盘](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1lqrecK4KQUFt0KobFTFKTQ?pwd=lknt) |\n| RepLKNet-31B | ImageNet-1K | ADE20K     | 16万次迭代    | 49.9      | 50.6      | 1.12亿 | 1170G    | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1ZV1CP1KzeSdH6_wKw4ytVe9BlCGHf89s\u002Fview?usp=sharing), [百度网盘](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1xjNzR7Z82iqsrocRBFGLLw?pwd=lknt) |\n| RepLKNet-31B | ImageNet-22K | ADE20K     | 16万次迭代    | 51.5      | 52.3      | 1.12亿 | 1829G    | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1W2W4nD2HzTsG_yP9ppLYAqMo3T3JHBNW\u002Fview?usp=sharing), [百度网盘](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1fJF1FffgbFoRvzBOT3a_gA?pwd=lknt) |\n| RepLKNet-31L | ImageNet-22K | ADE20K     | 16万次迭代    | 52.4      | 52.7      | 2.07亿 | 2404G    | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1nrZ723LC3QYjcVHJm8jpOOcecfWMsjxL\u002Fview?usp=sharing), [百度网盘](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1W4hc2iuUyfB3UH7OWul60g?pwd=lknt) |\n| RepLKNet-XL  | MegData73M  | ADE20K     | 16万次迭代    | 55.2      | 56.0      | 3.74亿 | 3431G    | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F14GbBI8tdeEl_ECytDCdrfAfNm1McqMv4\u002Fview?usp=sharing), [百度网盘](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1TYSxbj2Zh_Rfq9-aGM3lyA?pwd=lknt) |\n\nCOCO 数据集上的 Cascade Mask R-CNN（FLOPs 计算时使用 1280×800 分辨率）：\n\n| 主干网络 | 预训练数据集 | 方法         | 训练计划       | AP_box | AP_mask | 参数量 | FLOPs    | 下载链接                     |\n|:---:|:---:|:---:|:---:| :---:| :---:|:---:|:---:|:---:|\n| RepLKNet-31B | ImageNet-1K | FCOS         | 2倍周期        | 47.0    | -       | 8700万 | 437G     | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1g0jSpONBF2wJDXYhB7P3mbqAVE587Myi\u002Fview?usp=sharing), [百度网盘](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1VsQC073t8xEw7nzvJ2VHqQ?pwd=lknt) |\n| RepLKNet-31B | ImageNet-1K | Cascade Mask R-CNN | 3倍周期        | 52.2    | 45.2    | 1.37亿 | 965G     | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1XqWSkQZSLMIhyaQvaIhGbuFhdDoRJQ4Z\u002Fview?usp=sharing), [百度网盘](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F10uM9ypVwzxhOodOoZzhekQ?pwd=lknt) |\n| RepLKNet-31B | ImageNet-22K | Cascade Mask R-CNN | 3倍周期        | 53.0    | 46.0    | 1.37亿 | 965G     | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1faI-MiNuPidum6dC6dGADfYWe6J-bTAz\u002Fview?usp=sharing), [百度网盘](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1sO55h6GD9x8CxrCxxnFOHg?pwd=lknt) |\n| RepLKNet-31L | ImageNet-22K | Cascade Mask R-CNN | 3倍周期        | 53.9    | 46.5    | 2.29亿 | 1321G    | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1qLQONhIjCEuykhdy-wHx1Ah9lT3v2OXh\u002Fview?usp=sharing), [百度网盘](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F10VSqeiKowQlccZaQ_RB9nQ?pwd=lknt) |\n| RepLKNet-XL | MegData73M | Cascade Mask R-CNN | 3倍周期        | 55.5    | 48.0    | 3.92亿 | 1958G    | [Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1i0TqfwQJQUVHWdB5oyDgxlUUqzPZmIVr\u002Fview?usp=sharing), [百度网盘](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1AVCX86XVBpznstU5E88cyw?pwd=lknt) |\n\n## 预训练或微调的几点建议\n\n1. MegData73M 数据集上的均值\u002F标准差与 ImageNet 不同。因此，我们在 MegData73M 上对 RepLKNet-XL 进行预训练，并在 ImageNet-1K 上进行微调时，使用了 ```mean=[0.5,0.5,0.5], std=[0.5,0.5,0.5]```。相应地，在 MMSegmentation 和 MMDetection 中，应设置 ```img_norm_cfg = dict(mean=[127.5, 127.5, 127.5], std=[127.5, 127.5, 127.5], to_rgb=True)```。请参考 [此处](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fblob\u002Fmain\u002Fsegmentation\u002Fconfigs\u002FRepLKNet-XL_MegData73M_upernet_160k_ade20k_640.py#L31) 和 [此处](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fblob\u002Fmain\u002Fdetection\u002Fconfigs\u002FRepLKNet-XL_MegData73Mpretrain_cascade_mask_rcnn_3x_coco.py#L22)。对于其他模型，我们则沿用默认的 ImageNet 均值\u002F标准差。\n   \n2. 对于在 ADE20K 和 COCO 数据集上使用的 RepLKNet-XL，我们在将中间特征图输入到头部之前进行了批量归一化处理。只需使用 ```RepLKNet(..., norm_intermediate_features=True)``` 即可。我们尚未在其他模型上尝试这种设计，因此不确定其效果是否显著。\n\n3. 对于在 Cityscapes 和 ADE20K 数据集上使用的 RepLKNet-31B\u002FL，我们分别使用了 4 或 8 个配备 8 张 2080Ti 显卡的节点，每张显卡的批大小低于默认值（默认为每张显卡 4 个样本，详见 [此处](https:\u002F\u002Fgithub.com\u002Fopen-mmlab\u002Fmmsegmentation\u002Fblob\u002Fmaster\u002Fconfigs\u002F_base_\u002Fdatasets\u002Fade20k.py#L35)），但全局批大小更大。为此，我们减少了迭代次数，以确保总的训练样本数不变。请参阅配置文件中的注释。如果您希望使用我们的配置文件进行训练，请根据自身情况调整批大小和迭代次数。\n\n4. 在 ImageNet-1K 或下游任务上进行微调时，降低低层网络的学习率可能会提升性能，这一点与 ConvNeXt 和 BeiT 类似。不过，我们尚不确定这种改进是否显著。对于 ImageNet，[我们的实现](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fblob\u002Fmain\u002Foptim_factory.py#L34)直接参考了 ConvNeXt 和 BeiT 的做法。若在 MMSegmentation 和 MMDetection 中需要相关示例，请提交问题。\n\n5. 关于 drop_path_rate 的建议：模型越大，drop_path 应越高；预训练数据越多，drop_path 则越低。\n\n## 可视化有效感受野\n\n我们已发布用于可视化和分析有效感受野（ERF）的脚本。例如，要自动下载 torchvision 中的 ResNet-101 模型并获取聚合贡献度矩阵，可以运行以下命令：\n```\npython erf\u002Fvisualize_erf.py --model resnet101 --data_path \u002Fpath\u002Fto\u002Fimagenet-1k --save_path resnet101_erf_matrix.npy\n```\n随后，可通过以下命令计算高贡献区域比例并可视化 ERF：\n```\npython erf\u002Fanalyze_erf.py --source resnet101_erf_matrix.npy --heatmap_save resnet101_heatmap.png\n```\n请注意，该绘图脚本适用于 matplotlib 3.3 版本。若您使用更高版本的 matplotlib，请参考 [此处](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fblob\u002Fmain\u002Ferf\u002Fanalyze_erf.py#L40) 的注释说明。\n\n若要可视化您自己的模型，首先需定义一个输出最后一层特征图而非 logits 的模型（参考 [此示例](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fblob\u002Fmain\u002Ferf\u002Fresnet_for_erf.py#L25)），并在 [此处](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fblob\u002Fmain\u002Ferf\u002Fvisualize_erf.py#L74) 添加构建模型和加载权重的相关代码，然后运行：\n```\npython erf\u002Fvisualize_erf.py --model your_model --weights \u002Fpath\u002Fto\u002Fyour\u002Fweights --data_path \u002Fpath\u002Fto\u002Fimagenet-1k --save_path your_model_erf_matrix.npy\n```\n\n若想复现论文中的结果，请下载经过 120 个 epoch 训练的 RepLKNet-13（[Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F15gohkZof_Qi4__jluUXacB_0Gvbuf5GI\u002Fview?usp=sharing)，[百度网盘](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1a3ntckjrGRM4URMDDSP3Yw?pwd=lknt)）和 RepLKNet-31（[Google Drive](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1aQQiGfCoiBYSw2Ms506-ZFpnC9V6891s\u002Fview?usp=sharing)，[百度网盘](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1fqp57qWZ2Z5Y-Zr4rCO7jQ?pwd=lknt)）模型。\n\n## 如何获取形状偏差\n\n1. 安装 https:\u002F\u002Fgithub.com\u002Fbethgelab\u002Fmodel-vs-human。\n2. 将您构建模型和加载权重的代码添加到 [此文件](https:\u002F\u002Fgithub.com\u002Fbethgelab\u002Fmodel-vs-human\u002Fblob\u002Fmaster\u002Fmodelvshuman\u002Fmodels\u002Fpytorch\u002Fmodel_zoo.py) 中。例如：\n```\n@register_model(\"pytorch\")\ndef replknet(model_name, *args):\n    model = ...\n    model.load_state_dict(...)\n    return model\n```\n3. 根据其示例，修改 examples\u002Fevaluate.py（```models = ['replknet']```）和 examples\u002Fplotting_definition.py（```decision_makers.append(DecisionMaker(name_pattern=\"replknet\", ...))```）。\n\n## 致谢\n\n本次发布的 PyTorch 训练脚本基于 [ConvNeXt](https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002FConvNeXt) 的代码，该代码使用了 [timm](https:\u002F\u002Fgithub.com\u002Frwightman\u002Fpytorch-image-models) 库、[DeiT](https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fdeit) 和 [BEiT](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Funilm\u002Ftree\u002Fmaster\u002Fbeit) 等项目的技术成果。\n\n## 许可证\n\n本项目采用 MIT 许可证开源。更多信息请参阅 [LICENSE](LICENSE) 文件。\n\n## 联系方式\n\n**xiaohding@gmail.com**（原清华大学邮箱 dxh17@mails.tsinghua.edu.cn 将于数月后失效）\n\nGoogle Scholar 个人主页：https:\u002F\u002Fscholar.google.com\u002Fcitations?user=CIjw0KoAAAAJ&hl=en\n\n个人主页：https:\u002F\u002Fdingxiaohan.xyz\u002F\n\n我的开源论文与代码库：\n\n**结构重参数化宇宙**：\n\n1. RepLKNet（CVPR 2022）**具有超大卷积核（31×31）的强大高效架构，并提供了在 CNN 模型中使用大卷积核的指导原则**  \n[将卷积核扩大到 31×31：重新审视 CNN 中的大卷积核设计](https:\u002F\u002Farxiv.org\u002Fabs\u002F2203.06717)  \n[代码](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch)。\n\n2. **RepOptimizer** 使用**梯度重参数化**高效训练强大模型。其训练时的模型结构与推理时完全一致，同时解决了量化问题。  \n[与其重参数化架构，不如重参数化优化器](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2205.15242.pdf)  \n[代码](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepOptimizers)。\n\n3. RepVGG（CVPR 2021）**一种超级简单且强大的 VGG 风格卷积神经网络架构**。在 ImageNet 上最高可达 **84.16%** 的 top-1 准确率！  \n[RepVGG：让 VGG 风格的卷积神经网络再次伟大](https:\u002F\u002Farxiv.org\u002Fabs\u002F2101.03697)  \n[代码](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepVGG)。\n\n4. RepMLP（CVPR 2022）**MLP 风格的构建模块及架构**  \n[RepMLPNet：具有重参数化局部性的层次化视觉 MLP](https:\u002F\u002Farxiv.org\u002Fabs\u002F2112.11081)  \n[代码](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepMLP)。\n\n5. ResRep（ICCV 2021）**最先进的**通道剪枝技术（ResNet50，FLOPs 减少 55%，准确率 76.15%）  \n[ResRep：通过解耦记忆与遗忘实现无损 CNN 剪枝](https:\u002F\u002Fopenaccess.thecvf.com\u002Fcontent\u002FICCV2021\u002Fpapers\u002FDing_ResRep_Lossless_CNN_Pruning_via_Decoupling_Remembering_and_Forgetting_ICCV_2021_paper.pdf)  \n[代码](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FResRep)。\n\n6. ACB（ICCV 2019）是一种在推理阶段无需额外开销的 CNN 组件，也是我们“结构重参数化宇宙”的开山之作。  \n[ACNet：通过非对称卷积块强化卷积核骨架，打造更强大的 CNN](http:\u002F\u002Fopenaccess.thecvf.com\u002Fcontent_ICCV_2019\u002Fpapers\u002FDing_ACNet_Strengthening_the_Kernel_Skeletons_for_Powerful_CNN_via_Asymmetric_ICCV_2019_paper.pdf)  \n[代码](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FACNet)。\n\n7. DBB（CVPR 2021）是一种性能优于 ACB 且同样无需推理开销的 CNN 组件。有时我称它为 ACNet v2，因为“DBB”在 ASCII 码中比“ACB”多两位（哈哈）。  \n[多样化分支模块：将卷积层构建为类似 Inception 的单元](https:\u002F\u002Farxiv.org\u002Fabs\u002F2103.13425)  \n[代码](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FDiverseBranchBlock)。\n\n**模型压缩与加速**：\n\n1. （CVPR 2019）通道剪枝：[向心式 SGD 用于剪枝结构复杂的超深卷积神经网络](http:\u002F\u002Fopenaccess.thecvf.com\u002Fcontent_CVPR_2019\u002Fhtml\u002FDing_Centripetal_SGD_for_Pruning_Very_Deep_Convolutional_Networks_With_Complicated_CVPR_2019_paper.html)  \n[代码](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FCentripetal-SGD)。\n\n2. （ICML 2019）通道剪枝：[近似 Oracle 过滤器剪枝用于破坏性 CNN 宽度优化](http:\u002F\u002Fproceedings.mlr.press\u002Fv97\u002Fding19a.html)  \n[代码](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FAOFP)。\n\n3. （NeurIPS 2019）非结构化剪枝：[全局稀疏动量 SGD 用于剪枝超深神经网络](http:\u002F\u002Fpapers.nips.cc\u002Fpaper\u002F8867-global-sparse-momentum-sgd-for-pruning-very-deep-neural-networks.pdf)  \n[代码](https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FGSM-SGD)","# RepLKNet-pytorch 快速上手指南\n\nRepLKNet 是 CVPR 2022 提出的基于大卷积核（最大 31x31）的 CNN 架构。本指南帮助开发者快速在 PyTorch 环境中部署和使用该模型。\n\n## 环境准备\n\n### 系统要求\n*   **操作系统**: Linux (推荐 Ubuntu 18.04+)\n*   **GPU**: NVIDIA GPU (支持 V100, A100, 2080Ti 等)\n*   **CUDA**: 建议 CUDA 10.2 或 11.3+\n*   **Python**: 建议 Python 3.6.9 - 3.8.12 (版本不匹配可能导致编译错误)\n*   **PyTorch**: 建议 1.9 或 1.10+\n\n### 前置依赖\n确保已安装以下基础库：\n```bash\npip install torch torchvision timm submitit\n```\n> **注意**：`submitit` 用于多节点训练，单机训练可不安装。\n\n## 安装步骤\n\n### 1. 克隆代码库\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch.git\ncd RepLKNet-pytorch\n```\n\n### 2. 配置高效大核卷积算子 (可选但推荐)\n为了获得论文中所述的最佳性能，需编译自定义 CUDA 算子 (`DepthWiseConv2dImplicitGEMM`)。若跳过此步，代码将自动回退到标准实现，但速度较慢。\n\n**步骤 A: 获取 CUTLASS 源码**\n下载并解压项目提供的 cutlass 包，或从 MegEngine 仓库克隆：\n```bash\n# 方式一：使用项目提供的 zip (如有)\nunzip cutlass.zip\n# 方式二：从官方源克隆 (需注意 Python 版本兼容性)\ngit clone https:\u002F\u002Fgithub.com\u002FMegEngine\u002Fcutlass.git\n```\n\n**步骤 B: 编译扩展**\n进入指定目录并安装：\n```bash\ncd cutlass\u002Fexamples\u002F19_large_depthwise_conv2d_torch_extension\npython setup.py install --user\n```\n*若报错，请检查 `CUDA_HOME` 环境变量是否正确指向 CUDA 安装路径。*\n\n**步骤 C: 配置环境变量**\n将编译好的路径加入 `PYTHONPATH`，并设置环境变量让 RepLKNet 调用该实现：\n```bash\n# 请将路径替换为你实际的克隆路径\nexport PYTHONPATH=$PYTHONPATH:\u002Fpath\u002Fto\u002Fcutlass\u002Fexamples\u002F19_large_depthwise_conv2d_torch_extension\nexport LARGE_KERNEL_CONV_IMPL=\u002Fpath\u002Fto\u002Fcutlass\u002Fexamples\u002F19_large_depthwise_conv2d_torch_extension\n```\n\n### 3. 验证安装\n运行快速检查脚本：\n```bash\npython depthwise_conv2d_implicit_gemm.py\n```\n若无报错，则环境配置成功。\n\n## 基本使用\n\n### 加载预训练模型进行推理\n以下示例展示如何加载 ImageNet-1K 预训练的 `RepLKNet-31B` 模型并进行评估。\n\n**单卡\u002F单机评估命令：**\n```bash\npython -m torch.distributed.launch --nproc_per_node=8 main.py \\\n--model RepLKNet-31B \\\n--batch_size 32 \\\n--eval True \\\n--resume RepLKNet-31B_ImageNet-1K_224.pth \\\n--input_size 224 \\\n--data_path \u002Fpath\u002Fto\u002Fimagenet-1k\n```\n\n**关键参数说明：**\n*   `--model`: 模型名称 (如 `RepLKNet-31B`, `RepLKNet-31L`, `RepLKNet-XL`)。\n*   `--resume`: 预训练权重文件路径。\n    *   **国内下载加速**: 百度网盘提取码均为 `lknt` (详见项目 README 中的表格)。\n*   `--input_size`: 输入分辨率 (224, 320, 或 384)。\n*   `--imagenet_default_mean_and_std`: \n    *   对于 `RepLKNet-XL` (MegData-73M 预训练)，**必须**添加 `--imagenet_default_mean_and_std false`。\n    *   其他模型默认使用 ImageNet 标准均值方差，无需额外参数。\n\n### 代码调用示例 (Python)\n在您的 Python 脚本中直接调用：\n\n```python\nimport torch\nfrom replknet import create_model\n\n# 创建模型\nmodel = create_model(\n    model_name='repLKNet31B', \n    pretrained=True, \n    num_classes=1000\n)\nmodel.eval()\n\n# 准备输入 (Batch, Channels, Height, Width)\ninput_tensor = torch.randn(1, 3, 224, 224)\n\n# 前向传播\nwith torch.no_grad():\n    output = model(input_tensor)\n\nprint(output.shape)\n```\n\n### 显存优化\n如果您的 GPU 显存较小（如 2080Ti），在训练或大分辨率推理时，可启用梯度检查点以节省显存：\n```bash\n# 在训练命令中添加\n--use_checkpoint true\n```","某自动驾驶团队正在开发城市道路语义分割系统，急需提升模型对远处小目标和复杂路况的感知能力。\n\n### 没有 RepLKNet-pytorch 时\n- **感受野受限**：传统 CNN 依赖堆叠多层小卷积核来扩大感受野，导致网络过深，难以有效捕捉大范围上下文信息，远处车辆识别率低。\n- **细节丢失严重**：为了获取全局信息被迫使用大步长下采样，导致空间分辨率下降，车道线等细微结构的分割边缘模糊。\n- **推理延迟高**：为弥补精度不足而增加网络深度或引入复杂的注意力机制，显著增加了计算量和显存占用，无法满足车载芯片的实时性要求。\n- **调优成本高**：尝试混合架构（如 CNN+Transformer）带来了巨大的工程适配工作量，且训练收敛缓慢，难以快速迭代验证。\n\n### 使用 RepLKNet-pytorch 后\n- **超大感受野直达**：直接利用 31x31 大卷积核构建浅层网络，单层级即可覆盖广阔视野，显著提升了对远处障碍物和整体路况的理解能力。\n- **保留高分辨率特征**：无需过度下采样即可获取全局上下文，车道线和交通标志的边缘分割更加锐利精准，米级误差大幅降低。\n- **推理效率飞跃**：结合高效的 Depthwise Conv2d 实现，在保持高精度的同时减少了参数量和计算延迟，轻松在 Orin 等嵌入式设备上达到实时帧率。\n- **部署迁移平滑**：基于纯 PyTorch 生态且提供预训练模型，团队无需重构现有管线，仅替换卷积模块即可完成升级，研发周期缩短一半。\n\nRepLKNet-pytorch 通过重塑大卷积核设计，让纯卷积网络在保持高效推理的同时，拥有了媲美 Transformer 的全局建模能力。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FDingXiaoH_RepLKNet-pytorch_c80d982d.png","DingXiaoH","Xiaohan Ding","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FDingXiaoH_fbf5f556.jpg","ML, CV, Multimodal LLM, PhD from Tsinghua University",null,"Shenzhen, China","xiaohding@gmail.com","https:\u002F\u002Fgithub.com\u002FDingXiaoH",[81],{"name":82,"color":83,"percentage":84},"Python","#3572A5",100,940,91,"2026-04-07T17:03:54","MIT",4,"Linux","必需 NVIDIA GPU。测试环境包含 V100, A100, 2080Ti。需安装对应版本的 CUDA (测试过 10.2 和 11.3) 及 cuDNN。若显存有限（如 2080Ti），训练时需添加 --use_checkpoint true 参数以节省显存。","未说明",{"notes":94,"python":95,"dependencies":96},"1. 核心依赖：需手动编译并安装基于 CUTLASS 的大核卷积扩展（depthwise_conv2d_implicit_gemm），否则无法使用高效实现。2. 编译器要求：需安装与 CUDA 版本匹配的 gcc 和 nvcc。3. 已知问题：Python 版本与 CUDA\u002FCUTLASS 不兼容会导致编译报错（如 constructor 实例冲突或类型转换错误），如遇错请尝试升级或降级 Python。4. 分布式训练：支持多机多卡训练，推荐使用 submitit 在 SLURM 集群上运行。5. 预处理差异：RepLKNet-XL 模型需使用特定的均值和标准差进行预处理（--imagenet_default_mean_and_std false）。","3.6.9 - 3.8.12 (版本不匹配可能导致编译错误，建议根据 CUDA 版本调整)",[97,98,99,100,101,102],"torch>=1.9","submitit","gcc","nvcc","cuDNN","NCCL",[15,14],"2026-03-27T02:49:30.150509","2026-04-16T03:35:37.687894",[107,112,117,122,127,132],{"id":108,"question_zh":109,"answer_zh":110,"source_url":111},34797,"如何提取 RepLKNet 的中间层特征？","如果您在尝试通过 `.children()` 分割网络并调用子模块时遇到 `NotImplementedError`，这通常是因为某些部分（如 `nn.ModuleList`）没有直接实现 `forward` 函数，或者与运行时环境（特别是 `SyncBatchNorm` 在单卡或非分布式环境下）有关。建议先尝试仅在 CPU 上运行模型以排除 CUDA 运行时问题。如果必须使用 GPU 且涉及 `SyncBatchNorm`，请确保在分布式环境中运行，或将其替换为普通的 `BatchNorm2d`。","https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fissues\u002F21",{"id":113,"question_zh":114,"answer_zh":115,"source_url":116},34798,"DepthWiseConv2dImplicitGEMM 是否支持输入通道数不等于输出通道数的情况？","不支持。`DepthWiseConv2dImplicitGEMM` 是专门为深度卷积（Depthwise Convolution）设计的，因此它强制要求 `in_channels == out_channels == groups`。如果您需要输入通道数不等于输出通道数，不能仅通过修改 Python 代码来实现，必须自定义底层的 C++\u002FCUDA 代码逻辑。","https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fissues\u002F28",{"id":118,"question_zh":119,"answer_zh":120,"source_url":121},34799,"为什么测试大卷积核算子速度时，自定义算子与 PyTorch 原生 Conv2d 速度差异不大？","这通常是因为没有正确同步 CUDA 操作导致计时不准确。在测量 GPU 耗时前，必须调用 `torch.cuda.synchronize()` 以确保所有 GPU 任务完成。正确的计时方式是在开始和结束时间点分别加入同步调用。修正后，`DepthWiseConv2dImplicitGEMM` 在大核场景下通常会比原生 `Conv2d` 快得多（例如快 7 倍以上）。","https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fissues\u002F47",{"id":123,"question_zh":124,"answer_zh":125,"source_url":126},34800,"如何可视化有效感受野（ERF），包括 Vision Transformer 模型？","可以使用项目提供的相同代码进行可视化。对于 Vision Transformer 等非 CNN 模型，您需要修改模型代码以输出最后的特征图（feature maps）。注意可能需要将 Transformer 的输出形状从 `N(HW)C` 重塑（reshape）为 `NCHW` 格式，以便与可视化代码兼容。此外，请注意未训练模型的 ERF 可视化结果可能没有实际意义，因为模型在未训练时无法做出合理预测。","https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fissues\u002F8",{"id":128,"question_zh":129,"answer_zh":130,"source_url":131},34801,"为什么移植后的 RepLKNet-31L (ImageNet-21k) 权重预测结果不正确？","这通常是由于 ImageNet-21k 数据集的版本差异导致的类别映射问题。原作者使用的预训练基于 21841 个类别（遵循 FAIR 和 Microsoft 的标准），而 Google 的 ImageNet-22k 可能包含 21843 个类别。这种类别数量的细微差别会导致分类索引错位。解决方法是检查并调整类别映射表，参考相关讨论（如 Big Transfer 仓库的 issue）来找到缺失或错位的两个类别并进行修正。","https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fissues\u002F3",{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},34802,"在哪里可以找到用于可视化 ERF 的 RepLKNet-13 预训练权重？","维护者已确认可以提供相关权重。需要注意的是，有效感受野（ERF）是随着训练过程动态扩展的。未训练模型的 ERF 可视化结果与训练好的模型会有显著差异，且在模型未训练时讨论“感受野”的实际意义有限，因为此时模型尚不具备合理的预测能力。建议使用官方提供的已训练权重进行可视化以获得符合论文描述的结果。","https:\u002F\u002Fgithub.com\u002FDingXiaoH\u002FRepLKNet-pytorch\u002Fissues\u002F15",[]]