mmdeploy icon indicating copy to clipboard operation
mmdeploy copied to clipboard

[Bug] YOLOX is not in the mmengine::model registry (same goes for Yolov7)

Open levrone1987 opened this issue 1 year ago • 0 comments

Checklist

  • [X] I have searched related issues but cannot get the expected help.
  • [X] 2. I have read the FAQ documentation but cannot get the expected help.
  • [X] 3. The bug has not been fixed in the latest version.

Describe the bug

This is my config file:

model = dict(
    type='YOLOX',  # YOLOX architecture
    backbone=dict(type='CSPDarknet', deepen_factor=1.0, widen_factor=1.0),  # YOLOX backbone
    neck=dict(type='YOLOXPAFPN', in_channels=[256, 512, 1024], out_channels=[256, 512, 1024]),
    bbox_head=dict(
        type='YOLOXHead',
        num_classes=1,  # Update this based on the number of classes in your dataset
        in_channels=256,
        feat_channels=256
    ),
    train_cfg=dict(assigner=dict(type='SimOTAAssigner', center_radius=2.5)),
    test_cfg=dict(score_thr=0.01, nms=dict(type='nms', iou_threshold=0.65))
)

The following code lists YOLOX:

from mmdet.registry import MODELS

# Print all available models in the registry
print(MODELS.module_dict.keys())

However, running this code:

from mmengine.config import Config
from mmengine.runner import Runner
from mmdet.utils import register_all_modules

# Register all modules for MMYOLO and MMDetection
register_all_modules()

def train_model(config_file):
    # Load the configuration
    cfg = Config.fromfile(config_file)
    
    # Ensure the working directory for checkpoints and logs
    cfg.work_dir = './checkpoints'  

    # Build the runner
    runner = Runner.from_cfg(cfg)
    
    # Start training
    runner.train()
    print("Training completed! Checkpoints saved to './checkpoints'.")


# Path to your configuration file
config_file = 'configs/yolov7/yolox_subset_coco.py'

# Train the model
train_model(config_file)

produces this error:

KeyError: 'YOLOX is not in the mmengine::model registry. Please check whether the value of `YOLOX` is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/advanced_tutorials/config.html#import-the-custom-module'

Same holds for YOLOv7 model, which is in fact the one I would like to use. What do you think is the error here?

Reproduction

See above

Environment

I followed this for installation:
https://github.com/open-mmlab/mmyolo?tab=readme-ov-file#%EF%B8%8F-installation-

I do not have GPU.

Error traceback

No response

levrone1987 avatar Nov 06 '24 17:11 levrone1987