[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-Tianxiaomo--pytorch-YOLOv4":3,"tool-Tianxiaomo--pytorch-YOLOv4":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 真正成长为懂上",140436,2,"2026-04-05T23:32:43",[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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":10,"last_commit_at":50,"category_tags":51,"status":17},4292,"Deep-Live-Cam","hacksider\u002FDeep-Live-Cam","Deep-Live-Cam 是一款专注于实时换脸与视频生成的开源工具，用户仅需一张静态照片，即可通过“一键操作”实现摄像头画面的即时变脸或制作深度伪造视频。它有效解决了传统换脸技术流程繁琐、对硬件配置要求极高以及难以实时预览的痛点，让高质量的数字内容创作变得触手可及。\n\n这款工具不仅适合开发者和技术研究人员探索算法边界，更因其极简的操作逻辑（仅需三步：选脸、选摄像头、启动），广泛适用于普通用户、内容创作者、设计师及直播主播。无论是为了动画角色定制、服装展示模特替换，还是制作趣味短视频和直播互动，Deep-Live-Cam 都能提供流畅的支持。\n\n其核心技术亮点在于强大的实时处理能力，支持口型遮罩（Mouth Mask）以保留使用者原始的嘴部动作，确保表情自然精准；同时具备“人脸映射”功能，可同时对画面中的多个主体应用不同面孔。此外，项目内置了严格的内容安全过滤机制，自动拦截涉及裸露、暴力等不当素材，并倡导用户在获得授权及明确标注的前提下合规使用，体现了技术发展与伦理责任的平衡。",88924,"2026-04-06T03:28:53",[14,15,13,52],"视频",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":32,"last_commit_at":59,"category_tags":60,"status":17},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[14,35],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":67,"readme_en":68,"readme_zh":69,"quickstart_zh":70,"use_case_zh":71,"hero_image_url":72,"owner_login":73,"owner_name":74,"owner_avatar_url":75,"owner_bio":76,"owner_company":77,"owner_location":78,"owner_email":74,"owner_twitter":74,"owner_website":79,"owner_url":80,"languages":81,"stars":98,"forks":99,"last_commit_at":100,"license":101,"difficulty_score":10,"env_os":102,"env_gpu":103,"env_ram":102,"env_deps":104,"category_tags":112,"github_topics":113,"view_count":32,"oss_zip_url":74,"oss_zip_packed_at":74,"status":17,"created_at":123,"updated_at":124,"faqs":125,"releases":156},4273,"Tianxiaomo\u002Fpytorch-YOLOv4","pytorch-YOLOv4","PyTorch ,ONNX and TensorRT implementation of YOLOv4","pytorch-YOLOv4 是一个基于 PyTorch 框架实现的 YOLOv4 目标检测开源项目，旨在让开发者能够轻松地在 PyTorch 生态中复现和应用这一高性能检测算法。它解决了原始 YOLOv4 主要依赖 Darknet 框架、导致 PyTorch 用户难以直接训练和部署的问题，打通了从模型训练到推理的完整流程。\n\n该项目不仅支持标准的模型推理与训练功能，还特别集成了 Mosaic 数据增强技术以提升小目标检测效果。其独特的技术亮点在于提供了完善的模型转换工具链，支持将训练好的 PyTorch 模型无缝导出为 ONNX 格式，并进一步转换为 TensorRT 引擎，从而在保持高精度的同时显著提升推理速度，满足实时性要求。\n\npytorch-YOLOv4 非常适合计算机视觉领域的研究人员、算法工程师以及深度学习开发者使用。无论是希望复现论文结果的科研人员，还是需要将目标检测功能集成到实际产品中的开发人员，都能通过该项目快速上手。项目结构清晰，提供了从数据标注处理、模型训练权重下载到摄像头实时演示的完整示例代码，降低了 YOLOv4 的使用门槛，是进行高效目标检测开发与研究的得","pytorch-YOLOv4 是一个基于 PyTorch 框架实现的 YOLOv4 目标检测开源项目，旨在让开发者能够轻松地在 PyTorch 生态中复现和应用这一高性能检测算法。它解决了原始 YOLOv4 主要依赖 Darknet 框架、导致 PyTorch 用户难以直接训练和部署的问题，打通了从模型训练到推理的完整流程。\n\n该项目不仅支持标准的模型推理与训练功能，还特别集成了 Mosaic 数据增强技术以提升小目标检测效果。其独特的技术亮点在于提供了完善的模型转换工具链，支持将训练好的 PyTorch 模型无缝导出为 ONNX 格式，并进一步转换为 TensorRT 引擎，从而在保持高精度的同时显著提升推理速度，满足实时性要求。\n\npytorch-YOLOv4 非常适合计算机视觉领域的研究人员、算法工程师以及深度学习开发者使用。无论是希望复现论文结果的科研人员，还是需要将目标检测功能集成到实际产品中的开发人员，都能通过该项目快速上手。项目结构清晰，提供了从数据标注处理、模型训练权重下载到摄像头实时演示的完整示例代码，降低了 YOLOv4 的使用门槛，是进行高效目标检测开发与研究的得力助手。","# Pytorch-YOLOv4\n\n![](https:\u002F\u002Fimg.shields.io\u002Fstatic\u002Fv1?label=python&message=3.6|3.7&color=blue)\n![](https:\u002F\u002Fimg.shields.io\u002Fstatic\u002Fv1?label=pytorch&message=1.4&color=\u003CCOLOR>)\n[![](https:\u002F\u002Fimg.shields.io\u002Fstatic\u002Fv1?label=license&message=Apache2&color=green)](.\u002FLicense.txt)\n\nA minimal PyTorch implementation of YOLOv4.\n- Paper Yolo v4: https:\u002F\u002Farxiv.org\u002Fabs\u002F2004.10934\n- Source code:https:\u002F\u002Fgithub.com\u002FAlexeyAB\u002Fdarknet\n- More details: http:\u002F\u002Fpjreddie.com\u002Fdarknet\u002Fyolo\u002F\n\n\n- [x] Inference\n- [x] Train\n    - [x] Mosaic\n\n```\n├── README.md\n├── dataset.py            dataset\n├── demo.py               demo to run pytorch --> tool\u002Fdarknet2pytorch\n├── demo_darknet2onnx.py  tool to convert into onnx --> tool\u002Fdarknet2pytorch\n├── demo_pytorch2onnx.py  tool to convert into onnx\n├── models.py             model for pytorch\n├── train.py              train models.py\n├── cfg.py                cfg.py for train\n├── cfg                   cfg --> darknet2pytorch\n├── data            \n├── weight                --> darknet2pytorch\n├── tool\n│   ├── camera.py           a demo camera\n│   ├── coco_annotation.py       coco dataset generator\n│   ├── config.py\n│   ├── darknet2pytorch.py\n│   ├── region_loss.py\n│   ├── utils.py\n│   └── yolo_layer.py\n```\n\n![image](https:\u002F\u002Fuser-gold-cdn.xitu.io\u002F2020\u002F4\u002F26\u002F171b5a6c8b3bd513?w=768&h=576&f=jpeg&s=78882)\n\n# 0. Weights Download\n\n## 0.1 darknet\n- baidu(https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1dAGEW8cm-dqK14TbhhVetA     Extraction code:dm5b)\n- google(https:\u002F\u002Fdrive.google.com\u002Fopen?id=1cewMfusmPjYWbrnuJRuKhPMwRe_b9PaT)\n\n## 0.2 pytorch\nyou can use darknet2pytorch to convert it yourself, or download my converted model.\n\n- baidu\n    - yolov4.pth(https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1ZroDvoGScDgtE1ja_QqJVw Extraction code:xrq9) \n    - yolov4.conv.137.pth(https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1ovBie4YyVQQoUrC3AY0joA Extraction code:kcel)\n- google\n    - yolov4.pth(https:\u002F\u002Fdrive.google.com\u002Fopen?id=1wv_LiFeCRYwtpkqREPeI13-gPELBDwuJ)\n    - yolov4.conv.137.pth(https:\u002F\u002Fdrive.google.com\u002Fopen?id=1fcbR0bWzYfIEdLJPzOsn4R5mlvR6IQyA)\n\n# 1. Train\n\n[use yolov4 to train your own data](Use_yolov4_to_train_your_own_data.md)\n\n1. Download weight\n2. Transform data\n\n    For coco dataset,you can use tool\u002Fcoco_annotation.py.\n    ```\n    # train.txt\n    image_path1 x1,y1,x2,y2,id x1,y1,x2,y2,id x1,y1,x2,y2,id ...\n    image_path2 x1,y1,x2,y2,id x1,y1,x2,y2,id x1,y1,x2,y2,id ...\n    ...\n    ...\n    ```\n3. Train\n\n    you can set parameters in cfg.py.\n    ```\n     python train.py -g [GPU_ID] -dir [Dataset direction] ...\n    ```\n\n# 2. Inference\n\n## 2.1 Performance on MS COCO dataset (using pretrained DarknetWeights from \u003Chttps:\u002F\u002Fgithub.com\u002FAlexeyAB\u002Fdarknet>)\n\n**ONNX and TensorRT models are converted from Pytorch (TianXiaomo): Pytorch->ONNX->TensorRT.**\nSee following sections for more details of conversions.\n\n- val2017 dataset (input size: 416x416)\n\n| Model type          | AP          | AP50        | AP75        |  APS        | APM         | APL         |\n| ------------------- | ----------: | ----------: | ----------: | ----------: | ----------: | ----------: |\n| DarkNet (YOLOv4 paper)|     0.471 |       0.710 |       0.510 |       0.278 |       0.525 |       0.636 |\n| Pytorch (TianXiaomo)|       0.466 |       0.704 |       0.505 |       0.267 |       0.524 |       0.629 |\n| TensorRT FP32 + BatchedNMSPlugin | 0.472| 0.708 |       0.511 |       0.273 |       0.530 |       0.637 |\n| TensorRT FP16 + BatchedNMSPlugin | 0.472| 0.708 |       0.511 |       0.273 |       0.530 |       0.636 |\n\n- testdev2017 dataset (input size: 416x416)\n\n| Model type          | AP          | AP50        | AP75        |  APS        | APM         | APL         |\n| ------------------- | ----------: | ----------: | ----------: | ----------: | ----------: | ----------: |\n| DarkNet (YOLOv4 paper)|     0.412 |       0.628 |       0.443 |       0.204 |       0.444 |       0.560 |\n| Pytorch (TianXiaomo)|       0.404 |       0.615 |       0.436 |       0.196 |       0.438 |       0.552 |\n| TensorRT FP32 + BatchedNMSPlugin | 0.412| 0.625 |       0.445 |       0.200 |       0.446 |       0.564 |\n| TensorRT FP16 + BatchedNMSPlugin | 0.412| 0.625 |       0.445 |       0.200 |       0.446 |       0.563 |\n\n\n## 2.2 Image input size for inference\n\nImage input size is NOT restricted in `320 * 320`, `416 * 416`, `512 * 512` and `608 * 608`.\nYou can adjust your input sizes for a different input ratio, for example: `320 * 608`.\nLarger input size could help detect smaller targets, but may be slower and GPU memory exhausting.\n\n```py\nheight = 320 + 96 * n, n in {0, 1, 2, 3, ...}\nwidth  = 320 + 96 * m, m in {0, 1, 2, 3, ...}\n```\n\n## 2.3 **Different inference options**\n\n- Load the pretrained darknet model and darknet weights to do the inference (image size is configured in cfg file already)\n\n    ```sh\n    python demo.py -cfgfile \u003CcfgFile> -weightfile \u003CweightFile> -imgfile \u003CimgFile>\n    ```\n\n- Load pytorch weights (pth file) to do the inference\n\n    ```sh\n    python models.py \u003Cnum_classes> \u003Cweightfile> \u003Cimgfile> \u003CIN_IMAGE_H> \u003CIN_IMAGE_W> \u003Cnamefile(optional)>\n    ```\n    \n- Load converted ONNX file to do inference (See section 3 and 4)\n\n- Load converted TensorRT engine file to do inference (See section 5)\n\n## 2.4 Inference output\n\nThere are 2 inference outputs.\n- One is locations of bounding boxes, its shape is  `[batch, num_boxes, 1, 4]` which represents x1, y1, x2, y2 of each bounding box.\n- The other one is scores of bounding boxes which is of shape `[batch, num_boxes, num_classes]` indicating scores of all classes for each bounding box.\n\nUntil now, still a small piece of post-processing including NMS is required. We are trying to minimize time and complexity of post-processing.\n\n\n# 3. Darknet2ONNX\n\n- **This script is to convert the official pretrained darknet model into ONNX**\n\n- **Pytorch version Recommended:**\n\n    - Pytorch 1.4.0 for TensorRT 7.0 and higher\n    - Pytorch 1.5.0 and 1.6.0 for TensorRT 7.1.2 and higher\n\n- **Install onnxruntime**\n\n    ```sh\n    pip install onnxruntime\n    ```\n\n- **Run python script to generate ONNX model and run the demo**\n\n    ```sh\n    python demo_darknet2onnx.py \u003CcfgFile> \u003CnamesFile> \u003CweightFile> \u003CimageFile> \u003CbatchSize>\n    ```\n\n## 3.1 Dynamic or static batch size\n\n- **Positive batch size will generate ONNX model of static batch size, otherwise, batch size will be dynamic**\n    - Dynamic batch size will generate only one ONNX model\n    - Static batch size will generate 2 ONNX models, one is for running the demo (batch_size=1)\n\n# 4. Pytorch2ONNX\n\n- **You can convert your trained pytorch model into ONNX using this script**\n\n- **Pytorch version Recommended:**\n\n    - Pytorch 1.4.0 for TensorRT 7.0 and higher\n    - Pytorch 1.5.0 and 1.6.0 for TensorRT 7.1.2 and higher\n\n- **Install onnxruntime**\n\n    ```sh\n    pip install onnxruntime\n    ```\n\n- **Run python script to generate ONNX model and run the demo**\n\n    ```sh\n    python demo_pytorch2onnx.py \u003Cweight_file> \u003Cimage_path> \u003Cbatch_size> \u003Cn_classes> \u003CIN_IMAGE_H> \u003CIN_IMAGE_W>\n    ```\n\n    For example:\n\n    ```sh\n    python demo_pytorch2onnx.py yolov4.pth dog.jpg 8 80 416 416\n    ```\n\n## 4.1 Dynamic or static batch size\n\n- **Positive batch size will generate ONNX model of static batch size, otherwise, batch size will be dynamic**\n    - Dynamic batch size will generate only one ONNX model\n    - Static batch size will generate 2 ONNX models, one is for running the demo (batch_size=1)\n\n\n# 5. ONNX2TensorRT\n\n- **TensorRT version Recommended: 7.0, 7.1**\n\n## 5.1 Convert from ONNX of static Batch size\n\n- **Run the following command to convert YOLOv4 ONNX model into TensorRT engine**\n\n    ```sh\n    trtexec --onnx=\u003Connx_file> --explicitBatch --saveEngine=\u003CtensorRT_engine_file> --workspace=\u003Csize_in_megabytes> --fp16\n    ```\n    - Note: If you want to use int8 mode in conversion, extra int8 calibration is needed.\n\n## 5.2 Convert from ONNX of dynamic Batch size\n\n- **Run the following command to convert YOLOv4 ONNX model into TensorRT engine**\n\n    ```sh\n    trtexec --onnx=\u003Connx_file> \\\n    --minShapes=input:\u003Cshape_of_min_batch> --optShapes=input:\u003Cshape_of_opt_batch> --maxShapes=input:\u003Cshape_of_max_batch> \\\n    --workspace=\u003Csize_in_megabytes> --saveEngine=\u003Cengine_file> --fp16\n    ```\n- For example:\n\n    ```sh\n    trtexec --onnx=yolov4_-1_3_320_512_dynamic.onnx \\\n    --minShapes=input:1x3x320x512 --optShapes=input:4x3x320x512 --maxShapes=input:8x3x320x512 \\\n    --workspace=2048 --saveEngine=yolov4_-1_3_320_512_dynamic.engine --fp16\n    ```\n\n## 5.3 Run the demo\n\n```sh\npython demo_trt.py \u003CtensorRT_engine_file> \u003Cinput_image> \u003Cinput_H> \u003Cinput_W>\n```\n\n- This demo here only works when batchSize is dynamic (1 should be within dynamic range) or batchSize=1, but you can update this demo a little for other dynamic or static batch sizes.\n    \n- Note1: input_H and input_W should agree with the input size in the original ONNX file.\n    \n- Note2: extra NMS operations are needed for the tensorRT output. This demo uses python NMS code from `tool\u002Futils.py`.\n\n\n# 6. ONNX2Tensorflow\n\n- **First:Conversion to ONNX**\n\n    tensorflow >=2.0\n    \n    1: Thanks:github:https:\u002F\u002Fgithub.com\u002Fonnx\u002Fonnx-tensorflow\n    \n    2: Run git clone https:\u002F\u002Fgithub.com\u002Fonnx\u002Fonnx-tensorflow.git && cd onnx-tensorflow\n    Run pip install -e .\n    \n    Note:Errors will occur when using \"pip install onnx-tf\", at least for me,it is recommended to use source code installation\n\n# 7. ONNX2TensorRT and DeepStream Inference\n  \n  1. Compile the DeepStream Nvinfer Plugin \n  \n  ```\n      cd DeepStream\n      make \n  ```\n  2. Build a TRT Engine.\n  \n   For single batch, \n   ```\n   trtexec --onnx=\u003Connx_file> --explicitBatch --saveEngine=\u003CtensorRT_engine_file> --workspace=\u003Csize_in_megabytes> --fp16\n   ```\n   \n   For multi-batch, \n  ```\n  trtexec --onnx=\u003Connx_file> --explicitBatch --shapes=input:Xx3xHxW --optShapes=input:Xx3xHxW --maxShapes=input:Xx3xHxW --minShape=input:1x3xHxW --saveEngine=\u003CtensorRT_engine_file> --fp16\n  ```\n  \n  Note :The maxShapes could not be larger than model original shape.\n  \n  3. Write the deepstream config file for the TRT Engine.\n  \n  \n   \nReference:\n- https:\u002F\u002Fgithub.com\u002Feriklindernoren\u002FPyTorch-YOLOv3\n- https:\u002F\u002Fgithub.com\u002Fmarvis\u002Fpytorch-caffe-darknet-convert\n- https:\u002F\u002Fgithub.com\u002Fmarvis\u002Fpytorch-yolo3\n\n```\n@article{yolov4,\n  title={YOLOv4: YOLOv4: Optimal Speed and Accuracy of Object Detection},\n  author={Alexey Bochkovskiy, Chien-Yao Wang, Hong-Yuan Mark Liao},\n  journal = {arXiv},\n  year={2020}\n}\n```\n","# PyTorch-YOLOv4\n\n![](https:\u002F\u002Fimg.shields.io\u002Fstatic\u002Fv1?label=python&message=3.6|3.7&color=blue)\n![](https:\u002F\u002Fimg.shields.io\u002Fstatic\u002Fv1?label=pytorch&message=1.4&color=\u003CCOLOR>)\n[![](https:\u002F\u002Fimg.shields.io\u002Fstatic\u002Fv1?label=license&message=Apache2&color=green)](.\u002FLicense.txt)\n\nYOLOv4 的一个极简 PyTorch 实现。\n- YOLO v4 论文：https:\u002F\u002Farxiv.org\u002Fabs\u002F2004.10934\n- 源代码：https:\u002F\u002Fgithub.com\u002FAlexeyAB\u002Fdarknet\n- 更多详情：http:\u002F\u002Fpjreddie.com\u002Fdarknet\u002Fyolo\u002F\n\n\n- [x] 推理\n- [x] 训练\n    - [x] 马赛克数据增强\n\n```\n├── README.md\n├── dataset.py            数据集\n├── demo.py               运行 PyTorch 的示例 --> 工具\u002Fdarknet2pytorch\n├── demo_darknet2onnx.py  转换为 ONNX 的工具 --> 工具\u002Fdarknet2pytorch\n├── demo_pytorch2onnx.py  转换为 ONNX 的工具\n├── models.py             PyTorch 模型\n├── train.py              训练 models.py\n├── cfg.py                训练用的 cfg 文件\n├── cfg                   cfg 文件 --> darknet2pytorch\n├── data            \n├── weight                --> darknet2pytorch\n├── tool\n│   ├── camera.py           一个摄像头示例\n│   ├── coco_annotation.py       COCO 数据集生成器\n│   ├── config.py\n│   ├── darknet2pytorch.py\n│   ├── region_loss.py\n│   ├── utils.py\n│   └── yolo_layer.py\n```\n\n![image](https:\u002F\u002Fuser-gold-cdn.xitu.io\u002F2020\u002F4\u002F26\u002F171b5a6c8b3bd513?w=768&h=576&f=jpeg&s=78882)\n\n# 0. 权重下载\n\n## 0.1 Darknet\n- 百度网盘(https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1dAGEW8cm-dqK14TbhhVetA     提取码：dm5b)\n- Google Drive(https:\u002F\u002Fdrive.google.com\u002Fopen?id=1cewMfusmPjYWbrnuJRuKhPMwRe_b9PaT)\n\n## 0.2 PyTorch\n你可以使用 darknet2pytorch 自行转换，或者直接下载我转换好的模型。\n\n- 百度网盘\n    - yolov4.pth(https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1ZroDvoGScDgtE1ja_QqJVw 提取码：xrq9) \n    - yolov4.conv.137.pth(https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1ovBie4YyVQQoUrC3AY0joA 提取码：kcel)\n- Google Drive\n    - yolov4.pth(https:\u002F\u002Fdrive.google.com\u002Fopen?id=1wv_LiFeCRYwtpkqREPeI13-gPELBDwuJ)\n    - yolov4.conv.137.pth(https:\u002F\u002Fdrive.google.com\u002Fopen?id=1fcbR0bWzYfIEdLJPzOsn4R5mlvR6IQyA)\n\n# 1. 训练\n\n[使用 YOLOv4 训练自己的数据](Use_yolov4_to_train_your_own_data.md)\n\n1. 下载权重\n2. 转换数据\n\n    对于 COCO 数据集，可以使用 tool\u002Fcoco_annotation.py。\n    ```\n    # train.txt\n    图片路径1 x1,y1,x2,y2,id x1,y1,x2,y2,id x1,y1,x2,y2,id ...\n    图片路径2 x1,y1,x2,y2,id x1,y1,x2,y2,id x1,y1,x2,y2,id ...\n    ...\n    ...\n    ```\n3. 训练\n\n    你可以在 cfg.py 中设置参数。\n    ```\n     python train.py -g [GPU_ID] -dir [数据集路径] ...\n    ```\n\n# 2. 推理\n\n## 2.1 在 MS COCO 数据集上的性能（使用来自 \u003Chttps:\u002F\u002Fgithub.com\u002FAlexeyAB\u002Fdarknet> 的预训练 Darknet 权重）\n\n**ONNX 和 TensorRT 模型是从 PyTorch 转换而来（TianXiaomo）：PyTorch->ONNX->TensorRT。**\n更多关于转换的细节请参见后续章节。\n\n- val2017 数据集（输入尺寸：416x416）\n\n| 模型类型          | AP          | AP50        | AP75        |  APS        | APM         | APL         |\n| ------------------- | ----------: | ----------: | ----------: | ----------: | ----------: | ----------: |\n| DarkNet (YOLOv4 论文)|     0.471 |       0.710 |       0.510 |       0.278 |       0.525 |       0.636 |\n| PyTorch (TianXiaomo)|       0.466 |       0.704 |       0.505 |       0.267 |       0.524 |       0.629 |\n| TensorRT FP32 + BatchedNMSPlugin | 0.472| 0.708 |       0.511 |       0.273 |       0.530 |       0.637 |\n| TensorRT FP16 + BatchedNMSPlugin | 0.472| 0.708 |       0.511 |       0.273 |       0.530 |       0.636 |\n\n- testdev2017 数据集（输入尺寸：416x416）\n\n| 模型类型          | AP          | AP50        | AP75        |  APS        | APM         | APL         |\n| ------------------- | ----------: | ----------: | ----------: | ----------: | ----------: | ----------: |\n| DarkNet (YOLOv4 论文)|     0.412 |       0.628 |       0.443 |       0.204 |       0.444 |       0.560 |\n| PyTorch (TianXiaomo)|       0.404 |       0.615 |       0.436 |       0.196 |       0.438 |       0.552 |\n| TensorRT FP32 + BatchedNMSPlugin | 0.412| 0.625 |       0.445 |       0.200 |       0.446 |       0.564 |\n| TensorRT FP16 + BatchedNMSPlugin | 0.412| 0.625 |       0.445 |       0.200 |       0.446 |       0.563 |\n\n\n## 2.2 推理时的图像输入尺寸\n\n图像输入尺寸并不局限于 `320 * 320`、`416 * 416`、`512 * 512` 和 `608 * 608`。\n你可以根据需要调整输入尺寸以获得不同的宽高比，例如：`320 * 608`。\n更大的输入尺寸有助于检测更小的目标，但可能会降低推理速度并消耗更多 GPU 内存。\n\n```py\nheight = 320 + 96 * n, n in {0, 1, 2, 3, ...}\nwidth  = 320 + 96 * m, m in {0, 1, 2, 3, ...}\n```\n\n## 2.3 **不同的推理选项**\n\n- 加载预训练的 Darknet 模型和权重进行推理（图像尺寸已在 cfg 文件中配置）\n\n    ```sh\n    python demo.py -cfgfile \u003CcfgFile> -weightfile \u003CweightFile> -imgfile \u003CimgFile>\n    ```\n\n- 加载 PyTorch 权重（pth 文件）进行推理\n\n    ```sh\n    python models.py \u003Cnum_classes> \u003Cweightfile> \u003Cimgfile> \u003CIN_IMAGE_H> \u003CIN_IMAGE_W> \u003Cnamefile(可选)>\n    ```\n    \n- 加载转换后的 ONNX 文件进行推理（见第 3 和第 4 节）\n\n- 加载转换后的 TensorRT 引擎文件进行推理（见第 5 节）\n\n## 2.4 推理输出\n\n推理输出有两个：\n- 一个是边界框的位置信息，其形状为 `[batch, num_boxes, 1, 4]`，表示每个边界框的 x1, y1, x2, y2。\n- 另一个是边界框的得分，形状为 `[batch, num_boxes, num_classes]`，表示每个边界框在所有类别上的得分。\n\n目前仍需要进行一些后处理，包括 NMS。我们正在努力减少后处理的时间和复杂性。\n\n\n# 3. Darknet2ONNX\n\n- **此脚本用于将官方预训练的 Darknet 模型转换为 ONNX 格式**\n\n- **推荐的 PyTorch 版本：**\n\n    - 对于 TensorRT 7.0 及以上版本，建议使用 PyTorch 1.4.0\n    - 对于 TensorRT 7.1.2 及以上版本，建议使用 PyTorch 1.5.0 或 1.6.0\n\n- **安装 onnxruntime**\n\n    ```sh\n    pip install onnxruntime\n    ```\n\n- **运行 Python 脚本生成 ONNX 模型并运行示例**\n\n    ```sh\n    python demo_darknet2onnx.py \u003CcfgFile> \u003CnamesFile> \u003CweightFile> \u003CimageFile> \u003CbatchSize>\n    ```\n\n## 3.1 动态或静态批次大小\n\n- **正数批次大小会生成静态批次大小的 ONNX 模型，否则批次大小将是动态的**\n    - 动态批次大小只会生成一个 ONNX 模型\n    - 静态批次大小会生成两个 ONNX 模型，其中一个用于运行示例（batch_size=1）\n\n# 4. PyTorch转ONNX\n\n- **您可以使用此脚本将训练好的PyTorch模型转换为ONNX格式**\n\n- **推荐的PyTorch版本：**\n\n    - 对于TensorRT 7.0及以上版本，建议使用PyTorch 1.4.0\n    - 对于TensorRT 7.1.2及以上版本，建议使用PyTorch 1.5.0或1.6.0\n\n- **安装onnxruntime**\n\n    ```sh\n    pip install onnxruntime\n    ```\n\n- **运行Python脚本生成ONNX模型并执行演示**\n\n    ```sh\n    python demo_pytorch2onnx.py \u003Cweight_file> \u003Cimage_path> \u003Cbatch_size> \u003Cn_classes> \u003CIN_IMAGE_H> \u003CIN_IMAGE_W>\n    ```\n\n    例如：\n\n    ```sh\n    python demo_pytorch2onnx.py yolov4.pth dog.jpg 8 80 416 416\n    ```\n\n## 4.1 动态或静态批大小\n\n- **正数批大小将生成静态批大小的ONNX模型，否则批大小将是动态的**\n    - 动态批大小只会生成一个ONNX模型\n    - 静态批大小会生成两个ONNX模型，其中一个用于运行演示（批大小=1）\n\n\n# 5. ONNX转TensorRT\n\n- **推荐的TensorRT版本：7.0、7.1**\n\n## 5.1 从静态批大小的ONNX转换\n\n- **运行以下命令将YOLOv4 ONNX模型转换为TensorRT引擎**\n\n    ```sh\n    trtexec --onnx=\u003Connx_file> --explicitBatch --saveEngine=\u003CtensorRT_engine_file> --workspace=\u003Csize_in_megabytes> --fp16\n    ```\n    - 注意：如果要在转换中使用int8模式，需要额外进行int8校准。\n\n## 5.2 从动态批大小的ONNX转换\n\n- **运行以下命令将YOLOv4 ONNX模型转换为TensorRT引擎**\n\n    ```sh\n    trtexec --onnx=\u003Connx_file> \\\n    --minShapes=input:\u003Cshape_of_min_batch> --optShapes=input:\u003Cshape_of_opt_batch> --maxShapes=input:\u003Cshape_of_max_batch> \\\n    --workspace=\u003Csize_in_megabytes> --saveEngine=\u003Cengine_file> --fp16\n    ```\n- 例如：\n\n    ```sh\n    trtexec --onnx=yolov4_-1_3_320_512_dynamic.onnx \\\n    --minShapes=input:1x3x320x512 --optShapes=input:4x3x320x512 --maxShapes=input:8x3x320x512 \\\n    --workspace=2048 --saveEngine=yolov4_-1_3_320_512_dynamic.engine --fp16\n    ```\n\n## 5.3 运行演示\n\n```sh\npython demo_trt.py \u003CtensorRT_engine_file> \u003Cinput_image> \u003Cinput_H> \u003Cinput_W>\n```\n\n- 此处的演示仅在批大小为动态（1应在动态范围内）或批大小为1时有效，但您可以稍作修改以适应其他动态或静态批大小。\n    \n- 注意1：input_H和input_W应与原始ONNX文件中的输入尺寸一致。\n    \n- 注意2：TensorRT输出需要额外的NMS操作。此演示使用`tool\u002Futils.py`中的Python NMS代码。\n\n\n# 6. ONNX转TensorFlow\n\n- **第一步：转换为ONNX**\n\n    tensorflow >=2.0\n    \n    1：感谢：github:https:\u002F\u002Fgithub.com\u002Fonnx\u002Fonnx-tensorflow\n    \n    2：运行git clone https:\u002F\u002Fgithub.com\u002Fonnx\u002Fonnx-tensorflow.git && cd onnx-tensorflow\n    然后运行pip install -e .\n    \n    注意：使用“pip install onnx-tf”时可能会出现错误，至少对我而言如此，因此建议使用源码安装方法。\n\n# 7. ONNX转TensorRT及DeepStream推理\n\n1. 编译DeepStream Nvinfer插件\n  \n   ```\n      cd DeepStream\n      make \n  ```\n  \n2. 构建TRT引擎。\n  \n   对于单批次，\n   ```\n   trtexec --onnx=\u003Connx_file> --explicitBatch --saveEngine=\u003CtensorRT_engine_file> --workspace=\u003Csize_in_megabytes> --fp16\n   ```\n   \n   对于多批次，\n  ```\n  trtexec --onnx=\u003Connx_file> --explicitBatch --shapes=input:Xx3xHxW --optShapes=input:Xx3xHxW --maxShapes=input:Xx3xHxW --minShape=input:1x3xHxW --saveEngine=\u003CtensorRT_engine_file> --fp16\n  ```\n  \n  注意：maxShapes不能大于模型的原始形状。\n  \n3. 为TRT引擎编写Deepstream配置文件。\n  \n  \n   \n参考：\n- https:\u002F\u002Fgithub.com\u002Feriklindernoren\u002FPyTorch-YOLOv3\n- https:\u002F\u002Fgithub.com\u002Fmarvis\u002Fpytorch-caffe-darknet-convert\n- https:\u002F\u002Fgithub.com\u002Fmarvis\u002Fpytorch-yolo3\n\n```\n@article{yolov4,\n  title={YOLOv4: YOLOv4：目标检测的最佳速度与精度},\n  author={Alexey Bochkovskiy, Chien-Yao Wang, Hong-Yuan Mark Liao},\n  journal = {arXiv},\n  year={2020}\n}\n```","# PyTorch-YOLOv4 快速上手指南\n\n本指南基于 `pytorch-YOLOv4` 开源项目，帮助开发者快速在 PyTorch 环境中部署、训练及推理 YOLOv4 模型。\n\n## 1. 环境准备\n\n### 系统要求\n- **Python**: 3.6 或 3.7\n- **PyTorch**: 1.4.0 (推荐用于 TensorRT 7.0+)，也支持 1.5.0\u002F1.6.0\n- **GPU**: 支持 CUDA 的 NVIDIA 显卡（训练和加速推理必需）\n\n### 前置依赖\n请确保已安装以下基础库：\n```bash\npip install torch torchvision opencv-python numpy\n```\n\n若需进行模型转换（ONNX\u002FTensorRT），还需安装：\n```bash\npip install onnx onnxruntime\n```\n\n## 2. 安装步骤\n\n### 2.1 获取代码\n克隆项目仓库：\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FTianxiaomo\u002Fpytorch-YOLOv4.git\ncd pytorch-YOLOv4\n```\n\n### 2.2 下载预训练权重\n你可以选择手动转换 Darknet 权重，或直接下载已转换好的 PyTorch 权重文件。\n\n**推荐：直接下载已转换的权重（国内用户推荐使用百度网盘）**\n\n- **完整模型 (yolov4.pth)**\n  - 百度网盘: [下载链接](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1ZroDvoGScDgtE1ja_QqJVw) (提取码: `xrq9`)\n  - Google Drive: [下载链接](https:\u002F\u002Fdrive.google.com\u002Fopen?id=1wv_LiFeCRYwtpkqREPeI13-gPELBDwuJ)\n\n- **卷积骨干网络 (yolov4.conv.137.pth，用于微调训练)**\n  - 百度网盘: [下载链接](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1ovBie4YyVQQoUrC3AY0joA) (提取码: `kcel`)\n  - Google Drive: [下载链接](https:\u002F\u002Fdrive.google.com\u002Fopen?id=1fcbR0bWzYfIEdLJPzOsn4R5mlvR6IQyA)\n\n将下载的 `.pth` 文件放入项目根目录或 `weight` 文件夹中。\n\n## 3. 基本使用\n\n### 3.1 快速推理 (Inference)\n使用预训练权重对单张图片进行检测是最简单的上手方式。\n\n**方式一：加载 PyTorch 权重 (.pth)**\n适用于直接使用本项目提供的权重文件。\n```bash\npython models.py 80 weight\u002Fyolov4.pth dog.jpg 416 416\n```\n*参数说明：`80` 为类别数 (COCO)，`dog.jpg` 为输入图片，`416 416` 为输入宽高。*\n\n**方式二：加载 Darknet 配置和权重 (.cfg + .weights)**\n适用于使用官方 Darknet 原始权重文件。\n```bash\npython demo.py -cfgfile cfg\u002Fyolov4.cfg -weightfile weight\u002Fyolov4.weights -imgfile dog.jpg\n```\n\n### 3.2 训练自己的数据 (Train)\n若需训练自定义数据集，请按以下步骤操作：\n\n1.  **准备数据**：\n    生成 `train.txt`，格式如下（图片路径后跟随边界框坐标和类别 ID）：\n    ```text\n    image_path1 x1,y1,x2,y2,id x1,y1,x2,y2,id ...\n    image_path2 x1,y1,x2,y2,id x1,y1,x2,y2,id ...\n    ```\n    *注：可使用 `tool\u002Fcoco_annotation.py` 自动转换 COCO 格式数据集。*\n\n2.  **配置参数**：\n    编辑 `cfg.py` 文件，设置数据集路径、类别数、batch size 等参数。\n\n3.  **开始训练**：\n    ```bash\n    python train.py -g 0 -dir \u002Fpath\u002Fto\u002Fyour\u002Fdataset\n    ```\n    *参数 `-g` 指定 GPU ID，`-dir` 指定数据目录。*\n\n### 3.3 模型导出 (可选)\n本项目支持将模型转换为 ONNX 或 TensorRT 引擎以加速推理。\n\n- **转为 ONNX**:\n  ```bash\n  python demo_pytorch2onnx.py weight\u002Fyolov4.pth dog.jpg 1 80 416 416\n  ```\n- **转为 TensorRT** (需安装 TensorRT):\n  ```bash\n  trtexec --onnx=yolov4.onnx --explicitBatch --saveEngine=yolov4.engine --fp16\n  ```","某智慧交通团队需要在边缘计算设备上部署实时车辆检测系统，以监控路口违章行为并统计车流量。\n\n### 没有 pytorch-YOLOv4 时\n- **框架迁移困难**：官方 YOLOv4 基于 Darknet 框架，团队成员熟悉 PyTorch 却不得不重新学习 C 语言架构，导致算法复现和调试周期长达数周。\n- **训练功能缺失**：缺乏原生支持 Mosaic 数据增强等关键训练策略的 PyTorch 代码，直接导致模型在小目标（如远处车辆）检测上的精度难以达标。\n- **部署性能瓶颈**：无法直接将模型转换为 ONNX 或 TensorRT 格式，边缘设备推理延迟高，无法满足每秒 30 帧的实时处理需求。\n- **数据适配繁琐**：缺少自动化的 COCO 数据集标注转换工具，人工整理训练数据格式极易出错且效率低下。\n\n### 使用 pytorch-YOLOv4 后\n- **无缝开发体验**：利用其最小化的 PyTorch 实现，团队直接复用现有代码库，三天内即可完成模型加载与基础推理验证。\n- **精度显著提升**：通过内置的 Mosaic 训练支持，模型在复杂光照下的车辆识别率大幅提升，小目标检测指标（APS）接近原版 Darknet 水平。\n- **高效边缘部署**：借助集成的 `demo_pytorch2onnx.py` 工具，一键将模型转为 TensorRT 引擎，在嵌入式设备上推理速度提升 3 倍，成功实现实时检测。\n- **数据流程自动化**：使用 `coco_annotation.py` 脚本快速生成标准训练列表，将原本需要两天的人工数据清洗工作缩短至半小时。\n\npytorch-YOLOv4 通过打通从训练优化到端侧高性能部署的全链路，让团队得以专注于业务逻辑而非底层框架适配。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FTianxiaomo_pytorch-YOLOv4_ac1f0948.png","Tianxiaomo",null,"https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FTianxiaomo_10f9bb57.jpg","DL CV OCR and algorithm optimization","Dahuatech","Hangzhou","https:\u002F\u002Ftianxiaomo.github.io\u002F","https:\u002F\u002Fgithub.com\u002FTianxiaomo",[82,86,90,94],{"name":83,"color":84,"percentage":85},"Python","#3572A5",74.2,{"name":87,"color":88,"percentage":89},"C++","#f34b7d",24.1,{"name":91,"color":92,"percentage":93},"Cuda","#3A4E3A",1,{"name":95,"color":96,"percentage":97},"Makefile","#427819",0.7,4530,1491,"2026-04-04T07:24:11","Apache-2.0","未说明","需要 NVIDIA GPU（用于训练和 TensorRT 加速），具体显存大小取决于输入图像尺寸（大尺寸更耗显存），需安装对应 PyTorch 版本的 CUDA 环境",{"notes":105,"python":106,"dependencies":107},"该项目支持将 Darknet 权重转换为 PyTorch、ONNX 及 TensorRT 格式。若使用 TensorRT 进行 FP16 推理，需确保显卡支持。输入图像尺寸灵活（高宽需满足 320 + 96*n 的格式），但较大尺寸会显著增加显存消耗并降低速度。若需转换为 TensorFlow 模型，需源码安装 onnx-tensorflow 而非 pip 安装。","3.6, 3.7",[108,109,110,111],"torch==1.4.0 (推荐用于 TensorRT 7.0+)","torch==1.5.0 或 1.6.0 (推荐用于 TensorRT 7.1.2+)","onnxruntime","tensorrt (7.0 或 7.1 推荐)",[14],[114,115,116,117,118,119,120,121,122],"yolov4","pytorch","darknet2pytorch","darknet2onnx","tensorrt","onnx","pytorch-yolov4","yolov4-tiny","yolov3","2026-03-27T02:49:30.150509","2026-04-06T16:15:10.831693",[126,131,136,141,146,151],{"id":127,"question_zh":128,"answer_zh":129,"source_url":130},19442,"为什么在 CPU 上运行 camera.py 速度非常慢？","在 CPU 上运行确实较慢，官方测试数据显示在 Tesla T4 GPU 上，输入 416*416、batch_size=1 时，总推理时间约为 0.043 秒（预处理 0.0012s + 模型推理 0.0341s + 后处理 0.0039s）。如果在 Titan 等显卡上仍然感觉慢（如 160ms），瓶颈通常在于 Python 的后处理代码（特别是 get_region_boxes 函数曾耗时超过 0.15s）。维护者已通过更新代码消除了 get_region_boxes() 的运行时间瓶颈，优化后后处理总时间降至约 0.026 秒。建议拉取最新代码以获得性能提升。","https:\u002F\u002Fgithub.com\u002FTianxiaomo\u002Fpytorch-YOLOv4\u002Fissues\u002F2",{"id":132,"question_zh":133,"answer_zh":134,"source_url":135},19443,"在 Jetson NX 或 TensorRT 环境下推理正常但无法显示检测框（bbox）怎么办？","这是一个已知问题，通常表现为 ONNX 演示正常但 TensorRT (trt) 演示预测出无效的 y 坐标，导致图片上没有框。该问题已在后续代码更新中修复。如果遇到此情况，请确保拉取最新的代码库并重新生成 TensorRT 引擎文件。如果问题依旧，检查是否使用了正确的 TensorRT 版本（如 nvcr.io\u002Fnvidia\u002Ftensorrt:20.06-py3）以及 CUDA 驱动是否匹配。","https:\u002F\u002Fgithub.com\u002FTianxiaomo\u002Fpytorch-YOLOv4\u002Fissues\u002F102",{"id":137,"question_zh":138,"answer_zh":139,"source_url":140},19444,"训练或评估时出现 'ValueError: too many values to unpack (expected 2)' 错误如何解决？","该错误通常发生在数据加载或评估阶段。部分用户尝试修改 cfg.py 中的 get_image_id 函数，但这通常是解决另一个问题（#182）的方法，与此错误无关。如果数据集准备无误但仍频繁出现各类解包错误或 Bug，可能是仓库版本不稳定或文档说明不足导致的数据集格式不匹配。建议仔细核对 README 中关于数据集格式的要求，或尝试回退到更稳定的代码版本。如果问题持续，可能需要检查 train.py 中 evaluate 函数的输出结构是否与数据加载器一致。","https:\u002F\u002Fgithub.com\u002FTianxiaomo\u002Fpytorch-YOLOv4\u002Fissues\u002F209",{"id":142,"question_zh":143,"answer_zh":144,"source_url":145},19445,"如何修改 demo_trt.py 以支持大批量（Batch Size > 1）推理？","要实现大批量推理，需要在导出 ONNX 和构建 TensorRT 引擎时明确指定 batch size。1. 导出 ONNX 时确保动态轴或固定轴包含批次维度；2. 使用 trtexec 构建引擎时添加 --explicitBatch 标志，例如：`.\u002Ftrtexec --onnx=yolov4_5_3_320_320.onnx --explicitBatch --saveEngine=yolov4_320_5.trt --fp16`。注意：如果引擎构建时的最大 batch size 为 1，而推理时传入 batch size=5，会报错 'Parameter check failed... batchSize \u003C= mEngine.getMaxBatchSize()'。因此，构建引擎时必须确保其支持的目标 batch size 大于等于推理时的 batch size。","https:\u002F\u002Fgithub.com\u002FTianxiaomo\u002Fpytorch-YOLOv4\u002Fissues\u002F120",{"id":147,"question_zh":148,"answer_zh":149,"source_url":150},19446,"训练好的模型在推理时没有检测到任何物体或边界框（bbox），原因是什么？","如果训练了多个 epoch 但推理无结果，首先确认使用的推理脚本是否正确。有用户反馈，自己训练的 .pth 模型在使用 models.py 进行预测时可以检测到框，但在使用 demo.py、demo_onnx.py 或 demo_trt.py 时可能失败。这是因为这些演示脚本及其依赖项在不断演进，可能存在兼容性问题。解决方案是：1. 拉取最新的代码库；2. 确保模型文件（pth\u002Fweights\u002Fonnx\u002Ftrt）与当前的推理脚本版本匹配；3. 如果是自定义数据集，检查类别索引和配置文件是否一致。","https:\u002F\u002Fgithub.com\u002FTianxiaomo\u002Fpytorch-YOLOv4\u002Fissues\u002F51",{"id":152,"question_zh":153,"answer_zh":154,"source_url":155},19447,"将 pth 模型转换为 onnx 后，推理输出全为 'nan' 怎么办？","当 pth 转 onnx 后推理输出全为 nan，通常是因为模型处于训练模式（Training Mode）而非评估模式（Eval Mode），导致 BatchNorm 层行为异常或 Dropout 层生效。在导出 ONNX 模型前，务必在代码中调用 `model.eval()` 将模型设置为评估模式，并禁用梯度计算（`with torch.no_grad():`）。此外，检查输入数据的预处理（如归一化方式、RGB\u002FBGR 顺序）是否与训练时完全一致。","https:\u002F\u002Fgithub.com\u002FTianxiaomo\u002Fpytorch-YOLOv4\u002Fissues\u002F108",[]]