PaddlePaddle / PaddleDetection

Object Detection toolkit based on PaddlePaddle. It supports object detection, instance segmentation, multiple object tracking and real-time multi-person keypoint detection.
Apache License 2.0
12.75k stars 2.88k forks source link

register注册器机制的疑问? #5039

Closed wstchhwp closed 2 years ago

wstchhwp commented 2 years ago
# 注册模块类
def register(cls):
    """
    注册给定的模块类
    Args:
        cls (type): Module class to be registered.
    Returns: cls
    """
    if cls.__name__ in global_config:
        raise ValueError("Module class already registered: {}".format(cls.__name__))

    # cls里面如果有这个__op__属性
    if hasattr(cls, '__op__'):
        cls = make_partial(cls)

    # cls: <class 'ppdet.data.source.coco.COCODataSet'>
    # cls__name__: COCODataSet
    global_config[cls.__name__] = extract_schema(cls)
    print("xxxxxxxxxxxxxxxxxxxxxxxxxxxx")
    print(global_config)
    return cls

逐步打印global_config发现,字典里面元素原来越多,但是全是空的key-value。但是我在看模式提取函数extract_schema的时候,发现里面是把init参数逐渐添加到字典里面的,为啥返回的字典key_value中,value全是空的。 {'ImageFolder': {}, 'COCODataSet': {}, 'VOCDataSet': {}, 'WIDERFaceDataSet': {}, 'KeypointBottomUpCocoDataset': {}, 'KeypointBottomUpCrowdPoseDataset': {}, 'KeypointTopDownCocoDataset': {}, 'KeypointTopDownMPIIDatase t': {}, 'MOTDataSet': {}, 'MCMOTDataSet': {}, 'MOTImageFolder': {}, 'SniperCOCODataSet': {}, 'VGG': {}, 'ResNet': {}, 'Res5Head': {}, 'DarkNet': {}, 'MobileNet': {}, 'MobileNetV3': {}, 'HRNet': {}, 'AnchorGeneratorSS D': {}, 'RCNNBox': {}, 'MultiClassNMS': {}, 'MatrixNMS': {}, 'YOLOBox': {}, 'SSDBox': {}, 'AnchorGrid': {}, 'FCOSBox': {}, 'TTFBox': {}, 'JDEBox': {}, 'MaskMatrixNMS': {}, 'ConvMixer': {}, 'LiteHRNet': {}, 'BlazeNet' : {}, 'GhostNet': {}, 'SENet': {}, 'SERes5Head': {}, 'Res2Net': {}, 'Res2NetC5': {}, 'DLA': {}, 'ShuffleNetV2': {}, 'SwinTransformer': {}, 'LCNet': {}, 'HarDNet': {}, 'ESNet': {}, 'FPN': {}, 'YOLOv3FPN': {}, 'PPYOLOF PN': {}, 'PPYOLOTinyFPN': {}, 'PPYOLOPAN': {}, 'HRFPN': {}, 'TTFFPN': {}, 'CenterNetDLAFPN': {}, 'CenterNetHarDNetFPN': {}, 'BiFPN': {}, 'CSPPAN': {}, 'BlazeNeck': {}, 'AnchorGenerator': {}, 'RPNTargetAssign': {}, 'B BoxAssigner': {}, 'BBoxLibraAssigner': {}, 'MaskAssigner': {}, 'RBoxAssigner': {}, 'ProposalGenerator': {}, 'RPNHead': {}, 'RoIAlign': {}, 'TwoFCHead': {}, 'XConvNormHead': {}, 'BBoxHead': {}, 'MaskFeat': {}, 'MaskHe ad': {}, 'YOLOv3Head': {}, 'SSDHead': {}, 'FCOSFeat': {}, 'FCOSHead': {}, 'SOLOv2MaskHead': {}, 'SOLOv2Head': {}, 'HMHead': {}, 'WHHead': {}, 'TTFHead': {}, 'CascadeTwoFCHead': {}, 'CascadeXConvNormHead': {}, 'Cascad eHead': {}, 'FaceHead': {}, 'S2ANetHead': {}, 'HrHRNetHead': {}, 'YOLOv3Loss': {}, 'IouLoss': {}, 'GIoULoss': {}, 'DIouLoss': {}, 'IouAwareLoss': {}, 'SSDLoss': {}, 'FCOSLoss': {}, 'SOLOv2Loss': {}, 'CTFocalLoss': {} , 'KeyPointMSELoss': {}, 'HrHRNetLoss': {}, 'JDEDetectionLoss': {}, 'JDEEmbeddingLoss': {}, 'JDELoss': {}, 'FairMOTLoss': {}, 'QualityFocalLoss': {}, 'DistributionFocalLoss': {}, 'PositionEmbedding': {}, 'DETRTransfo rmer': {}, 'HungarianMatcher': {}, 'DeformableTransformer': {}, 'DETRLoss': {}, 'SparseRCNNLoss': {}, 'CenterNetHead': {}, 'DGQP': {}, 'GFLHead': {}, 'OTAHead': {}, 'OTAVFLHead': {}, 'PicoFeat': {}, 'PicoHead': {}, ' DETRHead': {}, 'DeformableDETRHead': {}, 'SparseRCNNHead': {}, 'TOODHead': {}, 'BaseArch': {}, 'FasterRCNN': {}, 'MaskRCNN': {}, 'BBoxPostProcess': {}, 'MaskPostProcess': {}, 'FCOSPostProcess': {}, 'S2ANetBBoxPostPro cess': {}, 'JDEBBoxPostProcess': {}, 'CenterNetPostProcess': {}, 'DETRBBoxPostProcess': {}, 'SparsePostProcess': {}, 'YOLOv3': {}, 'CascadeRCNN': {}, 'SSD': {}, 'FCOS': {}, 'SOLOv2': {}, 'TTFNet': {}, 'S2ANet': {}, ' HigherHRNet': {}, 'HrHRNetPostProcess': {}, 'TopDownHRNet': {}, 'JDE': {}, 'KalmanFilter': {}, 'BaseTrack': {}, 'STrack': {}, 'Track': {}, 'JDETracker': {}, 'DeepSORTTracker': {}, 'DeepSORT': {}, 'FairMOT': {}, 'Cent erNet': {}, 'GFL': {}, 'PicoDet': {}, 'DETR': {}, 'SparseRCNN': {}, 'TOOD': {}, 'BlazeFace': {}, 'JDEEmbeddingHead': {}, 'FairMOTEmbeddingHead': {}, 'PCBPyramid': {}, 'PPLCNetEmbedding': {}, 'TaskAlignedAssigner': {} , 'ATSSAssigner': {}, 'VarifocalLoss': {}, 'SimOTAAssigner': {}, 'TrainReader': {}, 'EvalReader': {}, 'TestReader': {}, 'EvalMOTReader': {}, 'TestMOTReader': {}, 'LearningRate': {}, 'OptimizerBuilder': {}, 'Pruner': {}, 'QAT': {}, 'PTQ': {}, 'DistillYOLOv3Loss': {}, 'UnstructuredPruner': {}}

wangxinxin08 commented 2 years ago

这个里面不是空,只不过没有定义内容的__repr__方法,所以没有显示

paddle-bot-old[bot] commented 2 years ago

Since this issue has not been updated for more than three months, it will be closed, if it is not solved or there is a follow-up one, please reopen it at any time and we will continue to follow up. It is recommended to pull and try the latest code first. 由于该问题超过三个月未更新,将会被关闭,若问题未解决或有后续问题,请随时重新打开(建议先拉取最新代码进行尝试),我们会继续跟进。