Giter Site home page Giter Site logo

Comments (4)

xanhug avatar xanhug commented on June 2, 2024

When I tried to mimic ThinkTwice and create a simple model following the mmdet style, I encountered issues related to registration.

#test_config.py

model = dict(
    type='EncoderDecoder'
)
#encoder_decoder_framework.py

from mmcv.runner import BaseModule
from mmdet.models import DETECTORS


@DETECTORS.register_module()
class EncoderDecoder(BaseModule):
    def __init__(self, train_cfg=None,
                test_cfg=None,):
        super().__init__()

    def forward(self):
        print('SimpleModel forward')

#train.py

from mmdet3d.models import build_model
from mmcv import Config, DictAction
import argparse

def parse_args():
    parser = argparse.ArgumentParser(description='Train a decision-maker')
    parser.add_argument('--config', default='open_loop_training/configs/test_config.py', required=False, help='train config file path')
    args = parser.parse_args()
    return args
def main():
    args = parse_args()
    cfg = Config.fromfile(args.config)

    model = build_model(
        cfg.model,
        train_cfg=None,
        test_cfg=None
    )
    print(model)

if __name__ == "__main__":
    main()

Error occurs:

KeyError: 'EncoderDecoder is not in the models registry'

The program runs successfully and the module is registered only when I place encoder_decoder_framework.py in the python3.7/site-packages/mmdet/models/detectors/ folder and make modifications to the __init__.py file in that folder.

# Copyright (c) OpenMMLab. All rights reserved.
from .atss import ATSS
from .autoassign import AutoAssign
from .base import BaseDetector
from .cascade_rcnn import CascadeRCNN
from .centernet import CenterNet
from .cornernet import CornerNet
from .ddod import DDOD
from .deformable_detr import DeformableDETR
from .detr import DETR
from .fast_rcnn import FastRCNN
from .faster_rcnn import FasterRCNN
from .fcos import FCOS
from .fovea import FOVEA
from .fsaf import FSAF
from .gfl import GFL
from .grid_rcnn import GridRCNN
from .htc import HybridTaskCascade
from .kd_one_stage import KnowledgeDistillationSingleStageDetector
from .lad import LAD
from .mask2former import Mask2Former
from .mask_rcnn import MaskRCNN
from .mask_scoring_rcnn import MaskScoringRCNN
from .maskformer import MaskFormer
from .nasfcos import NASFCOS
from .paa import PAA
from .panoptic_fpn import PanopticFPN
from .panoptic_two_stage_segmentor import TwoStagePanopticSegmentor
from .point_rend import PointRend
from .queryinst import QueryInst
from .reppoints_detector import RepPointsDetector
from .retinanet import RetinaNet
from .rpn import RPN
from .scnet import SCNet
from .single_stage import SingleStageDetector
from .solo import SOLO
from .solov2 import SOLOv2
from .sparse_rcnn import SparseRCNN
from .tood import TOOD
from .trident_faster_rcnn import TridentFasterRCNN
from .two_stage import TwoStageDetector
from .vfnet import VFNet
from .yolact import YOLACT
from .yolo import YOLOV3
from .yolof import YOLOF
from .yolox import YOLOX
from .encoder_decoder_framework import EncoderDecoder

__all__ = [
    'ATSS', 'BaseDetector', 'SingleStageDetector', 'TwoStageDetector', 'RPN',
    'KnowledgeDistillationSingleStageDetector', 'FastRCNN', 'FasterRCNN',
    'MaskRCNN', 'CascadeRCNN', 'HybridTaskCascade', 'RetinaNet', 'FCOS',
    'GridRCNN', 'MaskScoringRCNN', 'RepPointsDetector', 'FOVEA', 'FSAF',
    'NASFCOS', 'PointRend', 'GFL', 'CornerNet', 'PAA', 'YOLOV3', 'YOLACT',
    'VFNet', 'DETR', 'TridentFasterRCNN', 'SparseRCNN', 'SCNet', 'SOLO',
    'SOLOv2', 'DeformableDETR', 'AutoAssign', 'YOLOF', 'CenterNet', 'YOLOX',
    'TwoStagePanopticSegmentor', 'PanopticFPN', 'QueryInst', 'LAD', 'TOOD',
    'MaskFormer', 'DDOD', 'Mask2Former', 'EncoderDecoder'
]

However, it seems that in ThinkTwice, there is no modification to the __init__.py file or placement of encoder_decoder_framework.py in a specific folder. Yet, the module is successfully registered and can be called to create models in other files. How is this achieved?

from thinktwice.

xanhug avatar xanhug commented on June 2, 2024

Sorry for taking up your valuable time, and thank you for your potential response.

from thinktwice.

jiaxiaosong1002 avatar jiaxiaosong1002 commented on June 2, 2024

@xanhug Thanks for your interests. We note that some of the modules are not built by mmcv mechanism and we choose the brute-force building directly by Pytorch for fast development.

Besides, make sure you are reading the document of mmcv 1.x version since the latest/default mmcv 2.0/mmengine has made significant API changes.

from thinktwice.

xanhug avatar xanhug commented on June 2, 2024

@xanhug Thanks for your interests. We note that some of the modules are not built by mmcv mechanism and we choose the brute-force building directly by Pytorch for fast development.

Besides, make sure you are reading the document of mmcv 1.x version since the latest/default mmcv 2.0/mmengine has made significant API changes.

thanks for your reply.

from thinktwice.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.