gpt4 book ai didi

Register custom RPN/ROI in detectron2 registry(在detectron 2注册表中注册自定义RPN/ROI)

转载 作者:bug小助手 更新时间:2023-10-25 22:57:28 27 4
gpt4 key购买 nike



I currently try to get EfficientPS (https://github.com/vincrichard/EfficientPS) running.
When I start the training, the initialisation of the net crashes due to a key error belonging to detectron2.

我目前正在尝试运行EfficientPS(https://github.com/vincrichard/EfficientPS)。当我开始训练时,网络的初始化由于属于Detectron2的关键错误而崩溃。


During execution of the init method of InstanceHead, the calls

在执行InstanceHead的init方法期间,调用


self.rpm = build_proposal_generator(cfg, input_shape)
self.roi_heads = build_roi_heads(cfg, input_shape)

fail with output:

失败,输出:


Traceback (most recent call last):
build-agent-1 | File "/opt/.pycharm_helpers/pydev/pydevd.py", line 1496, in _exec
build-agent-1 | pydev_imports.execfile(file, globals, locals) # execute the script
build-agent-1 | File "/opt/.pycharm_helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
build-agent-1 | exec(compile(contents+"\n", file, 'exec'), glob, loc)
build-agent-1 | File "/opt/project/code/perception/src/panoptic_segmentation/src/training/train_net.py", line 168, in <module>
build-agent-1 | main()
build-agent-1 | File "/opt/project/code/perception/src/panoptic_segmentation/src/training/train_net.py", line 139, in main
build-agent-1 | efficientps = EffificientPS(cfg)
build-agent-1 | File "/opt/project/code/perception/src/panoptic_segmentation/src/efficientps/model.py", line 35, in __init__
build-agent-1 | self.instance_head = InstanceHead(cfg)
build-agent-1 | File "/opt/project/code/perception/src/panoptic_segmentation/src/efficientps/instance_head/instance_head.py", line 22, in __init__
build-agent-1 | self.roi_heads = build_roi_heads(cfg, input_shape)
build-agent-1 | File "/home/carla/.local/lib/python3.8/site-packages/detectron2/modeling/roi_heads/roi_heads.py", line 43, in build_roi_heads
build-agent-1 | return ROI_HEADS_REGISTRY.get(name)(cfg, input_shape)
build-agent-1 | File "/home/carla/.local/lib/python3.8/site-packages/fvcore/common/registry.py", line 71, in get
build-agent-1 | raise KeyError(
build-agent-1 | KeyError: "No object named 'CustomROIHeads' found in 'ROI_HEADS' registry!"

for roi_heads and:

对于ROI_HEADS和:


Traceback (most recent call last):
build-agent-1 | File "/opt/project/code/perception/src/panoptic_segmentation/src/training/train_net.py", line 168, in <module>
build-agent-1 | main()
build-agent-1 | File "/opt/project/code/perception/src/panoptic_segmentation/src/training/train_net.py", line 139, in main
build-agent-1 | efficientps = EffificientPS(cfg)
build-agent-1 | File "/opt/project/code/perception/src/panoptic_segmentation/src/efficientps/model.py", line 35, in __init__
build-agent-1 | self.instance_head = InstanceHead(cfg)
build-agent-1 | File "/opt/project/code/perception/src/panoptic_segmentation/src/efficientps/instance_head/instance_head.py", line 22, in __init__
build-agent-1 | self.rpn = build_proposal_generator(cfg, input_shape=input_shape)
build-agent-1 | File "/home/carla/.local/lib/python3.8/site-packages/detectron2/modeling/proposal_generator/build.py", line 24, in build_proposal_generator
build-agent-1 | return PROPOSAL_GENERATOR_REGISTRY.get(name)(cfg, input_shape)
build-agent-1 | File "/home/carla/.local/lib/python3.8/site-packages/fvcore/common/registry.py", line 71, in get
build-agent-1 | raise KeyError(
build-agent-1 | KeyError: "No object named 'RPNCustom' found in 'PROPOSAL_GENERATOR' registry!"

for rpn.

用于RPN。


I read about the registry in the documentation and it says that the models have to be registered in the registries.
I searched in the code and both models have the required registration call:

我在文档中读到了注册表,它说模型必须在注册表中注册。我在代码中搜索了一下,两款车都有必要的注册电话:


@PROPOSAL_GENERATOR_REGISTRY.register()
class RPNCustom(RPN):

def forward(...):
...

@ROI_HEADS_REGISTRY.register()
class CustomROIHeads(ROIHeads):
...

The corresponding part of the config:

配置的相应部分:


MODEL:
ANCHOR_GENERATOR:
SIZES: [[32], [64], [128], [256]] # One size for each in feature map
ASPECT_RATIOS: [[0.5, 1.0, 2.0]] # Three aspect ratios (same for all in feature maps)
PROPOSAL_GENERATOR:
NAME: "RPNCustom"
RPN:
HEAD_NAME: "DepthwiseSepRPNHead" # Normal RPN Head "StandardRPNHead"
IN_FEATURES: ["P_4", "P_8", "P_16", "P_32"]
PRE_NMS_TOPK_TRAIN: 2000 # Per FPN level
PRE_NMS_TOPK_TEST: 2000 # Per FPN level
BBOX_REG_LOSS_TYPE: "smooth_l1"
BBOX_REG_LOSS_WEIGHT: 1.0
SMOOTH_L1_BETA: 0.11111111 # 1.0 / 9.0

# Detectron1 uses 2000 proposals per-batch,
# (See "modeling/rpn/rpn_outputs.py" for details of this legacy issue)
# which is approximately 1000 proposals per-image since the default batch size for FPN is 2.
POST_NMS_TOPK_TRAIN: 1000
POST_NMS_TOPK_TEST: 1000
SMOOTH_L1_BETA: 0.1111
IOU_THRESHOLDS: [0.3, 0.7]
ROI_HEADS:
NAME: "CustomROIHeads"
# BATCH_SIZE_PER_IMAGE: 256 # number of proposals to sample for training
# POSITIVE_FRACTION: 0.25 # fraction of positive (foreground) proposals to sample for training.
IN_FEATURES: ["P_4", "P_8", "P_16", "P_32"]
NUM_CLASSES: 8 # There is 8 instance in the city scape dataset
# PROPOSAL_APPEND_GT:
IOU_THRESHOLDS: [0.5]
# IOU_LABELS:
SCORE_THRESH_TEST: 0.5 # First step of panoptic fusion module
NMS_THRESH_TEST: 0.5 # Second step of panoptic fusion module
ROI_BOX_HEAD:
POOLER_RESOLUTION: 7
POOLER_SAMPLING_RATIO: 2 # (maybe put to 2) The `sampling_ratio` parameter for the ROIAlign op.
POOLER_TYPE: "ROIAlign" # "ROIAlignV2"
SMOOTH_L1_BETA: 1.0
# SCORE_THRESH_TEST: 0.05
# NMS_THRESH_TEST: 0.5
BBOX_REG_LOSS_TYPE: "smooth_l1"
SMOOTH_L1_BETA: 1.0
BBOX_REG_LOSS_WEIGHT: 1.0
ROI_MASK_HEAD:
POOLER_RESOLUTION: 14
POOLER_TYPE: "ROIAlign"
TEST:
DETECTIONS_PER_IMAGE: 100

I never worked with detectron2 and its registries before, so I don't know what the problem here is.

我以前从未使用过Detectron2及其注册表,所以我不知道这里有什么问题。


更多回答
优秀答案推荐
更多回答

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com