[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-openseg-group--OCNet.pytorch":3,"tool-openseg-group--OCNet.pytorch":62},[4,18,26,35,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},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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",109154,2,"2026-04-18T11:18:24",[14,15,13],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":32,"last_commit_at":41,"category_tags":42,"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",[43,13,15,14],"插件",{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":10,"last_commit_at":50,"category_tags":51,"status":17},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,"2026-04-06T11:19:32",[52,15,13,14],"语言模型",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":10,"last_commit_at":59,"category_tags":60,"status":17},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,61],"视频",{"id":63,"github_repo":64,"name":65,"description_en":66,"description_zh":67,"ai_summary_zh":68,"readme_en":69,"readme_zh":70,"quickstart_zh":71,"use_case_zh":72,"hero_image_url":73,"owner_login":74,"owner_name":74,"owner_avatar_url":75,"owner_bio":76,"owner_company":77,"owner_location":77,"owner_email":78,"owner_twitter":77,"owner_website":77,"owner_url":79,"languages":80,"stars":101,"forks":102,"last_commit_at":103,"license":104,"difficulty_score":10,"env_os":105,"env_gpu":106,"env_ram":107,"env_deps":108,"category_tags":120,"github_topics":77,"view_count":32,"oss_zip_url":77,"oss_zip_packed_at":77,"status":17,"created_at":121,"updated_at":122,"faqs":123,"releases":157},9084,"openseg-group\u002FOCNet.pytorch","OCNet.pytorch","Please choose the openseg.pytorch project for the updated code that achieve SOTA on 6 benchmarks!","OCNet.pytorch 是一个基于 PyTorch 框架实现的开源项目，专注于解决计算机视觉中的场景解析（语义分割）难题。它的核心目标是让 AI 在识别图像时，不仅能看清局部像素，还能理解物体与其周围环境的关系，从而显著提升分割的准确度。\n\n传统方法往往难以处理复杂背景下的物体边界模糊问题，而 OCNet 通过引入独特的“对象上下文表示”（OCR）机制，有效聚合了同类物体的全局上下文信息。这一技术亮点使其在 Cityscapes、ADE20K、COCO-Stuff 等六大权威基准测试中屡创佳绩，甚至曾登顶 Cityscapes 排行榜首位。此外，该项目后续演进出的 openseg.pytorch 版本进一步支持了混合精度训练和分布式训练，大幅提升了效率与性能。\n\nOCNet.pytorch 非常适合人工智能研究人员、算法工程师以及高校开发者使用。如果你正在从事自动驾驶环境感知、医疗影像分析或机器人视觉等相关领域的研究，需要复现前沿论文或构建高精度的语义分割模型，这套代码库提供了坚实的基线和丰富的预训练权重参考。虽然它主要面向具备深度学习基础的专业人士，但其开放的社区贡献和持续的更新","OCNet.pytorch 是一个基于 PyTorch 框架实现的开源项目，专注于解决计算机视觉中的场景解析（语义分割）难题。它的核心目标是让 AI 在识别图像时，不仅能看清局部像素，还能理解物体与其周围环境的关系，从而显著提升分割的准确度。\n\n传统方法往往难以处理复杂背景下的物体边界模糊问题，而 OCNet 通过引入独特的“对象上下文表示”（OCR）机制，有效聚合了同类物体的全局上下文信息。这一技术亮点使其在 Cityscapes、ADE20K、COCO-Stuff 等六大权威基准测试中屡创佳绩，甚至曾登顶 Cityscapes 排行榜首位。此外，该项目后续演进出的 openseg.pytorch 版本进一步支持了混合精度训练和分布式训练，大幅提升了效率与性能。\n\nOCNet.pytorch 非常适合人工智能研究人员、算法工程师以及高校开发者使用。如果你正在从事自动驾驶环境感知、医疗影像分析或机器人视觉等相关领域的研究，需要复现前沿论文或构建高精度的语义分割模型，这套代码库提供了坚实的基线和丰富的预训练权重参考。虽然它主要面向具备深度学习基础的专业人士，但其开放的社区贡献和持续的更新维护，也为探索者提供了宝贵的学习资源。","# OCNet: Object Context Network for Scene Parsing (pytorch) \n\n\n[![PWC](https:\u002F\u002Fimg.shields.io\u002Fendpoint.svg?url=https:\u002F\u002Fpaperswithcode.com\u002Fbadge\u002Fobject-contextual-representations-for\u002Fsemantic-segmentation-on-coco-stuff-test)](https:\u002F\u002Fpaperswithcode.com\u002Fsota\u002Fsemantic-segmentation-on-coco-stuff-test?p=object-contextual-representations-for)\n\n[![PWC](https:\u002F\u002Fimg.shields.io\u002Fendpoint.svg?url=https:\u002F\u002Fpaperswithcode.com\u002Fbadge\u002Fobject-contextual-representations-for\u002Fsemantic-segmentation-on-pascal-context)](https:\u002F\u002Fpaperswithcode.com\u002Fsota\u002Fsemantic-segmentation-on-pascal-context?p=object-contextual-representations-for)\n\n[![PWC](https:\u002F\u002Fimg.shields.io\u002Fendpoint.svg?url=https:\u002F\u002Fpaperswithcode.com\u002Fbadge\u002Fobject-contextual-representations-for\u002Fsemantic-segmentation-on-ade20k-val)](https:\u002F\u002Fpaperswithcode.com\u002Fsota\u002Fsemantic-segmentation-on-ade20k-val?p=object-contextual-representations-for)\n\n\t\n[![PWC](https:\u002F\u002Fimg.shields.io\u002Fendpoint.svg?url=https:\u002F\u002Fpaperswithcode.com\u002Fbadge\u002Fobject-contextual-representations-for\u002Fsemantic-segmentation-on-lip-val)](https:\u002F\u002Fpaperswithcode.com\u002Fsota\u002Fsemantic-segmentation-on-lip-val?p=object-contextual-representations-for)\n\n[![PWC](https:\u002F\u002Fimg.shields.io\u002Fendpoint.svg?url=https:\u002F\u002Fpaperswithcode.com\u002Fbadge\u002Fobject-contextual-representations-for\u002Fsemantic-segmentation-on-cityscapes)](https:\u002F\u002Fpaperswithcode.com\u002Fsota\u002Fsemantic-segmentation-on-cityscapes?p=object-contextual-representations-for)\n\n\n\u003Ch2>\n\n\t\n```diff\n+ Our work is submitted to the arXiv on Tue, 4 Sep 2018.\n+ The concurrent work DANet is submitted to the arXiv on Sun, 9 Sep 2018.\n+ We hope you can cite our works in your discussions of the related works if it helps.\n```\n\u003C\u002Fh2>\n\n## News\n\n- 2021\u002F02\u002F14 [openseg.pytorch](https:\u002F\u002Fgithub.com\u002Fopenseg-group\u002Fopenseg.pytorch) supports **pytorch-1.7, mixed-precision, and distributed training**. Based on the [PaddleClas](https:\u002F\u002Fgithub.com\u002FPaddlePaddle\u002FPaddleClas) ImageNet pretrained weights, we achieve **82.78%** on Cityscapes val, **59.62%** on PASCAL-Context val (**new SOTA**) and **45.20%** on COCO-Stuff val (**new SOTA**).\n\n\n- 2020\u002F07\u002F15\n[MMSegmentation](https:\u002F\u002Fgithub.com\u002Fopen-mmlab\u002Fmmsegmentation) also supports our OCR. We further introduce a OCR+ that augments the original OCR with separable convolutions and a decoder head following the same manner as DeepLabv3+, which achieves a strong (single-scale evaluation) performance 81.0% on Cityscapes val set.\n\n\n- 2020\u002F07\u002F09\n[OCR (Spotlight)](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1909.11065.pdf) and [SegFix](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2007.04269.pdf) have been accepted by the ECCV-2020. Notably, the reseachers from Nvidia set a new state-of-the-art performance on Cityscapes leaderboard: [85.4%](https:\u002F\u002Fwww.cityscapes-dataset.com\u002Fmethod-details\u002F?submissionID=7836) via combining our HRNet + OCR with a new [hierarchical mult-scale attention scheme](https:\u002F\u002Farxiv.org\u002Fabs\u002F2005.10821). \n\n- 2020\u002F04\u002F16\nWe have released some of our checkpoints\u002Flogs of OCNet, OCR and SegFix in [openseg.pytorch](https:\u002F\u002Fgithub.com\u002Fopenseg-group\u002Fopenseg.pytorch). Thanks for your patience.\n\n- 2020\u002F01\u002F13\nThe source code for reproduced [HRNet+OCR](https:\u002F\u002Fgithub.com\u002FHRNet\u002FHRNet-Semantic-Segmentation\u002Ftree\u002FHRNet-OCR) has been made public.\n\n- 2020\u002F01\u002F09\n\"HRNet + OCR + SegFix\" achieves **Rank#1** on Cityscapes leaderboard with mIoU as **84.5%**. \n\n- 2020\u002F01\u002F07\n\"HRNet+OCR[Mapillary+Coarse]\" currently achieves **84.26%** with better Mapillary pretraining, where we pretrain the HRNet+OCR model on the original Mapillary train and achieve **50.8%** on Mapillary val. Our training settings are listed as below: 500,000 iterations, batch-size 16 and crop size 1024x1024. We believe our approach can futher benefit from more expensive training settings as in the recent Panoptic-DeepLab. We can expect higher performance with our novel post-processing mechanism.\n\n- 2019\u002F11\u002F28\nWe will release all of our [openseg.pytorch](https:\u002F\u002Fgithub.com\u002FPkuRainBow\u002Fopenseg.pytorch) code within the future week to provide a strong baseline for the community, which supports all of our OCNet series.\nBesides, we also provide the support of OCR on the [HRNet-Semantic-Segmentation](https:\u002F\u002Fgithub.com\u002FHRNet\u002FHRNet-Semantic-Segmentation\u002Ftree\u002Fpytorch-v1.1) code base.\n\n- 2019\u002F11\u002F20\nWe have updated the paper [OCR](https:\u002F\u002Farxiv.org\u002Fabs\u002F1909.11065), which is method of our **Rank#2** entry to the leaderboard of Cityscapes.\nWe could achieve **84.0%** with a simple novel post-processing scheme.\n\n- 2019\u002F07\u002F31\nWe have released the paper [ISA](https:\u002F\u002Farxiv.org\u002Fabs\u002F1907.12273), which is very easy to use and implement while being much more efficient than the conventional self-attention based OCNet or DANet.\n\n- 2019\u002F07\u002F23\nWe achieve **Rank#1** on the leaderboard of Cityscapes (with a single model) and the results will be public soon.\n\n- 2019\u002F07\u002F14\nWe achieve 83.3116%+ on the leaderboard of Cityscapes based on single model HRNet48V2 + OCR [training w\u002Fo any tricks]. More details will be shared in our new code base [openseg.pytorch](https:\u002F\u002Fgithub.com\u002Fopenseg-group\u002Fopenseg.pytorch)\n\n- 2019\u002F05\u002F27\nWe strongly recommend you to star our new code base [openseg.pytorch](https:\u002F\u002Fgithub.com\u002Fopenseg-group\u002Fopenseg.pytorch) and our approach achieves SOTA on all 6 benchmarks and outperforms all the previous approaches by more than 1%~2%.\n\n\n![Overall Framework of OCNet](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fopenseg-group_OCNet.pytorch_readme_5af433281e82.png)\n\nPlease check the paper updated [OCNet](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1809.00916.pdf) here.\n\n\nYou are welcome to share our work with your friends. [zhihu share](https:\u002F\u002Fzhuanlan.zhihu.com\u002Fp\u002F43902175)\n\nPlease consider citing our work if you find it helps you,\n\n```\n@article{YuanW18,\n  title={Ocnet: Object context network for scene parsing},\n  author={Yuhui Yuan and Jingdong Wang},\n  booktitle={arXiv preprint arXiv:1809.00916},\n  year={2018}\n}\n\n@article{HuangYGZCW19,\n  title={Interlaced Sparse Self-Attention for Semantic Segmentation},\n  author={Lang Huang and Yuhui Yuan and Jianyuan Guo and Chao Zhang and Xilin Chen and Jingdong Wang},\n  booktitle={arXiv preprint arXiv:1907.12273},\n  year={2019}\n}\n\n@article{YuanCW20,\n  title={Object-Contextual Representations for Semantic Segmentation},\n  author={Yuhui Yuan and Xilin Chen and Jingdong Wang},\n  booktitle={ECCV},\n  year={2020}\n}\n\n@article{YuanXCW20,\n  title={SegFix: Model-Agnostic Boundary Refinement for Segmentation},\n  author={Yuhui Yuan and Jingyi Xie and Xilin Chen and Jingdong Wang},\n  booktitle={ECCV},\n  year={2020}\n}\n```\n\n## Introduction\n\nContext is essential for various computer vision tasks.\nThe state-of-the-art scene parsing methods have exploited the effectiveness of the context defined over image-level.\nSuch context carries the mixture of objects belonging to different categories.\n\nAccording to that the label of each pixel is defined as the category of the object it belongs to, we propose the Object Context that considers the objects belonging to the same category. \nThe representation of any pixel P's object context is the aggregation of all the pixels' features that belong to the same category with P.\nSince it is impractical to estimate all the objects belonging to the same category in advance,\nwe employ the self-attention method to approximate the objects by learning a pixel-wise similarity map.\n\nWe further propose the Pyramid Object Context and Atrous Spatial Pyramid Object Context to capture context of multiple scales.\nBased on the object context, we introduce the OCNet and show that OCNet achieves state-of-the-art performance on both Cityscapes benchmark and ADE20K benchmark.\n\n\n## Visualization of the learned Object Context\n![Object Context learned with OCNet](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fopenseg-group_OCNet.pytorch_readme_6253344e713b.jpg)\n\n## Experiment Results\nAll of our implementation is based on pytorch, OCNet can achieve competitive performance on various benchmarks such as Cityscapes and ADE20K without any bells and whistles.\n\nThe current performance on the Cityscapes test set of OCNet trained with only the fine-labeled set,\n\n(**fix the bug of multi-scale testing**)\n\n\nMethod | Conference | Backbone | mIoU(\\%) \n---- | --- | --- | --- \nRefineNet |  CVPR2017  | ResNet-101  |  73.6 \nSAC  |  ICCV2017  | ResNet-101  |  78.1 \nPSPNet |  CVPR2017  | ResNet-101  |  78.4\nDUC-HDC | WACV2018 | ResNet-101 | 77.6 \nAAF |   ECCV2018  | ResNet-101  |  77.1 \nBiSeNet |   ECCV2018  | ResNet-101  |  78.9 \nPSANet |  ECCV2018  | ResNet-101  |  80.1 \nDFN  |  CVPR2018  | ResNet-101  |  79.3 \nDSSPN | CVPR2018  | ResNet-101  | 77.8 \nDenseASPP  |  CVPR2018  | DenseNet-161  |  80.6\n**OCNet** | - |  ResNet-101 | **81.7**\n**Fast-OCNet** | - |  ResNet-101 | **82.1**\n\nThe current performance on the ADE20K validation set of the OCNet\n\n\nMethod | Conference | Backbone | mIoU(\\%) \n---- | --- | --- | --- \nRefineNet | CVPR2017  | ResNet-152  |  40.70  \nPSPNet | CVPR2017  | ResNet-101  |  43.29 \nSAC |  ICCV2017  |  ResNet-101  |  44.30  \nPSANet  |  ECCV2018  |  ResNet-101  |  43.77  \nEncNet |  CVPR2018  | ResNet-101  |  44.65\n**OCNet** | - |  ResNet-101 | **45.45**\n\n\nThe current performance on the LIP validation set of the OCNet. We simply replace the PSP module with ASP-OC module within the [CE2P](https:\u002F\u002Fgithub.com\u002Fliutinglt\u002FCE2P) framework.\n\nMethod | Conference | Backbone | val mIoU(\\%) \n---- | --- | --- | --- \nAttention+SSL |  CVPR2017  |  ResNet-101  |  44.73\nSS-NAN    |  CVPR2017  |  ResNet-101  |  47.92 \nMMAN    |  ECCV2018  |  ResNet-101  |  46.81\nMuLA    |  ECCV2018  |  ResNet-101  |  49.30\nJPPNet  |  PAMI2018  |  ResNet-101  |  51.37\nCE2P    |  AAAI2019     | ResNet-101   |  53.10\n**OCNet** | - |  ResNet-101 | **54.72**\n\n\n## Enviroment\nThe code is developed using gcc5.4.0, python 3.6+, cuda8.0+ on Ubuntu 16.04. NVIDIA GPUs ared needed. The code is tested using 4 x NVIDIA P100 GPUS cards.\nAll the experiments on Cityscapes are tested on pytorch0.4.1. \n\nIf you can only access TITAX Pascal \u002F TITAN-1080Ti GPUs, you are recommended to modify the parameter **size** within the base-oc,\n\n```\nself.context = nn.Sequential(\n            nn.Conv2d(2048, 512, kernel_size=3, stride=1, padding=1),\n            InPlaceABNSync(512),\n            BaseOC_Module(in_channels=512, out_channels=512, key_channels=256, value_channels=256, \n            dropout=0.05, sizes=([2]))\n            )\n```\n\n## Quick start\n\n\n### Requirements\n~~~~\ntorch=0.4.1\ntorchvision\ntensorboardX\npillow\ntqdm\nh5py\nscikit-learn\ncv2\n~~~~\n\nJust install the offical pytorch with **pip install torch torchvision** is OK.\n\nWe mainly test all of our results based on the official pytorch 0.4.1.\n\n\n\n### Train\u002FValidate\u002FTest the OCNet (Cityscapes)\n\nWe implement training, validating, testing in one script for convenience. You can achieve all the results by runing this script.\n\n~~~~\nsh run_asp_oc.sh\n~~~~\n\nYou are expected to achieve ~79.5 mIoU on the validation set\u002F ~78.3 mIoU on the testing set (single scale).\n\nYou are also recommended to try the **run_base_oc.sh**, which can also achieve ~79.3 mIoU on the validation set \u002F ~78.1 mIoU on the testing set (single scale).\n\nTo further improve the performance, you can employ the **CriterionOhemDSN_single** by setting that\n\n~~~~\nUSE_OHEM=True\nOHEMTHRES=0.7\nOHEMKEEP=100000\n~~~~\n\nthen you could expect to achieve ~80.4 mIoU on the validation set\u002F ~79.0 mIoU on the testing set (single scale).\n\nTo achieve the 81.2 on the testing set, you need to train the model with both the training set and validation set for 80,000 iterations first(achieve ~80.5 on the testing set(multiple-scale + flip)), then you need to finetune this model for 100,000 iterations with fixed learning rate(1e-4). We adopt the online hard example mining accordingly.\n\n\n## Data preparation\n\nFor the cityscapes dataset, please download the dataset from the Cityscapes webset. Unzip all the images under the path \".\u002FOCNet\u002Fdataset\u002Fcityscapes\". Ensure the path tree like below within the folder \".\u002FOCNet\u002Fdataset\u002Fcityscapes\".\n\n```\n|-- README\n|-- get_cs_extra.sh\n|-- gtCoarse\n|   |-- README\n|   |-- license.txt\n|   |-- train\n|   |-- train_extra\n|   `-- val\n|-- gtFine\n|   |-- README\n|   |-- license.txt\n|   |-- test\n|   |-- train\n|   `-- val\n|-- leftImg8bit\n|   |-- README\n|   |-- license.txt\n|   |-- test\n|   |-- train\n|   |-- train_extra\n|   `-- val\n|-- license.txt\n`-- tree.txt\n```\n## Pretrained Models\n\nPlease put the pretrained models under the folder \".\u002FOCNet\u002Fpretrained_model\"\n\n[ImageNet Pretrained ResNet-101](http:\u002F\u002Fsceneparsing.csail.mit.edu\u002Fmodel\u002Fpretrained_resnet\u002Fresnet101-imagenet.pth)\n\n## Docker with the enviroments\n\n[rainbowsecret\u002Fpytorch04:20180719](https:\u002F\u002Fhub.docker.com\u002Fr\u002Frainbowsecret\u002Fpytorch04\u002Ftags\u002F)\n\n## Other problems (Performance gap between the Validation set and Testing set)\nWe find that the mIoU of the class train is unstable sometimes. For example, we run our code for 5 times, there can exist one time the mIoU for class train is 0.42 while we can get 0.75 for other 4 times.\n\nThere also exist some problems about the validation\u002Ftesting set accuracy gap.\nFor example, if you run the base-oc method for two times, you can achieve 79.3 and 79.8 mIou on the validation set separately while the testing mIou can be 78.55 and 77.69.\nThus I recommend to you to run our methods for multiple times if you want to achieve good performance on the testing set while our method performs pretty robust on the validation set as the reason of the distribution gaps between the training\u002Fvalidation set and the testing set.\n\n## Acknowledgment\nThis project is created based on the reproduced Deeplabv3, PSPNet (pytorch) provided by [Zilong Huang](https:\u002F\u002Fgithub.com\u002Fspeedinghzl) and he retains all the copyright of the reproduced Deeplabv3, PSPNet related code. \n\n## Thanks to the Third Party Libs\n[InplaceABN](https:\u002F\u002Fgithub.com\u002Fmapillary\u002Finplace_abn)\n\n[Non-local_pytorch](https:\u002F\u002Fgithub.com\u002FAlexHex7\u002FNon-local_pytorch).\n\n[Pytorch-Deeplab](https:\u002F\u002Fgithub.com\u002Fspeedinghzl\u002FPytorch-Deeplab)\n\n[PyTorch-Encoding](https:\u002F\u002Fgithub.com\u002Fzhanghang1989\u002FPyTorch-Encoding)\n\n[semantic-segmentation-pytorch](https:\u002F\u002Fgithub.com\u002FCSAILVision\u002Fsemantic-segmentation-pytorch)\n\n\n","# OCNet：用于场景解析的对象上下文网络（PyTorch）\n\n\n[![PWC](https:\u002F\u002Fimg.shields.io\u002Fendpoint.svg?url=https:\u002F\u002Fpaperswithcode.com\u002Fbadge\u002Fobject-contextual-representations-for\u002Fsemantic-segmentation-on-coco-stuff-test)](https:\u002F\u002Fpaperswithcode.com\u002Fsota\u002Fsemantic-segmentation-on-coco-stuff-test?p=object-contextual-representations-for)\n\n[![PWC](https:\u002F\u002Fimg.shields.io\u002Fendpoint.svg?url=https:\u002F\u002Fpaperswithcode.com\u002Fbadge\u002Fobject-contextual-representations-for\u002Fsemantic-segmentation-on-pascal-context)](https:\u002F\u002Fpaperswithcode.com\u002Fsota\u002Fsemantic-segmentation-on-pascal-context?p=object-contextual-representations-for)\n\n[![PWC](https:\u002F\u002Fimg.shields.io\u002Fendpoint.svg?url=https:\u002F\u002Fpaperswithcode.com\u002Fbadge\u002Fobject-contextual-representations-for\u002Fsemantic-segmentation-on-ade20k-val)](https:\u002F\u002Fpaperswithcode.com\u002Fsota\u002Fsemantic-segmentation-on-ade20k-val?p=object-contextual-representations-for)\n\n\t\n[![PWC](https:\u002F\u002Fimg.shields.io\u002Fendpoint.svg?url=https:\u002F\u002Fpaperswithcode.com\u002Fbadge\u002Fobject-contextual-representations-for\u002Fsemantic-segmentation-on-lip-val)](https:\u002F\u002Fpaperswithcode.com\u002Fsota\u002Fsemantic-segmentation-on-lip-val?p=object-contextual-representations-for)\n\n[![PWC](https:\u002F\u002Fimg.shields.io\u002Fendpoint.svg?url=https:\u002F\u002Fpaperswithcode.com\u002Fbadge\u002Fobject-contextual-representations-for\u002Fsemantic-segmentation-on-cityscapes)](https:\u002F\u002Fpaperswithcode.com\u002Fsota\u002Fsemantic-segmentation-on-cityscapes?p=object-contextual-representations-for)\n\n\n\u003Ch2>\n\n\t\n```diff\n+ 我们的工作于2018年9月4日星期二提交至arXiv。\n+ 同期的DANet工作于2018年9月9日星期日提交至arXiv。\n+ 如果对您的相关研究讨论有所帮助，我们希望您能在引用中提及我们的工作。\n```\n\u003C\u002Fh2>\n\n## 新闻\n\n- 2021年2月14日 [openseg.pytorch](https:\u002F\u002Fgithub.com\u002Fopenseg-group\u002Fopenseg.pytorch) 支持 **pytorch-1.7、混合精度和分布式训练**。基于 [PaddleClas](https:\u002F\u002Fgithub.com\u002FPaddlePaddle\u002FPaddleClas) 的 ImageNet 预训练权重，我们在 Cityscapes 验证集上达到 **82.78%**，在 PASCAL-Context 验证集上达到 **59.62%**（新的SOTA），在 COCO-Stuff 验证集上达到 **45.20%**（新的SOTA）。\n\n\n- 2020年7月15日\n[MMSegmentation](https:\u002F\u002Fgithub.com\u002Fopen-mmlab\u002Fmmsegmentation) 也支持我们的 OCR。我们进一步引入了一种 OCR+ 方法，通过可分离卷积和与 DeepLabv3+ 类似结构的解码器头来增强原始 OCR，从而在 Cityscapes 验证集上实现了强大的单尺度评估性能，达到 **81.0%**。\n\n\n- 2020年7月9日\n[OCR（Spotlight）](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1909.11065.pdf) 和 [SegFix](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2007.04269.pdf) 已被 ECCV-2020 接受。值得注意的是，Nvidia 的研究人员通过将我们的 HRNet + OCR 与一种新的 [层次化多尺度注意力机制](https:\u002F\u002Farxiv.org\u002Fabs\u002F2005.10821) 结合，在 Cityscapes 排行榜上创造了新的 SOTA 记录：[85.4%](https:\u002F\u002Fwww.cityscapes-dataset.com\u002Fmethod-details\u002F?submissionID=7836)。\n\n- 2020年4月16日\n我们已在 [openseg.pytorch](https:\u002F\u002Fgithub.com\u002Fopenseg-group\u002Fopenseg.pytorch) 中发布了 OCNet、OCR 和 SegFix 的部分检查点及日志文件。感谢您的耐心等待。\n\n- 2020年1月13日\n用于复现 [HRNet+OCR](https:\u002F\u002Fgithub.com\u002FHRNet\u002FHRNet-Semantic-Segmentation\u002Ftree\u002FHRNet-OCR) 的源代码已公开。\n\n- 2020年1月9日\n“HRNet + OCR + SegFix” 以 mIoU **84.5%** 的成绩位列 Cityscapes 排行榜第1名。\n\n- 2020年1月7日\n“HRNet+OCR[Mapillary+Coarse]” 目前通过更好的 Mapillary 预训练，达到了 **84.26%** 的成绩。我们使用原始 Mapillary 训练数据对 HRNet+OCR 模型进行预训练，并在 Mapillary 验证集上取得了 **50.8%** 的表现。我们的训练设置如下：50万次迭代，批次大小为16，裁剪尺寸为1024x1024。我们认为，借鉴近期 Panoptic-DeepLab 的更高成本训练策略，我们的方法有望进一步提升性能。结合我们新颖的后处理机制，未来有望取得更高的效果。\n\n- 2019年11月28日\n我们将在未来一周内发布所有 [openseg.pytorch](https:\u002F\u002Fgithub.com\u002FPkuRainBow\u002Fopenseg.pytorch) 代码，为社区提供一个强大的基准，该库支持我们所有的 OCNet 系列模型。此外，我们还在 [HRNet-Semantic-Segmentation](https:\u002F\u002Fgithub.com\u002FHRNet\u002FHRNet-Semantic-Segmentation\u002Ftree\u002Fpytorch-v1.1) 代码库中提供了 OCR 的支持。\n\n- 2019年11月20日\n我们更新了论文 [OCR](https:\u002F\u002Farxiv.org\u002Fabs\u002F1909.11065)，这是我们以 **第2名** 成绩进入 Cityscapes 排行榜的方法。通过一种简单的新型后处理方案，我们能够达到 **84.0%** 的成绩。\n\n- 2019年7月31日\n我们发布了论文 [ISA](https:\u002F\u002Farxiv.org\u002Fabs\u002F1907.12273)，该方法非常易于使用和实现，同时比传统的基于自注意力的 OCNet 或 DANet 更加高效。\n\n- 2019年7月23日\n我们以单模型的成绩在 Cityscapes 排行榜上获得了 **第1名**，相关结果将很快公布。\n\n- 2019年7月14日\n我们基于单模型 HRNet48V2 + OCR [无任何技巧的训练]，在 Cityscapes 排行榜上取得了 **83.3116%+** 的成绩。更多细节将在我们的新代码库 [openseg.pytorch](https:\u002F\u002Fgithub.com\u002Fopenseg-group\u002Fopenseg.pytorch) 中分享。\n\n- 2019年5月27日\n我们强烈建议您给我们的新代码库 [openseg.pytorch](https:\u002F\u002Fgithub.com\u002Fopenseg-group\u002Fopenseg.pytorch) 点个赞，因为我们的方法在所有6个基准测试中均达到 SOTA 水平，并且比之前的最佳方法高出1%~2%。\n\n\n![OCNet整体框架](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fopenseg-group_OCNet.pytorch_readme_5af433281e82.png)\n\n请在此处查看更新后的论文 [OCNet](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1809.00916.pdf)。\n\n\n欢迎您与朋友分享我们的工作。[知乎分享](https:\u002F\u002Fzhuanlan.zhihu.com\u002Fp\u002F43902175)\n\n如果您觉得我们的工作对您有帮助，请考虑引用：\n\n```\n@article{YuanW18,\n  title={Ocnet: 用于场景解析的对象上下文网络},\n  author={袁宇辉、王井东},\n  booktitle={arXiv预印本 arXiv:1809.00916},\n  year={2018}\n}\n\n@article{HuangYGZCW19,\n  title={用于语义分割的交错稀疏自注意力},\n  author={黄朗、袁宇辉、郭建元、张超、陈锡林、王井东},\n  booktitle={arXiv预印本 arXiv:1907.12273},\n  year={2019}\n}\n\n@article{YuanCW20,\n  title={用于语义分割的对象上下文表示},\n  author={袁宇辉、陈锡林、王井东},\n  booktitle={ECCV},\n  year={2020}\n}\n\n@article{YuanXCW20,\n  title={SegFix：面向分割的模型无关边界精修},\n  author={袁宇辉、谢静怡、陈锡林、王井东},\n  booktitle={ECCV},\n  year={2020}\n}\n```\n\n## 引言\n\n上下文对于各种计算机视觉任务至关重要。最先进的场景解析方法已经充分利用了图像级别定义的上下文信息。这种上下文包含了属于不同类别的物体的混合信息。\n\n根据每个像素的标签被定义为其所属物体的类别这一事实，我们提出了对象上下文，它考虑的是属于同一类别的物体。任意像素P的对象上下文表示为与P属于同一类别的所有像素特征的聚合。由于预先估计所有属于同一类别的物体是不现实的，我们采用自注意力机制，通过学习像素级相似度图来近似这些物体。\n\n我们进一步提出了金字塔对象上下文和空洞空间金字塔对象上下文，以捕捉多尺度的上下文信息。基于对象上下文，我们引入了OCNet，并证明OCNet在Cityscapes基准和ADE20K基准上均达到了最先进的性能。\n\n\n## 学习到的对象上下文可视化\n![使用OCNet学习到的对象上下文](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fopenseg-group_OCNet.pytorch_readme_6253344e713b.jpg)\n\n## 实验结果\n我们的所有实现都基于PyTorch，OCNet在Cityscapes和ADE20K等多个基准上无需任何额外技巧即可达到具有竞争力的性能。\n\n目前仅使用精细标注数据集训练的OCNet在Cityscapes测试集上的性能如下：\n\n(**修复多尺度测试的bug**)\n\n\n方法 | 会议 | 主干网络 | mIoU(%)\n---- | --- | --- | ---\nRefineNet | CVPR2017 | ResNet-101 | 73.6\nSAC | ICCV2017 | ResNet-101 | 78.1\nPSPNet | CVPR2017 | ResNet-101 | 78.4\nDUC-HDC | WACV2018 | ResNet-101 | 77.6\nAAF | ECCV2018 | ResNet-101 | 77.1\nBiSeNet | ECCV2018 | ResNet-101 | 78.9\nPSANet | ECCV2018 | ResNet-101 | 80.1\nDFN | CVPR2018 | ResNet-101 | 79.3\nDSSPN | CVPR2018 | ResNet-101 | 77.8\nDenseASPP | CVPR2018 | DenseNet-161 | 80.6\n**OCNet** | - | ResNet-101 | **81.7**\n**Fast-OCNet** | - | ResNet-101 | **82.1**\n\nOCNet在ADE20K验证集上的当前性能如下：\n\n\n方法 | 会议 | 主干网络 | mIoU(%)\n---- | --- | --- | ---\nRefineNet | CVPR2017 | ResNet-152 | 40.70\nPSPNet | CVPR2017 | ResNet-101 | 43.29\nSAC | ICCV2017 | ResNet-101 | 44.30\nPSANet | ECCV2018 | ResNet-101 | 43.77\nEncNet | CVPR2018 | ResNet-101 | 44.65\n**OCNet** | - | ResNet-101 | **45.45**\n\n\nOCNet在LIP验证集上的当前性能如下。我们简单地将[CE2P](https:\u002F\u002Fgithub.com\u002Fliutinglt\u002FCE2P)框架中的PSP模块替换为ASP-OC模块。\n\n方法 | 会议 | 主干网络 | 验证集mIoU(%)\n---- | --- | --- | ---\nAttention+SSL | CVPR2017 | ResNet-101 | 44.73\nSS-NAN | CVPR2017 | ResNet-101 | 47.92\nMMAN | ECCV2018 | ResNet-101 | 46.81\nMuLA | ECCV2018 | ResNet-101 | 49.30\nJPPNet | PAMI2018 | ResNet-101 | 51.37\nCE2P | AAAI2019 | ResNet-101 | 53.10\n**OCNet** | - | ResNet-101 | **54.72**\n\n\n## 环境\n代码是在Ubuntu 16.04系统上使用gcc5.4.0、Python 3.6+和CUDA8.0+开发的。需要NVIDIA GPU。代码使用4块NVIDIA P100 GPU进行测试。所有Cityscapes上的实验均在PyTorch 0.4.1上进行。\n\n如果您只能访问TITAX Pascal \u002F TITAN-1080Ti GPU，建议您修改base-oc中的参数**size**：\n\n```\nself.context = nn.Sequential(\n            nn.Conv2d(2048, 512, kernel_size=3, stride=1, padding=1),\n            InPlaceABNSync(512),\n            BaseOC_Module(in_channels=512, out_channels=512, key_channels=256, value_channels=256, \n            dropout=0.05, sizes=([2]))\n            )\n```\n\n## 快速入门\n\n\n### 要求\n~~~~\ntorch=0.4.1\ntorchvision\ntensorboardX\npillow\ntqdm\nh5py\nscikit-learn\ncv2\n~~~~\n\n只需使用**pip install torch torchvision**安装官方PyTorch即可。\n\n我们主要基于官方PyTorch 0.4.1测试所有结果。\n\n\n\n### 训练\u002F验证\u002F测试OCNet（Cityscapes）\n\n为了方便起见，我们将训练、验证和测试集成在一个脚本中。运行此脚本即可获得所有结果。\n\n~~~~\nsh run_asp_oc.sh\n~~~~\n\n预计在验证集上可达到约79.5的mIoU，在测试集上可达到约78.3的mIoU（单尺度）。\n\n也建议尝试**run_base_oc.sh**，该脚本同样可以在验证集上达到约79.3的mIoU，在测试集上达到约78.1的mIoU（单尺度）。\n\n为进一步提升性能，可以采用**CriterionOhemDSN_single**，设置如下：\n\n~~~~\nUSE_OHEM=True\nOHEMTHRES=0.7\nOHEMKEEP=100000\n~~~~\n\n这样预计在验证集上可达到约80.4的mIoU，在测试集上可达到约79.0的mIoU（单尺度）。\n\n要达到测试集上的81.2，需先用训练集和验证集共同训练模型8万次（多尺度+翻转情况下测试集可达约80.5），然后再用固定学习率（1e-4）对该模型进行10万次微调。我们相应地采用了在线困难样本挖掘方法。\n\n\n## 数据准备\n\n对于Cityscapes数据集，请从Cityscapes官网下载数据集。将所有图像解压到“.\u002FOCNet\u002Fdataset\u002Fcityscapes”路径下。确保文件夹“.\u002FOCNet\u002Fdataset\u002Fcityscapes”内的目录结构如下：\n\n```\n|-- README\n|-- get_cs_extra.sh\n|-- gtCoarse\n|   |-- README\n|   |-- license.txt\n|   |-- train\n|   |-- train_extra\n|   `-- val\n|-- gtFine\n|   |-- README\n|   |-- license.txt\n|   |-- test\n|   |-- train\n|   `-- val\n|-- leftImg8bit\n|   |-- README\n|   |-- license.txt\n|   |-- test\n|   |-- train\n|   |-- train_extra\n|   `-- val\n|-- license.txt\n`-- tree.txt\n```\n## 预训练模型\n\n请将预训练模型放在“.\u002FOCNet\u002Fpretrained_model”文件夹下。\n\n[ImageNet预训练ResNet-101](http:\u002F\u002Fsceneparsing.csail.mit.edu\u002Fmodel\u002Fpretrained_resnet\u002Fresnet101-imagenet.pth)\n\n## 包含环境的Docker镜像\n\n[rainbowsecret\u002Fpytorch04:20180719](https:\u002F\u002Fhub.docker.com\u002Fr\u002Frainbowsecret\u002Fpytorch04\u002Ftags\u002F)\n\n## 其他问题（验证集与测试集之间的性能差距）\n我们发现train类别的mIoU有时不稳定。例如，我们运行代码5次，其中有一次train类别的mIoU为0.42，而另外4次则为0.75。\n\n此外，验证集和测试集的准确率之间也存在一些差异。例如，如果两次运行base-oc方法，可能会分别在验证集上得到79.3和79.8的mIoU，而在测试集上则分别为78.55和77.69。因此，如果您希望在测试集上取得良好性能，我建议您多次运行我们的方法；尽管如此，由于训练\u002F验证集与测试集之间的分布差异，我们的方法在验证集上表现得相当稳健。\n\n## 致谢\n本项目基于[Zilong Huang](https:\u002F\u002Fgithub.com\u002Fspeedinghzl)提供的复现版Deeplabv3、PSPNet（PyTorch）构建，相关代码的版权仍归Zilong Huang所有。\n\n## 感谢第三方库\n[InplaceABN](https:\u002F\u002Fgithub.com\u002Fmapillary\u002Finplace_abn)\n\n[Non-local_pytorch](https:\u002F\u002Fgithub.com\u002FAlexHex7\u002FNon-local_pytorch).\n\n[Pytorch-Deeplab](https:\u002F\u002Fgithub.com\u002Fspeedinghzl\u002FPytorch-Deeplab)\n\n[PyTorch-Encoding](https:\u002F\u002Fgithub.com\u002Fzhanghang1989\u002FPyTorch-Encoding)\n\n[semantic-segmentation-pytorch](https:\u002F\u002Fgithub.com\u002FCSAILVision\u002Fsemantic-segmentation-pytorch)","# OCNet.pytorch 快速上手指南\n\nOCNet (Object Context Network) 是一个用于场景解析（语义分割）的 PyTorch 开源项目，通过引入“对象上下文”机制，在 Cityscapes、ADE20K 等基准测试中取得了优异的性能。\n\n## 环境准备\n\n本项目基于 Ubuntu 16.04 开发，需要 NVIDIA GPU 支持。官方测试环境如下：\n\n*   **操作系统**: Ubuntu 16.04\n*   **编译器**: gcc 5.4.0+\n*   **Python**: 3.6+\n*   **CUDA**: 8.0+\n*   **GPU**: 推荐 4x NVIDIA P100。若使用 TITAN X Pascal 或 TITAN 1080Ti，需修改代码中的 `size` 参数（详见原文注意事项）。\n*   **PyTorch 版本**: 官方主要基于 **PyTorch 0.4.1** 进行测试（注意版本兼容性）。\n\n### 依赖安装\n\n建议使用国内镜像源加速安装。首先安装基础依赖：\n\n```bash\npip install torch==0.4.1 torchvision tensorboardX pillow tqdm h5py scikit-learn opencv-python -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n```\n\n> **注意**：如果无法直接安装特定版本的 torch，请访问 [PyTorch 官网历史版本页面](https:\u002F\u002Fpytorch.org\u002Fget-started\u002Fprevious-versions\u002F) 获取对应 CUDA 版本的安装命令。\n\n## 安装步骤\n\n1.  **克隆仓库**\n    ```bash\n    git clone https:\u002F\u002Fgithub.com\u002FPkuRainBow\u002FOCNet.pytorch.git\n    cd OCNet.pytorch\n    ```\n\n2.  **数据集准备 (以 Cityscapes 为例)**\n    *   从 [Cityscapes 官网](https:\u002F\u002Fwww.cityscapes-dataset.com\u002F) 下载数据集。\n    *   将解压后的数据放置在 `.\u002FOCNet\u002Fdataset\u002Fcityscapes` 目录下。\n    *   确保目录结构如下：\n        ```text\n        .\u002FOCNet\u002Fdataset\u002Fcityscapes\u002F\n        ├── gtFine\u002F\n        │   ├── train\u002F\n        │   ├── val\u002F\n        │   └── test\u002F\n        ├── leftImg8bit\u002F\n        │   ├── train\u002F\n        │   ├── val\u002F\n        │   └── test\u002F\n        └── ...\n        ```\n\n## 基本使用\n\n项目提供了封装好的脚本，可一键完成训练、验证和测试。\n\n### 1. 快速开始 (ASP-OC 模块)\n\n运行以下脚本启动训练（默认使用 ASP-OC 模块）：\n\n```bash\nsh run_asp_oc.sh\n```\n\n*   **预期效果**: 单尺度评估下，验证集 mIoU 约 **79.5%**，测试集 mIoU 约 **78.3%**。\n\n### 2. 备选方案 (Base-OC 模块)\n\n也可尝试基础版本脚本：\n\n```bash\nsh run_base_oc.sh\n```\n\n*   **预期效果**: 单尺度评估下，验证集 mIoU 约 **79.3%**，测试集 mIoU 约 **78.1%**。\n\n### 3. 进阶优化 (使用 OHEM)\n\n为了进一步提升性能，可在配置中启用在线难例挖掘 (OHEM)。请在相关配置文件或脚本中设置以下参数：\n\n```python\nUSE_OHEM=True\nOHEMTHRES=0.7\nOHEMKEEP=100000\n```\n\n*   **预期效果**: 开启后，单尺度评估下验证集 mIoU 可提升至约 **80.4%**。\n\n### 4. 达到 SOTA 性能提示\n\n若要复现论文中更高的测试集成绩（如 81.2%+），通常需要两阶段训练策略：\n1.  使用训练集和验证集联合训练 80,000 次迭代。\n2.  固定学习率 (1e-4) 微调 100,000 次迭代。\n3.  测试时采用多尺度 + 翻转增强。","某自动驾驶团队正在开发城市道路感知系统，急需提升模型对复杂街景中车辆、行人及交通标志的像素级分割精度。\n\n### 没有 OCNet.pytorch 时\n- **上下文理解缺失**：传统分割网络难以捕捉物体间的全局依赖关系，常将远处的交通灯误识别为红色车辆，导致决策错误。\n- **边界模糊不清**：在处理密集场景（如拥堵路口）时，相邻物体的边缘分割结果粘连严重，无法清晰区分行人和自行车轮廓。\n- **小目标漏检率高**：对于画面中占比极小的路标或锥桶，模型往往直接忽略，造成感知盲区。\n- **调优成本高昂**：为了弥补精度不足，工程师需花费大量时间手动设计后处理规则或堆叠更深的网络，训练收敛缓慢。\n\n### 使用 OCNet.pytorch 后\n- **全局语境增强**：利用对象上下文表示（OCR）模块，模型能准确理解“车在路上、人在人行道”的空间逻辑，大幅降低类别误判。\n- **边缘细节锐化**：在 Cityscapes 等基准测试中验证的强大数据表征能力，使物体边界切割更加精准，有效分离紧邻目标。\n- **小目标感知提升**：通过聚合多尺度上下文信息，显著提升了对远处小型交通设施的识别率，消除关键感知盲点。\n- **研发效率飞跃**：直接复用其在多个榜单达到 SOTA 的预训练权重与架构，团队无需从零摸索，快速将 mIoU 指标提升至生产可用水平。\n\nOCNet.pytorch 通过引入先进的对象上下文机制，从根本上解决了复杂场景下语义分割的歧义性问题，让自动驾驶感知系统看得更清、更准。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fopenseg-group_OCNet.pytorch_6253344e.jpg","openseg-group","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fopenseg-group_4d96be4d.png","",null,"researcher.yuanyuhui@gmail.com","https:\u002F\u002Fgithub.com\u002Fopenseg-group",[81,85,89,93,97],{"name":82,"color":83,"percentage":84},"Python","#3572A5",75.8,{"name":86,"color":87,"percentage":88},"Cuda","#3A4E3A",9.3,{"name":90,"color":91,"percentage":92},"C++","#f34b7d",7.6,{"name":94,"color":95,"percentage":96},"Shell","#89e051",6.2,{"name":98,"color":99,"percentage":100},"C","#555555",1.1,813,126,"2026-04-08T04:50:04","MIT","Linux","必需 NVIDIA GPU。测试环境为 4x NVIDIA P100。若使用 TITAN X Pascal 或 TITAN 1080Ti，需修改代码参数。要求 CUDA 8.0+。","未说明",{"notes":109,"python":110,"dependencies":111},"开发环境基于 Ubuntu 16.04 和 GCC 5.4.0。代码主要在 PyTorch 0.4.1 版本上测试通过。如果使用显存较小的显卡（如 TITAN X Pascal 或 1080Ti），需要手动修改 base-oc 模块中的'sizes'参数以适应显存限制。","3.6+",[112,113,114,115,116,117,118,119],"torch==0.4.1","torchvision","tensorboardX","pillow","tqdm","h5py","scikit-learn","cv2",[15],"2026-03-27T02:49:30.150509","2026-04-18T22:33:43.433843",[124,129,134,139,144,148,153],{"id":125,"question_zh":126,"answer_zh":127,"source_url":128},40764,"如何进一步提升模型性能以达到论文报告的指标？","可以通过启用 OHEM（在线难例挖掘）来进一步提升性能。具体配置如下：设置 `USE_OHEM=True`，`OHEMTHRES=0.7`，`OHEMKEEP=100000`。启用后，预期在验证集上达到约 80.4 mIoU，在测试集（单尺度）上达到约 79.0 mIoU。此外，建议多次运行实验以确保结果的稳定性，因为 Cityscapes 数据集可能存在某些类别（如火车、公交车或卡车）表现较差的情况。","https:\u002F\u002Fgithub.com\u002Fopenseg-group\u002FOCNet.pytorch\u002Fissues\u002F22",{"id":130,"question_zh":131,"answer_zh":132,"source_url":133},40765,"推理脚本中多尺度测试的缩放比例（scale）为何不生效？","这是一个已知的代码逻辑问题。在 `generate_submit.py` 的 `predict_whole_img` 函数中，原始代码仅在 `scale > 1` 时才对图像进行缩放，导致小于 1 的尺度（如 0.75x）被忽略。虽然代码中存在此 bug，但维护者确认原始设计的意图是支持 `[0.75x, 1x, 1.25x]` 这三个尺度。用户在使用时需确保修改代码逻辑，使其在 `scale != 1` 时均执行缩放操作，或者直接应用官方后续修复的版本。","https:\u002F\u002Fgithub.com\u002Fopenseg-group\u002FOCNet.pytorch\u002Fissues\u002F26",{"id":135,"question_zh":136,"answer_zh":137,"source_url":138},40766,"如何在训练自定义数据集时计算损失函数的类别权重？","许多用户尝试使用“每个类别的像素频率倒数（1\u002Fpixel frequency）”来计算权重，但效果不佳。目前社区强烈请求维护者提供计算整个数据集类别频率（class_freq）或训练集像素计数（pixel_count）的具体代码脚本。建议在官方未发布专用脚本前，仔细统计训练集中每个类别的像素总数，并尝试不同的加权策略（如中值频率平衡），同时参考官方在 Cityscapes 数据集上的权重计算方式进行调整。","https:\u002F\u002Fgithub.com\u002Fopenseg-group\u002FOCNet.pytorch\u002Fissues\u002F14",{"id":140,"question_zh":141,"answer_zh":142,"source_url":143},40767,"运行时出现 KeyError: 'resnet101_base' 错误如何解决？","该错误是由于网络名称配置不匹配导致的。代码中注册的网络名称是 `'resnet101_baseline'`，而不是 `'resnet101_base'`。解决方法是检查启动脚本或配置文件，将所有的 `'resnet101_base'` 修改为 `'resnet101_baseline'`。建议在修改任何代码前仔细阅读 `network\u002F__init__.py` 文件以了解可用的网络注册名称。","https:\u002F\u002Fgithub.com\u002Fopenseg-group\u002FOCNet.pytorch\u002Fissues\u002F13",{"id":145,"question_zh":146,"answer_zh":147,"source_url":143},40768,"拥有两张 11GB 显存的 GPU（如 2x 1080Ti）时，Batch Size 应该设置为多少？","根据社区用户的实际经验，在拥有两张 11GB 显存的 NVIDIA 1080Ti 显卡时，可以将 `BATCHSIZE` 设置为 2。这通常能保证模型顺利训练而不发生显存溢出（OOM）。具体的 Batch Size 可能还取决于输入图像的分辨率和网络深度，如果遇到显存不足，可尝试进一步减小该数值。",{"id":149,"question_zh":150,"answer_zh":151,"source_url":152},40769,"为什么将 OC 模块放在网络中间层时，学习到的对象上下文变得不可解释？","这种现象是因为对象上下文（Object Context）的可解释性依赖于语义信息的丰富程度。当 OC 模块放置在网络最后（分类器之前）时，特征图包含高级语义信息，因此能准确高亮同类像素。若放在中间层，特征尚处于低级阶段，可能导致上下文关联错误（如点击汽车却高亮道路）。虽然性能可能相近，但若需可视化的可解释性，建议将 base_oc_block 放置在网络末端。如果必须在中间层使用，可以尝试利用真值（GT）导出的对象上下文来辅助训练。","https:\u002F\u002Fgithub.com\u002Fopenseg-group\u002FOCNet.pytorch\u002Fissues\u002F42",{"id":154,"question_zh":155,"answer_zh":156,"source_url":128},40770,"编译扩展时出现 ABI 不兼容警告及 Ninja 构建失败怎么办？","该问题通常由编译器版本与 PyTorch 不兼容引起。警告信息明确指出需要使用与 GCC 4.9 及以上版本 ABI 兼容的编译器。解决方法是安装 GCC 4.9 或更高版本，并确保在编译时使用该编译器。可以参考相关教程（如 gist.github.com\u002Fgoldsborough\u002Fd466f43e8ffc948ff92de7486c5216d6）来安装合适的 GCC 版本，然后重新运行构建命令。",[]]