From 5ea21f2424830871401d5a978a48815b46cc17af Mon Sep 17 00:00:00 2001
From: Qian Zhao <112053249+C1rN09@users.noreply.github.com>
Date: Sun, 4 Dec 2022 10:40:48 +0800
Subject: [PATCH] [Fix] Fix hub.get_model failure on some mmcls models (#784)

---
 mmengine/hub/hub.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mmengine/hub/hub.py b/mmengine/hub/hub.py
index b7b0d4ad..b24ac2c1 100644
--- a/mmengine/hub/hub.py
+++ b/mmengine/hub/hub.py
@@ -75,6 +75,8 @@ def get_model(cfg_path: str, pretrained: bool = False, **kwargs):
     package = cfg_path.split('::')[0]
     with DefaultScope.overwrite_default_scope(package):  # type: ignore
         cfg = get_config(cfg_path, pretrained)
+        if 'data_preprocessor' in cfg:
+            cfg.model.data_preprocessor = cfg.data_preprocessor
         models_module = importlib.import_module(f'{package}.utils')
         models_module.register_all_modules()  # type: ignore
         model = MODELS.build(cfg.model, default_args=kwargs)
-- 
GitLab