[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-IDEA-Research--DN-DETR":3,"tool-IDEA-Research--DN-DETR":64},[4,17,26,40,48,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},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,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,2,"2026-04-03T11:11:01",[13,14,15],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":23,"last_commit_at":32,"category_tags":33,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,34,35,36,15,37,38,13,39],"数据工具","视频","插件","其他","语言模型","音频",{"id":41,"name":42,"github_repo":43,"description_zh":44,"stars":45,"difficulty_score":10,"last_commit_at":46,"category_tags":47,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,38,37],{"id":49,"name":50,"github_repo":51,"description_zh":52,"stars":53,"difficulty_score":10,"last_commit_at":54,"category_tags":55,"status":16},519,"PaddleOCR","PaddlePaddle\u002FPaddleOCR","PaddleOCR 是一款基于百度飞桨框架开发的高性能开源光学字符识别工具包。它的核心能力是将图片、PDF 等文档中的文字提取出来，转换成计算机可读取的结构化数据，让机器真正“看懂”图文内容。\n\n面对海量纸质或电子文档，PaddleOCR 解决了人工录入效率低、数字化成本高的问题。尤其在人工智能领域，它扮演着连接图像与大型语言模型（LLM）的桥梁角色，能将视觉信息直接转化为文本输入，助力智能问答、文档分析等应用场景落地。\n\nPaddleOCR 适合开发者、算法研究人员以及有文档自动化需求的普通用户。其技术优势十分明显：不仅支持全球 100 多种语言的识别，还能在 Windows、Linux、macOS 等多个系统上运行，并灵活适配 CPU、GPU、NPU 等各类硬件。作为一个轻量级且社区活跃的开源项目，PaddleOCR 既能满足快速集成的需求，也能支撑前沿的视觉语言研究，是处理文字识别任务的理想选择。",74913,"2026-04-05T10:44:17",[38,14,13,37],{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":23,"last_commit_at":62,"category_tags":63,"status":16},2471,"tesseract","tesseract-ocr\u002Ftesseract","Tesseract 是一款历史悠久且备受推崇的开源光学字符识别（OCR）引擎，最初由惠普实验室开发，后由 Google 维护，目前由全球社区共同贡献。它的核心功能是将图片中的文字转化为可编辑、可搜索的文本数据，有效解决了从扫描件、照片或 PDF 文档中提取文字信息的难题，是数字化归档和信息自动化的重要基础工具。\n\n在技术层面，Tesseract 展现了强大的适应能力。从版本 4 开始，它引入了基于长短期记忆网络（LSTM）的神经网络 OCR 引擎，显著提升了行识别的准确率；同时，为了兼顾旧有需求，它依然支持传统的字符模式识别引擎。Tesseract 原生支持 UTF-8 编码，开箱即用即可识别超过 100 种语言，并兼容 PNG、JPEG、TIFF 等多种常见图像格式。输出方面，它灵活支持纯文本、hOCR、PDF、TSV 等多种格式，方便后续数据处理。\n\nTesseract 主要面向开发者、研究人员以及需要构建文档处理流程的企业用户。由于它本身是一个命令行工具和库（libtesseract），不包含图形用户界面（GUI），因此最适合具备一定编程能力的技术人员集成到自动化脚本或应用程序中",73286,"2026-04-03T01:56:45",[13,14],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":75,"owner_avatar_url":76,"owner_bio":77,"owner_company":78,"owner_location":78,"owner_email":78,"owner_twitter":78,"owner_website":79,"owner_url":80,"languages":81,"stars":98,"forks":99,"last_commit_at":100,"license":101,"difficulty_score":102,"env_os":103,"env_gpu":104,"env_ram":105,"env_deps":106,"category_tags":113,"github_topics":114,"view_count":23,"oss_zip_url":78,"oss_zip_packed_at":78,"status":16,"created_at":117,"updated_at":118,"faqs":119,"releases":155},2265,"IDEA-Research\u002FDN-DETR","DN-DETR","[CVPR 2022 Oral] Official implementation of DN-DETR","DN-DETR 是一款专为加速目标检测模型训练而设计的开源算法，其核心成果曾入选计算机视觉顶会 CVPR 2022 的口头报告。它主要解决了经典 DETR 系列模型长期存在的训练收敛速度慢、需要极长迭代周期才能达成高性能的痛点。\n\n通过引入创新的“查询去噪”（Query DeNoising）训练机制，DN-DETR 能够在训练过程中有效区分并学习噪声信号与真实目标，从而大幅提升模型的收敛效率。这一方法不仅让基于 ResNet-50 的模型在更少的训练轮次（如 12 或 50 个 epoch）下即可取得优异的检测精度（COCO 数据集 AP 分别达 43.4 和 48.6），还具备极强的通用性。它不仅仅是一个独立的模型，更是一种可灵活插件化的训练策略，能够无缝集成到各类 DETR 变体甚至传统的 CNN 检测器（如 Faster R-CNN）及分割模型中，帮助这些模型突破性能瓶颈。\n\nDN-DETR 非常适合从事计算机视觉研究的科研人员、需要高效部署检测算法的开发者，以及希望优化现有模型训练流程的工程师使用。对于追求前沿技术落地和训练效率提升的团队而言，这是一个极具价值的技术选项。","**DN-DETR**: Accelerate DETR Training by Introducing Query DeNoising\n========\n\nBy [Feng Li*](https:\u002F\u002Ffengli-ust.github.io\u002F), [Hao Zhang*](https:\u002F\u002Fhaozhang534.github.io\u002F), [Shilong Liu](https:\u002F\u002Fscholar.google.com\u002Fcitations?hl=zh-CN&user=nkSVY3MAAAAJ), [Jian Guo](https:\u002F\u002Fidea.edu.cn\u002Fen\u002Fabout-team\u002Fjian_guo.html), [Lionel M.Ni](https:\u002F\u002Fscholar.google.com\u002Fcitations?hl=zh-CN&user=OzMYwDIAAAAJ), and [Lei Zhang](https:\u002F\u002Fscholar.google.com\u002Fcitations?hl=zh-CN&user=fIlGZToAAAAJ).\n\nThis repository is an official implementation of the [DN-DETR](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2203.01305.pdf). Accepted to **CVPR 2022** (score **112**, **Oral** presentation). Code is avaliable now.\n[[CVPR paper link](https:\u002F\u002Fopenaccess.thecvf.com\u002Fcontent\u002FCVPR2022\u002Fpapers\u002FLi_DN-DETR_Accelerate_DETR_Training_by_Introducing_Query_DeNoising_CVPR_2022_paper.pdf)] [[extended version paper link](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2203.01305.pdf)] [[中文解读](https:\u002F\u002Fwww.zhihu.com\u002Fquestion\u002F517340666\u002Fanswer\u002F2381304399)]\n\n## News\n\n\n[2022\u002F12]: We release an extended version of DN-DETR on arxiv, here is the [paper link](https:\u002F\u002Farxiv.org\u002Fabs\u002F2203.01305)! We add denoising training to CNN-based model Faster R-CNN, segmentation model Mask2Former, and other DETR-like models like Anchor DETR and DETR, to improve the performance of these models.\n\n[2022\u002F12]: Code for [Mask DINO](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FMaskDINO) is available! Mask DINO further Achieves **51.7** and **59.0** box AP on COCO with a ResNet-50 and SwinL without extra detection data, outperforming DINO under the same setting!\n\n[2022\u002F11]: DINO implementation based on DN-DETR is released in this repo. Credits to @[Vallum](https:\u002F\u002Fgithub.com\u002FVallum)! This optimized version under ResNet-50 can reach [50.8 ~ 51.0 AP](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FDN-DETR\u002Fpull\u002F45) in 36epochs.\n\n[2022\u002F9]: We release a toolbox [detrex](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002Fdetrex) that provides many state-of-the-art Transformer-based detection algorithms. It includes DN-DETR with better performance.  Welcome to use it!\n\n[2022\u002F7] Code for [DINO](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2203.03605.pdf) is available [here](https:\u002F\u002Fgithub.com\u002FIDEACVR\u002FDINO)!\n\n[2022\u002F6]: We release a unified detection and segmentation model [Mask DINO](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2206.02777.pdf) that achieves the best results on all the three segmentation tasks (**54.5** AP on [COCO instance leaderboard](https:\u002F\u002Fpaperswithcode.com\u002Fsota\u002Finstance-segmentation-on-coco-minival), **59.4** PQ on [COCO panoptic leaderboard](https:\u002F\u002Fpaperswithcode.com\u002Fsota\u002Fpanoptic-segmentation-on-coco-minival), and **60.8** mIoU on [ADE20K semantic leaderboard](https:\u002F\u002Fpaperswithcode.com\u002Fsota\u002Fsemantic-segmentation-on-ade20k))! Code will be available [here](https:\u002F\u002Fgithub.com\u002FIDEACVR\u002FMaskDINO).\n\n[2022\u002F5]Our code is available! Better performance ```49.5```AP on COCO achieved with ResNet-50.\n\n[2022\u002F4]Code is avaliable for [DAB-DETR](https:\u002F\u002Farxiv.org\u002Fabs\u002F2201.12329) [here](https:\u002F\u002Fgithub.com\u002FIDEA-opensource\u002FDAB-DETR).\n\n[2022\u002F3]We build a repo [Awesome Detection Transformer](https:\u002F\u002Fgithub.com\u002FIDEACVR\u002Fawesome-detection-transformer) to present papers about transformer for detection and segmentation. Welcome to your attention!\n\n[2022\u002F3]DN-DETR is selected for an **Oral** presentation in CVPR2022.\n\n\n[2022\u002F3]We release another work [DINO:DETR with Improved DeNoising Anchor Boxes for End-to-End Object Detection](https:\u002F\u002Farxiv.org\u002Fabs\u002F2203.03605) that for the first time establishes a DETR-like model as a SOTA model on the [leaderboard](https:\u002F\u002Fpaperswithcode.com\u002Fsota\u002Fobject-detection-on-coco). Also based on **DN**. Code will be avaliable [here](https:\u002F\u002Fgithub.com\u002FIDEACVR\u002FDINO).\n\n## Introduction\n1. We present a novel denoising training method to speedup DETR training and offer a deepened understanding of the slow convergence issue of DETR-like methods. \n2. DN is only a training method and be plugged into many DETR-like models or even traditional models to boost performance.\n3. DN-DETR achieves AP **43.4** and **48.6** with 12 and 50\nepochs of training \nwith ResNet-50 backbone. Compared with the baseline models under the same setting, DN-DETR achieves comparable performance with **50%** training epochs.\n4. Our optmized models result in better performance. DN-Deformable-DETR achieves **49.5** with a ResNet-50 backbone.\n\n\n## Model\nWe build upon DAB-DETR and add a denoising part to accelerate training convergence. It only adds minimal computation and will be removed during inference time.\n![DN-DETR](.github\u002Farchitect.png)\nWe conduct extensive experiments to validate the effectiveness of our denoising training, for example, the convergnece curve comparison. You can refer to [our paper](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2203.01305.pdf) for more experimental results.\n![DN-DETR](.github\u002Fconvergence.png)\n## Model Zoo\nWe provide our models under **DAB-DETR**, **DAB-Deformable-DETR(deformable encoder only)**, and **DAB-Deformable-DETR** (See DAB-DETR [code](https:\u002F\u002Fgithub.com\u002FIDEA-opensource\u002FDAB-DETR) and [paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2201.12329) for more details). \n\nYou can also refer to our \n\n[[model zoo in google drive]](https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1wmiZKfOg_DIGIwyQedV4rzNqUwHVTkUv?usp=sharing) \n\n[[model zoo in 百度网盘]](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F13Dc_DgliVps4bHVlNujA4Q?pwd=niet)（提取码niet）.\n\n### 50 epoch setting\n\u003Ctable>\n  \u003Cthead>\n    \u003Ctr style=\"text-align: right;\">\n      \u003Cth>\u003C\u002Fth>\n      \u003Cth>name\u003C\u002Fth>\n      \u003Cth>backbone\u003C\u002Fth>\n      \u003Cth>box AP\u003C\u002Fth>\n      \u003Cth>Log\u002FConfig\u002FCheckpoint\u003C\u002Fth>\n      \u003Cth>Where in \u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fpdf\u002F2203.01305.pdf\">Our Paper\u003C\u002Fa>\u003C\u002Fth>\n    \u003C\u002Ftr>\n  \u003C\u002Fthead>\n  \u003Ctbody>\n    \u003Ctr>\n      \u003Cth>0\u003C\u002Fth>\n      \u003Ctd>DN-DETR-R50\u003C\u002Ftd>\n      \u003Ctd>R50\u003C\u002Ftd>\n      \u003Ctd>44.4\u003Csup>\u003Ca id=\"sup3c\" herf=\"#sup1\">1\u003C\u002Fa>\u003C\u002Fsup>\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1kuwScU8PhN61qQOl5bbiPhKAYbzDHsWs?usp=sharing\">Google Drive\u003C\u002Fa>&nbsp\u002F&nbsp\u003Ca href=\"https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1TqvnjsbAjARZp1i8cB2w8A?pwd=niet\">BaiDu\u003C\u002Fa>&nbsp\u003C\u002Ftd>\n      \u003Ctd>Table 1\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n      \u003Cth>2\u003C\u002Fth>\n      \u003Ctd>DN-DETR-R50-DC5\u003C\u002Ftd>\n      \u003Ctd>R50\u003C\u002Ftd>\n      \u003Ctd>46.3\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1jr8BdDdMu8esABXdU3lNY7fpWVxAJtWa?usp=sharing\">Google Drive\u003C\u002Fa>&nbsp\u002F&nbsp\u003Ca href=\"https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1lWrLUkxNfrncRTM-zmpbeA?pwd=niet\">BaiDu\u003C\u002Fa>&nbsp;\u003C\u002Ftd>\n      \u003Ctd>Table 1\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n      \u003Cth>5\u003C\u002Fth>\n      \u003Ctd>DN-DAB-Deformbale-DETR\u003Cbr>(Deformbale Encoder Only)\u003Csup>\u003Ca id=\"sup3c\" herf=\"#sup3\">3\u003C\u002Fa>\u003C\u002Fsup>\u003C\u002Ftd>\n      \u003Ctd>R50\u003C\u002Ftd>\n      \u003Ctd>48.6\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1TLIuvMw6F9lBv77gWQ3Qcn5tdfG7kqdU?usp=sharing\">Google Drive\u003C\u002Fa>&nbsp\u002F&nbsp\u003Ca href=\"https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1emOumSadTJbCcoqxhKnllQ?pwd=niet\">BaiDu\u003C\u002Fa>&nbsp\u003C\u002Ftd>\n      \u003Ctd>Table 3\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n      \u003Cth>6\u003C\u002Fth>\n      \u003Ctd>DN-DAB-Deformable-DETR-R50-v2\u003Csup>\u003Ca id=\"sup4c\" herf=\"#sup4\">4\u003C\u002Fa>\u003C\u002Fsup>\u003C\u002Ftd>\n      \u003Ctd>R50\u003C\u002Ftd>\n      \u003Ctd>49.5 (48.4 in 24 epochs)\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1pIllR0VfSIqX8TmQy0PFNiPdp87j-78j?usp=sharing\">Google Drive\u003C\u002Fa>&nbsp\u002F&nbsp\u003Ca href=\"https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1ugoXlpr3x72qcXPKQ669sA?pwd=niet\">BaiDu\u003C\u002Fa>&nbsp\u003C\u002Ftd>\n      \u003Ctd>Optimized implementation with deformable attention in both encoder and decoder. See \u003Ca href=\"https:\u002F\u002Fgithub.com\u002FIDEA-opensource\u002FDAB-DETR\">DAB-DETR\u003C\u002Fa> for more details.\u003C\u002Ftd>\n    \u003C\u002Ftr>\n  \u003C\u002Ftbody>\n\u003C\u002Ftable>\n\n### 12 epoch setting\n\u003Ctable>\n  \u003Cthead>\n    \u003Ctr style=\"text-align: right;\">\n      \u003Cth>\u003C\u002Fth>\n      \u003Cth>name\u003C\u002Fth>\n      \u003Cth>backbone\u003C\u002Fth>\n      \u003Cth>box AP\u003C\u002Fth>\n      \u003Cth>Log\u002FConfig\u002FCheckpoint\u003C\u002Fth>\n      \u003Cth>Where in \u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fpdf\u002F2203.01305.pdf\">Our Paper\u003C\u002Fa>\u003C\u002Fth>\n    \u003C\u002Ftr>\n  \u003C\u002Fthead>\n  \u003Ctbody>\n    \u003Ctr>\n      \u003Cth>1\u003C\u002Fth>\n      \u003Ctd>DN-DAB-DETR-R50-DC5(3 pat)\u003Csup>\u003Ca id=\"sup2c\" herf=\"#sup1\">2\u003C\u002Fa>\u003C\u002Fsup>\u003C\u002Ftd>\n      \u003Ctd>R50\u003C\u002Ftd>\n      \u003Ctd>41.7\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1jWSIWTWgoiIvyA7w2xIkdk-B1pS2atPA?usp=sharing\">Google Drive\u003C\u002Fa>&nbsp\u002F&nbsp\u003Ca href=\"https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1fgCIGpMf0cgO6ToIb0xFuA?pwd=niet\">BaiDu\u003C\u002Fa>&nbsp\u003C\u002Ftd>\n      \u003Ctd>Table 2\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n      \u003Cth>4\u003C\u002Fth>\n      \u003Ctd>DN-DAB-DETR-R101-DC5(3 pat)\u003Csup>\u003Ca id=\"sup2c\" herf=\"#sup1\">2\u003C\u002Fa>\u003C\u002Fsup>\u003C\u002Ftd>\n      \u003Ctd>R101\u003C\u002Ftd>\n      \u003Ctd>42.8\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1elPn06gs8mNxR3jtE53zi4cK5qLGH0AV?usp=sharing\">Google Drive\u003C\u002Fa>&nbsp\u002F&nbsp\u003Ca href=\"https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1fgCIGpMf0cgO6ToIb0xFuA?pwd=niet\">BaiDu\u003C\u002Fa>&nbsp\u003C\u002Ftd>\n      \u003Ctd>Table 2\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n      \u003Cth>5\u003C\u002Fth>\n      \u003Ctd>DN-DAB-Deformbale-DETR\u003Cbr>(Deformble Encoder Only)\u003Csup>\u003Ca id=\"sup3c\" herf=\"#sup3\">3\u003C\u002Fa>\u003C\u002Fsup>\u003C\u002Ftd>\n      \u003Ctd>R50\u003C\u002Ftd>\n      \u003Ctd>43.4\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1T-qiHrvDF38PyqLhMU3QFC_n-ZkVgMJh?usp=sharing\">Google Drive\u003C\u002Fa>&nbsp\u002F&nbsp\u003Ca href=\"https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1XygS_bjhe8Gg9tFhs9Z6uQ?pwd=niet\">BaiDu\u003C\u002Fa>&nbsp\u003C\u002Ftd>\n      \u003Ctd>Table 2\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n      \u003Cth>5\u003C\u002Fth>\n      \u003Ctd>DN-DAB-Deformbale-DETR\u003Cbr>(Deformble Encoder Only)\u003Csup>\u003Ca id=\"sup3c\" herf=\"#sup3\">3\u003C\u002Fa>\u003C\u002Fsup>\u003C\u002Ftd>\n      \u003Ctd>R101\u003C\u002Ftd>\n      \u003Ctd>44.1\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1V8CH7AMf9HGUYNNgEYaGK_2g2T2LNNWD?usp=sharing\">Google Drive\u003C\u002Fa>&nbsp\u002F&nbsp\u003Ca href=\"https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1Q_C7FMXAlyPcWkIhbf5M6g?pwd=niet\">BaiDu\u003C\u002Fa>&nbsp\u003C\u002Ftd>\n      \u003Ctd>Table 2\u003C\u002Ftd>\n    \u003C\u002Ftr>\n  \u003C\u002Ftbody>\n\u003C\u002Ftable>\n\nNotes: \n- \u003Csup>\u003Ca id=\"sup1\" herf=\"#sup1c\">1\u003C\u002Fa>\u003C\u002Fsup>: The result increases compared with the reported one in our paper (from ```44.1```to ```44.4```) since we optimized the code. We did not rerun other models, so\n  \u003Cfont color=red>**you are expected to get better performance than reported ones in our paper**.\u003C\u002Ffont>\n- \u003Csup>\u003Ca id=\"sup2\" herf=\"#sup2c\">2\u003C\u002Fa>\u003C\u002Fsup>: The models with marks (3 pat) are trained with multiple pattern embeds (refer to Anchor DETR or [DAB-DETR](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2203.01305.pdf) for more details.).\n- \u003Csup>\u003Ca id=\"sup3\" herf=\"#sup3c\">3\u003C\u002Fa>\u003C\u002Fsup>: This model is based on DAB-Deformbale-DETR(Deformbale Encoder Only), which is a multiscale version of DAB-DETR. It requires 16 GPUs to train as it only use deformable attention in the encoder. \n- \u003Csup>\u003Ca id=\"sup4\" herf=\"#sup4c\">4\u003C\u002Fa>\u003C\u002Fsup>: This model is based on DAB-Deformbale-DETR which is an optimized implementation with deformable DETR. See \u003Ca href=\"https:\u002F\u002Fgithub.com\u002FIDEA-opensource\u002FDAB-DETR\">DAB-DETR\u003C\u002Fa> for more details. \n  \u003Cfont color=red>**You are encouraged to use this\ndeformable version**\u003C\u002Ffont> as it uses deformable attention in both encoder and deocder, which is more lightweight (i.e, train with 4\u002F8 A100 GPUs) and converges faster (i.e, achieves ```48.4``` in 24 epochs, comparable to the 50-epoch DAB-Deformable-DETR).\n\n# Usage\n## How to use denoising training in your own model\nOur code largely follows DAB-DETR and adds additional components for denoising training, which are warped in a file [dn_components.py](models\u002FDAB_DETR\u002Fdn_components.py). There are mainly 3 functions including **prepare_for_dn**, **dn_post_proces** (the first two are used in your detection forward function to process the dn part), and **compute_dn_loss**(this one is used to calculate dn loss). You can import these functions and add them to your own detection model.\nYou may also compare DN-DETR and DAB-DETR to see how these functions are added if you would like to use it in your own detection models.\n\nYou are also encouraged to apply it to some other DETR-like models or even traditional detection models and update results\nin this repo.\n\n\n## Installation\nWe use the DAB-DETR project as our codebase, hence no extra dependency is needed for our **DN-DETR**. For the **DN-Deformable-DETR**, you need to compile the deformable attention operator manually.\n\nWe test our models under ```python=3.7.3,pytorch=1.9.0,cuda=11.1```. Other versions might be available as well.\n\n1. Clone this repo\n```sh\ngit clone https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FDN-DETR.git\ncd DN-DETR\n```\n\n2. Install Pytorch and torchvision\n\nFollow the instruction on https:\u002F\u002Fpytorch.org\u002Fget-started\u002Flocally\u002F.\n```sh\n# an example:\nconda install -c pytorch pytorch torchvision\n```\n\n3. Install other needed packages\n```sh\npip install -r requirements.txt\n```\n\n4. Compiling CUDA operators\n```sh\ncd models\u002Fdn_dab_deformable_detr\u002Fops\npython setup.py build install\n# unit test (should see all checking is True)\npython test.py\ncd ..\u002F..\u002F..\n```\n\n## Data\nPlease download [COCO 2017](https:\u002F\u002Fcocodataset.org\u002F) dataset and organize them as following:\n```\nCOCODIR\u002F\n  ├── train2017\u002F\n  ├── val2017\u002F\n  └── annotations\u002F\n  \t├── instances_train2017.json\n  \t└── instances_val2017.json\n```\n\n\n## Run\nWe use the standard **DN-DETR-R50** and **DN-Deformable-DETR-R50** as examples for training and evalulation.\n\n### Eval our pretrianed models\n\nDownload our DN-DETR-R50 model checkpoint from [this link](https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1kuwScU8PhN61qQOl5bbiPhKAYbzDHsWs?usp=sharing) and perform the command below. \nYou can expect to get the final AP about ```44.4```.\n\nFor our DN-DAB-Deformable-DETR_Deformable_Encoder_Only ([download here](https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1TLIuvMw6F9lBv77gWQ3Qcn5tdfG7kqdU?usp=sharing)). The final AP expected is ```48.6```.\n\nFor our DN-DAB-Deformable-DETR ([download here](https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1pIllR0VfSIqX8TmQy0PFNiPdp87j-78j?usp=sharing)), the final AP expected is ```49.5```.\n\n```sh\n# for dn_detr: 44.1 AP; optimized result is 44.4AP\npython main.py -m dn_dab_detr \\\n  --output_dir logs\u002Fdn_DABDETR\u002FR50 \\\n  --batch_size 1 \\\n  --coco_path \u002Fpath\u002Fto\u002Fyour\u002FCOCODIR \\ # replace the args to your COCO path\n  --resume \u002Fpath\u002Fto\u002Four\u002Fcheckpoint \\ # replace the args to your checkpoint path\n  --use_dn \\\n  --eval\n\n# for dn_deformable_detr: 49.5 AP\npython main.py -m dn_deformable_detr \\\n  --output_dir logs\u002Fdab_deformable_detr\u002FR50 \\\n  --batch_size 1 \\\n  --coco_path \u002Fpath\u002Fto\u002Fyour\u002FCOCODIR \\ # replace the args to your COCO path\n  --resume \u002Fpath\u002Fto\u002Four\u002Fcheckpoint \\ # replace the args to your checkpoint path\n  --transformer_activation relu \\\n  --use_dn \\\n  --eval\n  \n# for dn_deformable_detr_deformable_encoder_only: 48.6 AP\npython main.py -m dn_dab_deformable_detr_deformable_encoder_only \n  --output_dir logs\u002Fdab_deformable_detr\u002FR50 \\\n  --batch_size 1 \\\n  --coco_path \u002Fpath\u002Fto\u002Fyour\u002FCOCODIR \\ # replace the args to your COCO path\n  --resume \u002Fpath\u002Fto\u002Four\u002Fcheckpoint \\ # replace the args to your checkpoint path\n  --transformer_activation relu \\\n  --num_patterns 3 \\  # use 3 pattern embeddings\n  --use_dn  \\\n  --eval\n```\n\n\n### Training your own models\nSimilarly, you can also train our model on a single process: \n```sh\n# for dn_detr\npython main.py -m dn_dab_detr \\\n  --output_dir logs\u002Fdn_DABDETR\u002FR50 \\\n  --batch_size 1 \\\n  --epochs 50 \\\n  --lr_drop 40 \\\n  --coco_path \u002Fpath\u002Fto\u002Fyour\u002FCOCODIR  # replace the args to your COCO path\n  --use_dn\n```\n\n\n### Distributed Run\nHowever, as the training is time consuming, we suggest to train the model on multi-device.\n\nIf you plan to train the models on a cluster with Slurm, here is an example command for training:\n```sh\n# for dn_detr: 44.4 AP\npython run_with_submitit.py \\\n  --timeout 3000 \\\n  --job_name DNDETR \\\n  --coco_path \u002Fpath\u002Fto\u002Fyour\u002FCOCODIR \\\n  -m dn_dab_detr \\\n  --job_dir logs\u002Fdn_DABDETR\u002FR50_%j \\\n  --batch_size 2 \\\n  --ngpus 8 \\\n  --nodes 1 \\\n  --epochs 50 \\\n  --lr_drop 40 \\\n  --use_dn\n\n# for dn_dab_deformable_detr: 49.5 AP\npython run_with_submitit.py \\\n  --timeout 3000 \\\n  --job_name dn_dab_deformable_detr \\\n  --coco_path \u002Fpath\u002Fto\u002Fyour\u002FCOCODIR \\\n  -m dab_deformable_detr \\\n  --transformer_activation relu \\\n  --job_dir logs\u002Fdn_dab_deformable_detr\u002FR50_%j \\\n  --batch_size 2 \\\n  --ngpus 8 \\\n  --nodes 1 \\\n  --epochs 50 \\\n  --lr_drop 40 \\\n  --use_dn\n\n# for dn_dab_deformable_detr_deformable_encoder_only: 48.6 AP\npython run_with_submitit.py \\\n  --timeout 3000 \\\n  --job_name dn_dab_deformable_detr_deformable_encoder_only \\\n  --coco_path \u002Fpath\u002Fto\u002Fyour\u002FCOCODIR \\\n  -m dn_dab_deformable_detr_deformable_encoder_only \\\n  --transformer_activation relu \\\n  --job_dir logs\u002Fdn_dab_deformable_detr\u002FR50_%j \\\n  --num_patterns 3 \\ \n  --batch_size 1 \\\n  --ngpus 8 \\\n  --nodes 2 \\\n  --epochs 50 \\\n  --lr_drop 40 \\\n  --use_dn\n```\nIf you want to train our DC reversion or mulitple-patterns version, add \n```sh\n--dilation  # for DC version\n\n--num_patterns 3  # for 3 patterns\n```\nHowever, this requires additional training resources and memory, i.e, use 16 GPUs.\n\nThe final AP should be similar or better to ours, as our optimized result is better than our reported\nperformance in the paper( for example, we report ```44.1``` for **DN-DETR**, but our new result can achieve ```44.4```. \nDon't be surprised if you get better result! ). \n\nOur training setting is same as DAB-DETR but add a argument ```--use_dn```, you may also refer to\n [DAB-DETR](https:\u002F\u002Fgithub.com\u002FIDEA-opensource\u002FDAB-DETR) as well. \n\nNotes: \n  - The results are sensitive to the batch size. We use 16(2 images each GPU x 8 GPUs) by default.\n\n\nOr run with multi-processes on a single node:\n```sh\n# for dn_dab_detr: 44.4 AP\npython -m torch.distributed.launch --nproc_per_node=8 \\\n  main.py -m dn_dab_detr \\\n  --output_dir logs\u002Fdn_DABDETR\u002FR50 \\\n  --batch_size 2 \\\n  --epochs 50 \\\n  --lr_drop 40 \\\n  --coco_path \u002Fpath\u002Fto\u002Fyour\u002FCOCODIR \\\n  --use_dn\n\n# for dn_deformable_detr: 49.5 AP\npython -m torch.distributed.launch --nproc_per_node=8 \\\n  main.py -m dn_dab_deformable_detr \\\n  --output_dir logs\u002Fdn_dab_deformable_detr\u002FR50 \\\n  --batch_size 2 \\\n  --epochs 50 \\\n  --lr_drop 40 \\\n  --transformer_activation relu \\\n  --coco_path \u002Fpath\u002Fto\u002Fyour\u002FCOCODIR \\\n  --use_dn\n```\n\n\n## Links\nOur work is based on **DAB-DETR**. We also release another [SOAT](https:\u002F\u002Fpaperswithcode.com\u002Fsota\u002Fobject-detection-on-coco) detection model **DINO** based on DN-DETR and DAB-DETR.   \n- **DINO: DETR with Improved DeNoising Anchor Boxes for End-to-End Object Detection**.     \nHao Zhang*, Feng Li*, Shilong Liu*, Lei Zhang, Hang Su, Jun Zhu, Lionel M. Ni, Heung-Yeung Shum.  \narxiv 2022.   \n[[paper]](https:\u002F\u002Farxiv.org\u002Fabs\u002F2203.03605) [[code]](https:\u002F\u002Fgithub.com\u002FIDEACVR\u002FDINO).  \n\n- **DAB-DETR: Dynamic Anchor Boxes are Better Queries for DETR**.  \nShilong Liu, Feng Li, Hao Zhang, Xiao Yang, Xianbiao Qi, Hang Su, Jun Zhu, Lei Zhang.    \nInternational Conference on Learning Representations (ICLR) 2022.  \n[[Paper]](https:\u002F\u002Farxiv.org\u002Fabs\u002F2201.12329) [[Code]](https:\u002F\u002Fgithub.com\u002FSlongLiu\u002FDAB-DETR).     \n\n## LICNESE\nDN-DETR is released under the Apache 2.0 license. Please see the [LICENSE](LICNESE) file for more information.\n\nCopyright (c) IDEA. All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use these files except in compliance with the License. You may obtain a copy of the License at http:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n\n## Bibtex\nIf you find our work helpful for your research, please consider citing the following BibTeX entry.   \n```\n@inproceedings{li2022dn,\n  title={Dn-detr: Accelerate detr training by introducing query denoising},\n  author={Li, Feng and Zhang, Hao and Liu, Shilong and Guo, Jian and Ni, Lionel M and Zhang, Lei},\n  booktitle={Proceedings of the IEEE\u002FCVF Conference on Computer Vision and Pattern Recognition},\n  pages={13619--13627},\n  year={2022}\n}\n```\n","**DN-DETR**: 通过引入查询去噪加速 DETR 训练\n========\n\n作者：[Feng Li*](https:\u002F\u002Ffengli-ust.github.io\u002F)、[Hao Zhang*](https:\u002F\u002Fhaozhang534.github.io\u002F)、[Shilong Liu](https:\u002F\u002Fscholar.google.com\u002Fcitations?hl=zh-CN&user=nkSVY3MAAAAJ)、[Jian Guo](https:\u002F\u002Fidea.edu.cn\u002Fen\u002Fabout-team\u002Fjian_guo.html)、[Lionel M.Ni](https:\u002F\u002Fscholar.google.com\u002Fcitations?hl=zh-CN&user=OzMYwDIAAAAJ) 和 [Lei Zhang](https:\u002F\u002Fscholar.google.com\u002Fcitations?hl=zh-CN&user=fIlGZToAAAAJ)。\n\n本仓库是 [DN-DETR](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2203.01305.pdf) 的官方实现。该工作已被 **CVPR 2022** 接收（评分 **112**，**口头报告**）。代码现已公开。\n[[CVPR 论文链接](https:\u002F\u002Fopenaccess.thecvf.com\u002Fcontent\u002FCVPR2022\u002Fpapers\u002FLi_DN-DETR_Accelerate_DETR_Training_by_Introducing_Query_DeNoising_CVPR_2022_paper.pdf)] [[扩展版论文链接](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2203.01305.pdf)] [[中文解读](https:\u002F\u002Fwww.zhihu.com\u002Fquestion\u002F517340666\u002Fanswer\u002F2381304399)]\n\n## 最新消息\n\n\n[2022\u002F12]: 我们在 arXiv 上发布了 DN-DETR 的扩展版本，论文链接为 [这里](https:\u002F\u002Farxiv.org\u002Fabs\u002F2203.01305)! 我们将去噪训练方法应用于基于 CNN 的 Faster R-CNN 模型、分割模型 Mask2Former，以及 Anchor DETR 和 DETR 等其他 DETR 类模型，以提升这些模型的性能。\n\n[2022\u002F12]: [Mask DINO](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FMaskDINO) 的代码已开源！Mask DINO 在 COCO 数据集上使用 ResNet-50 和 SwinL 骨干，在不使用额外检测数据的情况下，分别取得了 **51.7** 和 **59.0** 的边界框 AP，超越了相同设置下的 DINO！\n\n[2022\u002F11]: 基于 DN-DETR 的 DINO 实现已在本仓库发布。特别感谢 @[Vallum](https:\u002F\u002Fgithub.com\u002FVallum)! 该优化版本在 ResNet-50 骨干下，仅需 36 个 epoch 即可达到 [50.8 ~ 51.0 AP](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FDN-DETR\u002Fpull\u002F45)。\n\n[2022\u002F9]: 我们发布了一个工具箱 [detrex](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002Fdetrex)，其中包含多种最先进的基于 Transformer 的目标检测算法。该工具箱包括性能更优的 DN-DETR。欢迎使用！\n\n[2022\u002F7] [DINO](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2203.03605.pdf) 的代码已在此处开放：[DINO](https:\u002F\u002Fgithub.com\u002FIDEACVR\u002FDINO)!\n\n[2022\u002F6]: 我们发布了一种统一的目标检测与分割模型 [Mask DINO](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2206.02777.pdf)，在三大分割任务中均取得了最佳成绩（在 [COCO 实例分割排行榜](https:\u002F\u002Fpaperswithcode.com\u002Fsota\u002Finstance-segmentation-on-coco-minival) 上获得 **54.5** AP，在 [COCO 全景分割排行榜](https:\u002F\u002Fpaperswithcode.com\u002Fsota\u002Fpanoptic-segmentation-on-coco-minival) 上获得 **59.4** PQ，在 [ADE20K 语义分割排行榜](https:\u002F\u002Fpaperswithcode.com\u002Fsota\u002Fsemantic-segmentation-on-ade20k) 上获得 **60.8** mIoU）! 代码将在此处开放：[Mask DINO](https:\u002F\u002Fgithub.com\u002FIDEACVR\u002FMaskDINO)。\n\n[2022\u002F5]我们的代码现已公开！使用 ResNet-50 骨干，在 COCO 数据集上实现了更好的性能，AP 达到 **49.5**。\n\n[2022\u002F4] [DAB-DETR](https:\u002F\u002Farxiv.org\u002Fabs\u002F2201.12329) 的代码已在此处开放：[DAB-DETR](https:\u002F\u002Fgithub.com\u002FIDEA-opensource\u002FDAB-DETR)。\n\n[2022\u002F3]我们创建了一个仓库 [Awesome Detection Transformer](https:\u002F\u002Fgithub.com\u002FIDEACVR\u002Fawesome-detection-transformer)，用于整理和展示关于目标检测与分割领域 Transformer 相关的论文。欢迎大家关注！\n\n[2022\u002F3]DN-DETR 被选为 CVPR 2022 的 **口头报告**。\n\n[2022\u002F3]我们还发布了另一项工作 [DINO:DETR with Improved DeNoising Anchor Boxes for End-to-End Object Detection](https:\u002F\u002Farxiv.org\u002Fabs\u002F2203.03605)，首次将一种 DETR 类模型确立为 [COCO 数据集目标检测排行榜](https:\u002F\u002Fpaperswithcode.com\u002Fsota\u002Fobject-detection-on-coco) 上的 SOTA 模型。该模型同样基于 **DN** 技术。代码将在此处开放：[DINO](https:\u002F\u002Fgithub.com\u002FIDEACVR\u002FDINO)。\n\n## 简介\n1. 我们提出了一种新颖的去噪训练方法，用于加速 DETR 的训练，并深入理解了 DETR 类方法收敛缓慢的问题。\n2. DN 只是一种训练方法，可以轻松集成到多种 DETR 类模型，甚至传统模型中，以提升其性能。\n3. DN-DETR 使用 ResNet-50 骨干，在分别经过 12 和 50 个训练 epoch 后，分别达到了 **43.4** 和 **48.6** 的 AP。与相同设置下的基线模型相比，DN-DETR 仅用 **50%** 的训练时间就达到了相当的性能。\n4. 经过优化后的模型表现更佳。DN-Deformable-DETR 使用 ResNet-50 骨干时，AP 可达 **49.5**。\n\n## 模型\n我们在 DAB-DETR 的基础上增加了去噪模块，以加速训练收敛。该模块仅引入少量计算开销，并且在推理阶段会被移除。\n![DN-DETR](.github\u002Farchitect.png)\n我们进行了大量实验来验证去噪训练的有效性，例如收敛曲线的对比。更多实验结果请参阅 [我们的论文](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2203.01305.pdf)。\n![DN-DETR](.github\u002Fconvergence.png)\n## 模型库\n我们提供了以下模型：**DAB-DETR**、**DAB-Deformable-DETR（仅可变形编码器）** 和 **DAB-Deformable-DETR**（有关详细信息，请参阅 DAB-DETR 的 [代码](https:\u002F\u002Fgithub.com\u002FIDEA-opensource\u002FDAB-DETR) 和 [论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2201.12329)）。\n\n您也可以参考我们的\n\n[[Google Drive 模型库]](https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1wmiZKfOg_DIGIwyQedV4rzNqUwHVTkUv?usp=sharing)\n\n[[百度网盘模型库]](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F13Dc_DgliVps4bHVlNujA4Q?pwd=niet)（提取码：niet）。\n\n### 50轮次设置\n\u003Ctable>\n  \u003Cthead>\n    \u003Ctr style=\"text-align: right;\">\n      \u003Cth>\u003C\u002Fth>\n      \u003Cth>名称\u003C\u002Fth>\n      \u003Cth>骨干网络\u003C\u002Fth>\n      \u003Cth>边界框AP\u003C\u002Fth>\n      \u003Cth>日志\u002F配置\u002F检查点\u003C\u002Fth>\n      \u003Cth>在\u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fpdf\u002F2203.01305.pdf\">我们的论文\u003C\u002Fa>中的位置\u003C\u002Fth>\n    \u003C\u002Ftr>\n  \u003C\u002Fthead>\n  \u003Ctbody>\n    \u003Ctr>\n      \u003Cth>0\u003C\u002Fth>\n      \u003Ctd>DN-DETR-R50\u003C\u002Ftd>\n      \u003Ctd>R50\u003C\u002Ftd>\n      \u003Ctd>44.4\u003Csup>\u003Ca id=\"sup3c\" herf=\"#sup1\">1\u003C\u002Fa>\u003C\u002Fsup>\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1kuwScU8PhN61qQOl5bbiPhKAYbzDHsWs?usp=sharing\">Google云端硬盘\u003C\u002Fa>&nbsp\u002F&nbsp\u003Ca href=\"https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1TqvnjsbAjARZp1i8cB2w8A?pwd=niet\">百度网盘\u003C\u002Fa>&nbsp\u003C\u002Ftd>\n      \u003Ctd>表1\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n      \u003Cth>2\u003C\u002Fth>\n      \u003Ctd>DN-DETR-R50-DC5\u003C\u002Ftd>\n      \u003Ctd>R50\u003C\u002Ftd>\n      \u003Ctd>46.3\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1jr8BdDdMu8esABXdU3lNY7fpWVxAJtWa?usp=sharing\">Google云端硬盘\u003C\u002Fa>&nbsp\u002F&nbsp\u003Ca href=\"https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1lWrLUkxNfrncRTM-zmpbeA?pwd=niet\">百度网盘\u003C\u002Fa>&nbsp;\u003C\u002Ftd>\n      \u003Ctd>表1\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n      \u003Cth>5\u003C\u002Fth>\n      \u003Ctd>DN-DAB-可变形DETR\u003Cbr>(仅可变形编码器)\u003Csup>\u003Ca id=\"sup3c\" herf=\"#sup3\">3\u003C\u002Fa>\u003C\u002Fsup>\u003C\u002Ftd>\n      \u003Ctd>R50\u003C\u002Ftd>\n      \u003Ctd>48.6\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1TLIuvMw6F9lBv77gWQ3Qcn5tdfG7kqdU?usp=sharing\">Google云端硬盘\u003C\u002Fa>&nbsp\u002F&nbsp\u003Ca href=\"https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1emOumSadTJbCcoqxhKnllQ?pwd=niet\">百度网盘\u003C\u002Fa>&nbsp\u003C\u002Ftd>\n      \u003Ctd>表3\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n      \u003Cth>6\u003C\u002Fth>\n      \u003Ctd>DN-DAB-可变形DETR-R50-v2\u003Csup>\u003Ca id=\"sup4c\" herf=\"#sup4\">4\u003C\u002Fa>\u003C\u002Fsup>\u003C\u002Ftd>\n      \u003Ctd>R50\u003C\u002Ftd>\n      \u003Ctd>49.5（24轮次时为48.4）\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1pIllR0VfSIqX8TmQy0PFNiPdp87j-78j?usp=sharing\">Google云端硬盘\u003C\u002Fa>&nbsp\u002F&nbsp\u003Ca href=\"https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1ugoXlpr3x72qcXPKQ669sA?pwd=niet\">百度网盘\u003C\u002Fa>&nbsp\u003C\u002Ftd>\n      \u003Ctd>优化后的实现，在编码器和解码器中均使用可变形注意力。更多详情请参见\u003Ca href=\"https:\u002F\u002Fgithub.com\u002FIDEA-opensource\u002FDAB-DETR\">DAB-DETR\u003C\u002Fa>。\u003C\u002Ftd>\n    \u003C\u002Ftr>\n  \u003C\u002Ftbody>\n\u003C\u002Ftable>\n\n### 12轮次设置\n\u003Ctable>\n  \u003Cthead>\n    \u003Ctr style=\"text-align: right;\">\n      \u003Cth>\u003C\u002Fth>\n      \u003Cth>名称\u003C\u002Fth>\n      \u003Cth>骨干网络\u003C\u002Fth>\n      \u003Cth>边界框AP\u003C\u002Fth>\n      \u003Cth>日志\u002F配置\u002F检查点\u003C\u002Fth>\n      \u003Cth>在\u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fpdf\u002F2203.01305.pdf\">我们的论文\u003C\u002Fa>中的位置\u003C\u002Fth>\n    \u003C\u002Ftr>\n  \u003C\u002Fthead>\n  \u003Ctbody>\n    \u003Ctr>\n      \u003Cth>1\u003C\u002Fth>\n      \u003Ctd>DN-DAB-DETR-R50-DC5(3 pat)\u003Csup>\u003Ca id=\"sup2c\" herf=\"#sup1\">2\u003C\u002Fa>\u003C\u002Fsup>\u003C\u002Ftd>\n      \u003Ctd>R50\u003C\u002Ftd>\n      \u003Ctd>41.7\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1jWSIWTWgoiIvyA7w2xIkdk-B1pS2atPA?usp=sharing\">Google云端硬盘\u003C\u002Fa>&nbsp\u002F&nbsp\u003Ca href=\"https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1fgCIGpMf0cgO6ToIb0xFuA?pwd=niet\">百度网盘\u003C\u002Fa>&nbsp\u003C\u002Ftd>\n      \u003Ctd>表2\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n      \u003Cth>4\u003C\u002Fth>\n      \u003Ctd>DN-DAB-DETR-R101-DC5(3 pat)\u003Csup>\u003Ca id=\"sup2c\" herf=\"#sup1\">2\u003C\u002Fa>\u003C\u002Fsup>\u003C\u002Ftd>\n      \u003Ctd>R101\u003C\u002Ftd>\n      \u003Ctd>42.8\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1elPn06gs8mNxR3jtE53zi4cK5qLGH0AV?usp=sharing\">Google云端硬盘\u003C\u002Fa>&nbsp\u002F&nbsp\u003Ca href=\"https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1fgCIGpMf0cgO6ToIb0xFuA?pwd=niet\">百度网盘\u003C\u002Fa>&nbsp\u003C\u002Ftd>\n      \u003Ctd>表2\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n      \u003Cth>5\u003C\u002Fth>\n      \u003Ctd>DN-DAB-可变形DETR\u003Cbr>(仅可变形编码器)\u003Csup>\u003Ca id=\"sup3c\" herf=\"#sup3\">3\u003C\u002Fa>\u003C\u002Fsup>\u003C\u002Ftd>\n      \u003Ctd>R50\u003C\u002Ftd>\n      \u003Ctd>43.4\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1T-qiHrvDF38PyqLhMU3QFC_n-ZkVgMJh?usp=sharing\">Google云端硬盘\u003C\u002Fa>&nbsp\u002F&nbsp\u003Ca href=\"https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1XygS_bjhe8Gg9tFhs9Z6uQ?pwd=niet\">百度网盘\u003C\u002Fa>&nbsp\u003C\u002Ftd>\n      \u003Ctd>表2\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n      \u003Cth>5\u003C\u002Fth>\n      \u003Ctd>DN-DAB-可变形DETR\u003Cbr>(仅可变形编码器)\u003Csup>\u003Ca id=\"sup3c\" herf=\"#sup3\">3\u003C\u002Fa>\u003C\u002Fsup>\u003C\u002Ftd>\n      \u003Ctd>R101\u003C\u002Ftd>\n      \u003Ctd>44.1\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1V8CH7AMf9HGUYNNgEYaGK_2g2T2LNNWD?usp=sharing\">Google云端硬盘\u003C\u002Fa>&nbsp\u002F&nbsp\u003Ca href=\"https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1Q_C7FMXAlyPcWkIhbf5M6g?pwd=niet\">百度网盘\u003C\u002Fa>&nbsp\u003C\u002Ftd>\n      \u003Ctd>表2\u003C\u002Ftd>\n    \u003C\u002Ftr>\n  \u003C\u002Ftbody>\n\u003C\u002Ftable>\n\n注释：\n- \u003Csup>\u003Ca id=\"sup1\" herf=\"#sup1c\">1\u003C\u002Fa>\u003C\u002Fsup>：相较于我们论文中报告的结果（从```44.1```提升至```44.4```），这一结果有所提高，因为我们对代码进行了优化。我们并未重新运行其他模型，因此\n  \u003Cfont color=red>**预计您将获得比我们论文中报告的更好的性能**。\u003C\u002Ffont>\n- \u003Csup>\u003Ca id=\"sup2\" herf=\"#sup2c\">2\u003C\u002Fa>\u003C\u002Fsup>：带有标记（3 pat）的模型使用了多模式嵌入进行训练（详情请参考Anchor DETR或[DAB-DETR](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2203.01305.pdf)）。\n- \u003Csup>\u003Ca id=\"sup3\" herf=\"#sup3c\">3\u003C\u002Fa>\u003C\u002Fsup>：该模型基于DAB-可变形DETR（仅可变形编码器），这是DAB-DETR的多尺度版本。由于仅在编码器中使用可变形注意力，因此需要16张GPU卡进行训练。\n- \u003Csup>\u003Ca id=\"sup4\" herf=\"#sup4c\">4\u003C\u002Fa>\u003C\u002Fsup>：该模型基于DAB-可变形DETR，这是一个使用可变形DETR的优化实现。更多详情请参见\u003Ca href=\"https:\u002F\u002Fgithub.com\u002FIDEA-opensource\u002FDAB-DETR\">DAB-DETR\u003C\u002Fa>。\n  \u003Cfont color=red>**建议您使用这个可变形版本**\u003C\u002Ffont>，因为它在编码器和解码器中都使用可变形注意力，更加轻量级（即可以用4\u002F8张A100 GPU进行训练），并且收敛速度更快（即在24轮次内达到```48.4```，与50轮次的DAB-可变形DETR相当）。\n\n# 使用方法\n## 如何在您自己的模型中使用去噪训练\n我们的代码主要遵循DAB-DETR，并添加了用于去噪训练的额外组件，这些组件被封装在一个文件[dn_components.py](models\u002FDAB_DETR\u002Fdn_components.py)中。主要有3个函数，包括**prepare_for_dn**、**dn_post_proces**（前两个函数用于您的检测前向传播中处理去噪部分），以及**compute_dn_loss**（用于计算去噪损失）。您可以导入这些函数并将其添加到您自己的检测模型中。\n如果您希望在自己的检测模型中使用这些功能，也可以对比DN-DETR和DAB-DETR，了解这些函数是如何被加入的。\n\n我们也鼓励您将其应用于其他类似DETR的模型，甚至传统的检测模型，并在此仓库中更新结果。\n\n## 安装\n我们以DAB-DETR项目作为我们的代码库，因此对于**DN-DETR**无需额外依赖。而对于**DN-可变形DETR**，您需要手动编译可变形注意力算子。\n\n我们是在```python=3.7.3, pytorch=1.9.0, cuda=11.1```的环境下测试了我们的模型。其他版本也可能适用。\n\n1. 克隆本仓库\n```sh\ngit clone https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FDN-DETR.git\ncd DN-DETR\n```\n\n2. 安装PyTorch和 torchvision\n\n请按照https:\u002F\u002Fpytorch.org\u002Fget-started\u002Flocally\u002F上的说明进行操作。\n```sh\n# 示例：\nconda install -c pytorch pytorch torchvision\n```\n\n3. 安装其他所需软件包\n```sh\npip install -r requirements.txt\n```\n\n4. 编译CUDA算子\n```sh\ncd models\u002Fdn_dab_deformable_detr\u002Fops\npython setup.py build install\n\n# 单元测试（应看到所有检查均为 True）\npython test.py\ncd ..\u002F..\u002F..\n```\n\n## 数据\n请下载 [COCO 2017](https:\u002F\u002Fcocodataset.org\u002F) 数据集，并按以下方式组织：\n```\nCOCODIR\u002F\n  ├── train2017\u002F\n  ├── val2017\u002F\n  └── annotations\u002F\n  \t├── instances_train2017.json\n  \t└── instances_val2017.json\n```\n\n\n## 运行\n我们以标准的 **DN-DETR-R50** 和 **DN-Deformable-DETR-R50** 为例进行训练和评估。\n\n### 评估我们的预训练模型\n\n从 [此链接](https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1kuwScU8PhN61qQOl5bbiPhKAYbzDHsWs?usp=sharing) 下载我们的 DN-DETR-R50 模型检查点，并执行以下命令。您预计最终的 AP 约为 ```44.4```。\n\n对于我们的 DN-DAB-Deformable-DETR_Deformable_Encoder_Only（[在此下载](https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1TLIuvMw6F9lBv77gWQ3Qcn5tdfG7kqdU?usp=sharing)），预期的最终 AP 为 ```48.6```。\n\n对于我们的 DN-DAB-Deformable-DETR（[在此下载](https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1pIllR0VfSIqX8TmQy0PFNiPdp87j-78j?usp=sharing)），预期的最终 AP 为 ```49.5```。\n\n```sh\n# 对于 dn_detr：44.1 AP；优化后的结果为 44.4 AP\npython main.py -m dn_dab_detr \\\n  --output_dir logs\u002Fdn_DABDETR\u002FR50 \\\n  --batch_size 1 \\\n  --coco_path \u002Fpath\u002Fto\u002Fyour\u002FCOCODIR \\ # 将参数替换为您的 COCO 数据集路径\n  --resume \u002Fpath\u002Fto\u002Four\u002Fcheckpoint \\ # 将参数替换为您的检查点路径\n  --use_dn \\\n  --eval\n\n# 对于 dn_deformable_detr：49.5 AP\npython main.py -m dn_deformable_detr \\\n  --output_dir logs\u002Fdab_deformable_detr\u002FR50 \\\n  --batch_size 1 \\\n  --coco_path \u002Fpath\u002Fto\u002Fyour\u002FCOCODIR \\ # 将参数替换为您的 COCO 数据集路径\n  --resume \u002Fpath\u002Fto\u002Four\u002Fcheckpoint \\ # 将参数替换为您的检查点路径\n  --transformer_activation relu \\\n  --use_dn \\\n  --eval\n  \n# 对于 dn_deformable_detr_deformable_encoder_only：48.6 AP\npython main.py -m dn_dab_deformable_detr_deformable_encoder_only \n  --output_dir logs\u002Fdab_deformable_detr\u002FR50 \\\n  --batch_size 1 \\\n  --coco_path \u002Fpath\u002Fto\u002Fyour\u002FCOCODIR \\ # 将参数替换为您的 COCO 数据集路径\n  --resume \u002Fpath\u002Fto\u002Four\u002Fcheckpoint \\ # 将参数替换为您的检查点路径\n  --transformer_activation relu \\\n  --num_patterns 3 \\  # 使用 3 个模式嵌入\n  --use_dn  \\\n  --eval\n```\n\n\n### 训练您自己的模型\n同样，您也可以在单进程上训练我们的模型：\n```sh\n# 对于 dn_detr\npython main.py -m dn_dab_detr \\\n  --output_dir logs\u002Fdn_DABDETR\u002FR50 \\\n  --batch_size 1 \\\n  --epochs 50 \\\n  --lr_drop 40 \\\n  --coco_path \u002Fpath\u002Fto\u002Fyour\u002FCOCODIR  # 将参数替换为您的 COCO 数据集路径\n  --use_dn\n```\n\n\n### 分布式运行\n然而，由于训练耗时较长，我们建议在多设备上进行训练。\n\n如果您计划在使用 Slurm 的集群上训练模型，以下是训练示例命令：\n```sh\n# 对于 dn_detr：44.4 AP\npython run_with_submitit.py \\\n  --timeout 3000 \\\n  --job_name DNDETR \\\n  --coco_path \u002Fpath\u002Fto\u002Fyour\u002FCOCODIR \\\n  -m dn_dab_detr \\\n  --job_dir logs\u002Fdn_DABDETR\u002FR50_%j \\\n  --batch_size 2 \\\n  --ngpus 8 \\\n  --nodes 1 \\\n  --epochs 50 \\\n  --lr_drop 40 \\\n  --use_dn\n\n# 对于 dn_dab_deformable_detr：49.5 AP\npython run_with_submitit.py \\\n  --timeout 3000 \\\n  --job_name dn_dab_deformable_detr \\\n  --coco_path \u002Fpath\u002Fto\u002Fyour\u002FCOCODIR \\\n  -m dab_deformable_detr \\\n  --transformer_activation relu \\\n  --job_dir logs\u002Fdn_dab_deformable_detr\u002FR50_%j \\\n  --batch_size 2 \\\n  --ngpus 8 \\\n  --nodes 1 \\\n  --epochs 50 \\\n  --lr_drop 40 \\\n  --use_dn\n\n# 对于 dn_dab_deformable_detr_deformable_encoder_only：48.6 AP\npython run_with_submitit.py \\\n  --timeout 3000 \\\n  --job_name dn_dab_deformable_detr_deformable_encoder_only \\\n  --coco_path \u002Fpath\u002Fto\u002Fyour\u002FCOCODIR \\\n  -m dn_dab_deformable_detr_deformable_encoder_only \\\n  --transformer_activation relu \\\n  --job_dir logs\u002Fdn_dab_deformable_detr\u002FR50_%j \\\n  --num_patterns 3 \\ \n  --batch_size 1 \\\n  --ngpus 8 \\\n  --nodes 2 \\\n  --epochs 50 \\\n  --lr_drop 40 \\\n  --use_dn\n```\n如果您想训练我们的 DC 版本或多模式版本，请添加：\n```sh\n--dilation  # 对于 DC 版本\n\n--num_patterns 3  # 对于 3 种模式\n```\n不过，这需要额外的训练资源和内存，即使用 16 个 GPU。\n\n最终的 AP 应该与我们的结果相似或更好，因为我们的优化结果优于论文中报告的性能（例如，我们报告 **DN-DETR** 的 AP 为 ```44.1```，但新的结果可以达到 ```44.4```）。如果您得到更好的结果也不必惊讶！\n\n我们的训练设置与 DAB-DETR 相同，只是增加了一个参数 ```--use_dn```。您也可以参考 [DAB-DETR](https:\u002F\u002Fgithub.com\u002FIDEA-opensource\u002FDAB-DETR)。\n\n注意：\n  - 结果对批次大小较为敏感。我们默认使用 16（每张 GPU 2 张图像 × 8 张 GPU）。\n\n或者在单节点上使用多进程运行：\n```sh\n# 对于 dn_dab_detr：44.4 AP\npython -m torch.distributed.launch --nproc_per_node=8 \\\n  main.py -m dn_dab_detr \\\n  --output_dir logs\u002Fdn_DABDETR\u002FR50 \\\n  --batch_size 2 \\\n  --epochs 50 \\\n  --lr_drop 40 \\\n  --coco_path \u002Fpath\u002Fto\u002Fyour\u002FCOCODIR \\\n  --use_dn\n\n# 对于 dn_deformable_detr：49.5 AP\npython -m torch.distributed.launch --nproc_per_node=8 \\\n  main.py -m dn_dab_deformable_detr \\\n  --output_dir logs\u002Fdn_dab_deformable_detr\u002FR50 \\\n  --batch_size 2 \\\n  --epochs 50 \\\n  --lr_drop 40 \\\n  --transformer_activation relu \\\n  --coco_path \u002Fpath\u002Fto\u002Fyour\u002FCOCODIR \\\n  --use_dn\n```\n\n\n## 链接\n我们的工作基于 **DAB-DETR**。我们还发布了另一个基于 DN-DETR 和 DAB-DETR 的 [SOAT](https:\u002F\u002Fpaperswithcode.com\u002Fsota\u002Fobject-detection-on-coco) 检测模型 **DINO**。\n- **DINO：带有改进去噪锚框的 DETR，用于端到端目标检测**。\nHao Zhang*, Feng Li*, Shilong Liu*, Lei Zhang, Hang Su, Jun Zhu, Lionel M. Ni, Heung-Yeung Shum。\narxiv 2022。\n[[论文]](https:\u002F\u002Farxiv.org\u002Fabs\u002F2203.03605) [[代码]](https:\u002F\u002Fgithub.com\u002FIDEACVR\u002FDINO)。\n\n- **DAB-DETR：动态锚框是 DETR 更好的查询**。\nShilong Liu, Feng Li, Hao Zhang, Xiao Yang, Xianbiao Qi, Hang Su, Jun Zhu, Lei Zhang。\n国际表征学习会议 (ICLR) 2022。\n[[论文]](https:\u002F\u002Farxiv.org\u002Fabs\u002F2201.12329) [[代码]](https:\u002F\u002Fgithub.com\u002FSlongLiu\u002FDAB-DETR)。\n\n## 许可证\nDN-DETR 采用 Apache 2.0 许可证发布。更多信息请参阅 [LICENSE](LICNESE) 文件。\n\n版权所有 © IDEA。保留所有权利。\n\n根据 Apache 许可证第 2.0 版（“许可证”）授权。除非符合许可证规定，否则不得使用这些文件。您可以在 http:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0 获取许可证副本。\n\n除非适用法律要求或书面协议另有约定，否则根据许可证分发的软件以“AS IS”的基础提供，不附带任何类型的保证或条件，无论是明示的还是暗示的。有关特定语言的权限和限制，请参阅许可证。\n\n## Bibtex\n如果您认为我们的工作对您的研究有所帮助，请考虑引用以下 BibTeX 条目。\n```\n@inproceedings{li2022dn,\n  title={Dn-DETR：通过引入查询去噪加速 DETR 训练},\n  author={李峰和张浩和刘世龙和郭健和倪利昂和张磊},\n  booktitle={IEEE\u002FCVF 计算机视觉与模式识别会议论文集},\n  pages={13619--13627},\n  year={2022}\n}\n```","# DN-DETR 快速上手指南\n\nDN-DETR 是一种通过引入查询去噪（Query DeNoising）机制来加速 DETR 训练的创新方法。该方法仅需在训练阶段添加少量计算，推理时自动移除，可显著缩短收敛时间并提升检测性能（如在 COCO 数据集上仅用 50% 的训练轮次即可达到基线模型相当的效果）。\n\n## 环境准备\n\n在开始之前，请确保您的开发环境满足以下要求：\n\n*   **操作系统**: Linux (推荐 Ubuntu)\n*   **Python**: 3.7.3 (其他版本可能兼容，但已测试此版本)\n*   **PyTorch**: 1.9.0\n*   **CUDA**: 11.1\n*   **硬件**: \n    *   基础模型：单卡或多卡 GPU 均可。\n    *   多尺度变形模型 (Deformable Encoder Only)：建议配备 16 张 GPU。\n    *   优化版变形模型 (Encoder & Decoder)：建议使用 4 或 8 张 A100 GPU。\n\n> **注意**：如果您计划使用 **DN-Deformable-DETR** 系列模型，需要手动编译 deformable attention 算子。基础 DN-DETR 无需额外依赖。\n\n## 安装步骤\n\n### 1. 克隆代码仓库\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FDN-DETR.git\ncd DN-DETR\n```\n\n### 2. 安装 PyTorch 和 TorchVision\n请访问 [PyTorch 官网](https:\u002F\u002Fpytorch.org\u002Fget-started\u002Flocally\u002F) 获取适合您环境的安装命令。以下是基于 CUDA 11.1 的示例：\n\n```bash\npip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 -f https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Ftorch_stable.html\n```\n\n### 3. 安装其他依赖\n进入项目目录并安装 requirements：\n```bash\npip install -r requirements.txt\n```\n\n### 4. 编译 Deformable Attention 算子 (仅针对变形模型)\n如果您需要使用 `DN-DAB-Deformable-DETR` 模型，必须编译自定义算子：\n\n```bash\ncd models\u002FDAB_DETR\u002Fops\npython setup.py build install\ncd ..\u002F..\u002F..\u002F\n```\n\n## 基本使用\n\n### 模型推理与测试\n本项目基于 DAB-DETR 构建。您可以直接下载预训练权重进行评测。\n\n**下载预训练模型：**\n*   **Google Drive**: [模型库链接](https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1wmiZKfOg_DIGIwyQedV4rzNqUwHVTkUv?usp=sharing)\n*   **百度网盘**: [模型库链接](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F13Dc_DgliVps4bHVlNujA4Q?pwd=niet) (提取码: `niet`)\n\n**运行评估脚本：**\n以 ResNet-50 骨干网络的 50 epoch 模型为例：\n```bash\npython main.py \\\n  --output_dir .\u002Flogs\u002Fdn_detr_r50 \\\n  --config_file configs\u002Fdn_detr_r50.yaml \\\n  --eval \\\n  --resume path\u002Fto\u002Fcheckpoint.pth\n```\n*(注：具体配置文件名和参数请参考 `configs\u002F` 目录下的实际文件)*\n\n### 将去噪训练应用到您的模型\nDN-DETR 的核心逻辑封装在 `models\u002FDAB_DETR\u002Fdn_components.py` 文件中。若要在自己的检测模型中集成此功能，主要涉及以下三个函数：\n\n1.  **`prepare_for_dn`**: 在检测前向传播中准备去噪数据。\n2.  **`dn_post_process`**: 处理去噪部分的输出。\n3.  **`compute_dn_loss`**: 计算去噪损失。\n\n**集成示例思路：**\n您可以在自己的模型 forward 函数中导入并调用这些组件：\n\n```python\nfrom models.DAB_DETR.dn_components import prepare_for_dn, dn_post_process, compute_dn_loss\n\n# 1. 准备去噪输入\ndn_meta, known_labels, known_boxes = prepare_for_dn(targets, ...)\n\n# 2. 在模型前向传播中使用 dn_meta 生成带噪声的查询\n\n# 3. 计算损失时加入 dn loss\nloss_dict = criterion(outputs, targets)\nloss_dn = compute_dn_loss(...)\nfinal_loss = sum(loss_dict.values()) + loss_dn\n```\n\n建议参考本仓库中 `DN-DETR` 与 `DAB-DETR` 的代码差异，以了解具体的插入位置和调用方式。\n\n### 推荐模型选择\n*   **追求轻量与快速收敛**：推荐使用 **DN-DAB-Deformable-DETR-R50-v2**。该版本在 Encoder 和 Decoder 中均使用了 deformable attention，仅需 24 个 epoch 即可达到 48.4 AP，且显存占用更优（支持 4\u002F8 卡训练）。\n*   **复现论文基准**：可选择表格中对应的 R50 或 R101  backbone 模型。","某自动驾驶初创公司的算法团队正致力于提升车载摄像头对行人和车辆的实时检测精度，计划将原有的 DETR 模型部署到新一代感知系统中。\n\n### 没有 DN-DETR 时\n- **训练周期漫长**：原始 DETR 模型收敛极慢，通常需要训练 500 个 epoch 才能达到可用精度，导致单次实验迭代耗时数周，严重拖慢研发节奏。\n- **超参数调优困难**：模型对二分图匹配过程中的噪声极其敏感，开发人员需花费大量时间手动调整学习率和匹配策略，仍难以稳定复现论文效果。\n- **小目标漏检率高**：在复杂城市场景下，模型难以快速学习到细微特征，导致远距离行人或小型车辆的召回率低下，存在安全隐患。\n- **算力资源浪费**：漫长的训练过程占用了公司宝贵的 GPU 集群资源，使得团队无法并行开展更多新架构的探索实验。\n\n### 使用 DN-DETR 后\n- **训练效率飞跃**：引入查询去噪（Query DeNoising）机制后，模型在仅需 50 个 epoch 内即可超越原始 DETR 训练 500 轮的精度，实验迭代速度提升近 10 倍。\n- **训练过程稳定**：去噪训练任务为模型提供了明确的监督信号，显著降低了对超参数的敏感度，团队无需反复试错即可轻松复现高性能模型。\n- **检测性能增强**：得益于更快的收敛速度和更优的特征学习，模型在小目标检测上的 AP 值显著提升，有效减少了复杂路况下的漏检情况。\n- **资源成本降低**：训练时长的大幅缩短释放了 90% 的 GPU 算力，让团队有余力同时尝试多传感器融合等更前沿的算法方案。\n\nDN-DETR 通过创新的去噪训练机制，彻底解决了 Transformer 检测模型收敛慢的痛点，将原本以月计的研发周期压缩至天级，极大加速了自动驾驶感知系统的落地进程。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FIDEA-Research_DN-DETR_d19447e2.png","IDEA-Research","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FIDEA-Research_b8b3359e.png","The International Digital Economy Academy (“IDEA”). ",null,"www.idea.edu.cn","https:\u002F\u002Fgithub.com\u002FIDEA-Research",[82,86,90,94],{"name":83,"color":84,"percentage":85},"Python","#3572A5",78.6,{"name":87,"color":88,"percentage":89},"Cuda","#3A4E3A",19.2,{"name":91,"color":92,"percentage":93},"C++","#f34b7d",1.9,{"name":95,"color":96,"percentage":97},"Shell","#89e051",0.3,604,71,"2026-03-20T02:37:08","Apache-2.0",4,"Linux","需要 NVIDIA GPU，具体显存未说明。基础模型需较少资源，部分多尺度变形注意力模型（Deformable Encoder Only）训练需 16 张 GPU；优化版变形模型可用 4\u002F8 张 A100 GPU。CUDA 版本测试为 11.1。","未说明",{"notes":107,"python":108,"dependencies":109},"代码基于 DAB-DETR 项目，基础版无需额外依赖。若使用 DN-Deformable-DETR 版本，需手动编译 deformable attention 算子。官方测试环境为 Python 3.7.3, PyTorch 1.9.0, CUDA 11.1，其他版本可能可用但未保证。建议使用优化后的变形版本（同时在编码器和解码器中使用变形注意力），因其更轻量且收敛更快。","3.7.3",[110,111,112],"torch==1.9.0","torchvision","deformable attention operator (需手动编译)",[14],[115,116],"object-detection","detr","2026-03-27T02:49:30.150509","2026-04-06T07:11:49.947987",[120,125,130,135,140,145,150],{"id":121,"question_zh":122,"answer_zh":123,"source_url":124},10399,"如何实现可视化或进行预测？","可以复制输入数据并使用 main.py 中的 dataloader 进行预测。具体代码逻辑如下：遍历验证集数据加载器，处理图像路径字符串，将图像和目标（targets）压缩维度并移动到设备（device）上。示例代码片段：\nfor image, targets, path in data_loader_val:\n    path_s = str(path).replace(\"('\\'\",\"\").replace(\"\\',)\",\"\")\n    image = torch.squeeze(image, 0)\n    image_gpu = image.to(device)\n    for t in targets:\n        targets[t] = torch.squeeze(targets[t], 0)\n    targets = [{t: to_device(targets[t], device) for t in targets}]","https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FDN-DETR\u002Fissues\u002F20",{"id":126,"question_zh":127,"answer_zh":128,"source_url":129},10400,"类别标签嵌入（class label embedding）是如何实现的？","并不是将 one-hot 向量通过 MLP 获取特征向量。实现方式是添加了一个新的线性层（linear layer）来嵌入类别标签。","https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FDN-DETR\u002Fissues\u002F3",{"id":131,"question_zh":132,"answer_zh":133,"source_url":134},10401,"如何区分去噪部分（denoising part）和匹配部分（matching part）的查询？指示符（indicator）的作用是什么？","在注意力掩码（attention mask）中，去噪部分仍然可以看到匹配部分，因此需要指示符来区分这两者。虽然注意力掩码可以防止信息泄露，但实验表明添加指示符能带来轻微的性能提升。实现上通常是将标量指示符（0 或 1）拼接到标签嵌入的末尾。","https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FDN-DETR\u002Fissues\u002F10",{"id":136,"question_zh":137,"answer_zh":138,"source_url":139},10402,"为什么 class_embed 使用 91 类而 label_enc 使用 92 类？不同变体中对 tgt 的处理为何不同？","这取决于具体的模型变体：\n1. DAB-DETR 使用全零向量作为初始内容查询嵌入，因此直接将其嵌入为背景类别以区别于去噪（dn）部分。\n2. Deformable DAB-DETR 使用可学习的内容查询嵌入（包含从数据集学到的信息），因此将指示符与 tgt 拼接（cat）以保留原始内容信息。\n这两种方式主要用于区分 dn 部分和原始匹配部分，对整体性能影响不显著。","https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FDN-DETR\u002Fissues\u002F23",{"id":141,"question_zh":142,"answer_zh":143,"source_url":144},10403,"代码何时发布？","维护者表示将在 NIPS 会议后的 6 月初发布代码。","https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FDN-DETR\u002Fissues\u002F7",{"id":146,"question_zh":147,"answer_zh":148,"source_url":149},10404,"如何计算 DN-DETR 模型的 FLOPs？","DN-DETR 的 GFLOPs 与 DAB-DETR 相同。由于评估模式（eval mode）下不需要 dn_components 组件，您可以直接使用 DAB-DETR 的脚本来计算 GFLOPs。","https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FDN-DETR\u002Fissues\u002F44",{"id":151,"question_zh":152,"answer_zh":153,"source_url":154},10405,"已知标签检测（Known Labels Detection）是如何实现的？","其核心思想是利用特定类别 c 的标签嵌入，让解码器仅输出该类别的所有框。具体实现涉及在匹配部分用类别 c 的标签嵌入替换所有未知类别的嵌入。推理次数通常对应于图像中的类别数量。","https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FDN-DETR\u002Fissues\u002F5",[]]