From 83c92ede6519b25c3d4289f6241659e78a369864 Mon Sep 17 00:00:00 2001 From: LLinkedlist <72634327+linkedlist771@users.noreply.github.com> Date: Thu, 26 Mar 2026 19:00:37 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=20move=20mmcv=20-=E3=80=8B=202.0?= =?UTF-8?q?=20fix=20api=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 +++- pyproject.toml | 6 +++++- .../models/model/modules/feat_prop.py | 17 +++-------------- .../models/model/modules/flow_comp.py | 3 ++- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 9f19cc6..d219bac 100644 --- a/.gitignore +++ b/.gitignore @@ -185,4 +185,6 @@ cython_debug/ notebooks resources/checkpoint/ examples -outputs \ No newline at end of file +outputs +.DS_Store +uv.lock \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 4d5780d..4133e99 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,7 +52,8 @@ dependencies = [ "jupyter>=1.1.1", "loguru>=0.7.3", "matplotlib>=3.10.6", - "mmcv-full>=1.7.2", + "mmcv>=2.0.0,<2.3.0", + "mmengine>=0.10,<0.11", "notebook>=7.4.7", "omegaconf>=2.3.0", "opencv-python>=4.12.0.88", @@ -205,6 +206,9 @@ testpaths = [ ] norecursedirs = [] filterwarnings = [] +[tool.uv.extra-build-dependencies] +clip = ["setuptools<82"] +mmcv = ["setuptools<82"] [tool.uv.sources] clip = { git = "https://github.com/openai/CLIP.git" } diff --git a/src/demark_world/models/model/modules/feat_prop.py b/src/demark_world/models/model/modules/feat_prop.py index 03bb625..c82d94c 100644 --- a/src/demark_world/models/model/modules/feat_prop.py +++ b/src/demark_world/models/model/modules/feat_prop.py @@ -4,25 +4,14 @@ import torch import torch.nn as nn +from mmengine.model import constant_init try: - from mmcv.cnn import constant_init from mmcv.ops import ModulatedDeformConv2d, modulated_deform_conv2d -except: +except Exception as exc: from loguru import logger - logger.warning("mmcv is not available, using a fallback implementation") - import torch - import torch.nn as nn - import torch.nn.functional as F - - # Fallback: constant_init function - def constant_init(module, val=0, bias=0): - """Initialize module parameters with constant values.""" - if hasattr(module, "weight") and module.weight is not None: - nn.init.constant_(module.weight, val) - if hasattr(module, "bias") and module.bias is not None: - nn.init.constant_(module.bias, bias) + logger.warning(f"mmcv.ops is not available, using a fallback implementation: {exc}") def _pair(v): if isinstance(v, tuple): diff --git a/src/demark_world/models/model/modules/flow_comp.py b/src/demark_world/models/model/modules/flow_comp.py index 169a3ef..435f860 100644 --- a/src/demark_world/models/model/modules/flow_comp.py +++ b/src/demark_world/models/model/modules/flow_comp.py @@ -3,7 +3,8 @@ import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import ConvModule -from mmcv.runner import load_checkpoint +from mmengine.runner import load_checkpoint + from demark_world.configs import SPYNET_CHECKPOINT_PATH, PHY_NET_CHECKPOINT_REMOTE_URL from demark_world.utils.download_utils import ensure_model_downloaded