MMdetection中的注册register和build 以及Hook的register和build

商汤开源目标检测工具箱mmdetection代码详解(一)—— build和Registry和配置信息,分析mmedetection如何动态构建网络_ZJE-CSDN博客_商汤mmdetection 我们在看mmdetection源码时,首先肯定找主函数main()在哪。主函数在 tool/train.py 里。然后我们遇到第一个疑惑的就会是build_detector(),然后往下看,还会 有一堆类似的,例如 build_dataset(),build_backbone(),build_neck(),build_loss()等等。我们暂时称这些为”build系列”,那我们以build_detector()为例子,看看它是怎么”build”的。…MMdetection中的注册register和build 以及Hook的register和buildhttps://blog.csdn.net/u014453898/article/details/106267173/; 目标检测(MMdetection)-HOOK机制 – 知乎最近做了一段时间的目标检测,不得不说检测这块还是相对比较复杂的,在熟悉项目的同时也确实学习到了很多有用的东西。 MMdetetion是现在最著名、算法包最多并且使用人数最多的训练框架,其中的源码非常值得学习,…MMdetection中的注册register和build 以及Hook的register和buildhttps://zhuanlan.zhihu.com/p/238130913 ;

目标检测(MMDetection)-Registry – 知乎目标检测(MMDetection)-Registry 工作日趋繁忙,上一篇讲HOOK的文章获得了大家的赞同受宠若惊,虽然才疏学浅,今天就接着上次的内容,讲一下MMDetection中注册器Registry,希望能帮助到大家理解这个框架。 1. Regi…MMdetection中的注册register和build 以及Hook的register和buildhttps://zhuanlan.zhihu.com/p/260919755 ;

mmdetection源码阅读笔记:Registry – 知乎其余内容见: mmdetection阅读笔记:(一)概览一提到mmdetection的核心组件,一定离不开它的注册器机制Registry(定义在mmcv中),回答两个问题,为什么需要Registry?Registry是怎么设计的? 为什么需要Registry…MMdetection中的注册register和build 以及Hook的register和buildhttps://zhuanlan.zhihu.com/p/444205206?utm_source=wechat_session&utm_medium=social&utm_oi=979707863623516160&utm_campaign=shareopn ;

参考上面4篇

一/注册register和build

1. 创建为models的注册表全局变量。dataset;runner;hook等都是同样的机制进行注册的 (训练时
from mmdet.models import build_detector的import功能将mmdetection中的各种类进行了注册,使注册表中被注册各种类)

MMdetection中的注册register和build 以及Hook的register和build

第四篇博客链接写道:

MMdetection中的注册register和build 以及Hook的register和build

MMdetection中的注册register和build 以及Hook的register和build

MMdetection中的注册register和build 以及Hook的register和build

MMdetection中的注册register和build 以及Hook的register和build

MMdetection中的注册register和build 以及Hook的register和build

MMdetection中的注册register和build 以及Hook的register和build

MMdetection中的注册register和build 以及Hook的register和build
@BACKBONES.register_module()是修饰器功能,
2. 将PyramidVisionTransformerV2类放入注册表全局变量中 训练时需要使用时build_from_cfg进行实例化,该函数中有实例化语句

MMdetection中的注册register和build 以及Hook的register和build

二/ HOOK除了register和build实例化以外,还需要创建一个优先级_hook列表

hook机制除了进行register和build实例化以外,还需要创建一个优先级_hook列表,训练等使用。

hook类的定义为:

MMdetection中的注册register和build 以及Hook的register和build

hook在runner里面进行实例化操作和将该hook注册进入创建一个优先级_hook列表:

MMdetection中的注册register和build 以及Hook的register和build

路径:mmcv\runner\base_runner.py

hook在runner里面进行实例化操作:

MMdetection中的注册register和build 以及Hook的register和build

将该hook注册进入创建一个优先级_hook列表:

MMdetection中的注册register和build 以及Hook的register和build

根据各种hook的优先级将其加入到self._hooks的列表中

MMdetection中的注册register和build 以及Hook的register和build

MMdetection中的注册register和build 以及Hook的register和build

使用hook列表时:call_hook

MMdetection中的注册register和build 以及Hook的register和build

getattr(hook, fn_name)(self) 中的self就是实例化的runner,传入实例化的hook中。hook中的每一个函数都是含有参数runner的。

MMdetection中的注册register和build 以及Hook的register和build

MMdetection中的注册register和build 以及Hook的register和build

Original: https://blog.csdn.net/liuyang_xyz/article/details/122327975
Author: liuyang_xyz
Title: MMdetection中的注册register和build 以及Hook的register和build

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/682954/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球