Skip to content

Commit

Permalink
fix register torchvision.transforms error, AttributeError: 'functools…
Browse files Browse the repository at this point in the history
….partial' object has no attribute '__module__' when call mmengine.registry.count_registered_modules(./)
  • Loading branch information
FelixFu520 committed Nov 1, 2024
1 parent ee7f2e8 commit c0c65f2
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions mmpretrain/datasets/transforms/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ def register_vision_transforms() -> List[str]:
_transform = getattr(torchvision.transforms, module_name)
if inspect.isclass(_transform) and callable(
_transform) and not isinstance(_transform, (EnumMeta)):
from functools import partial
TRANSFORMS.register_module(
module=partial(
TorchVisonTransformWrapper, transform=_transform),
module=lambda name=module_name: TorchVisonTransformWrapper(transform=torchvision.transforms[name], name=name),
name=f'torchvision/{module_name}')
vision_transforms.append(f'torchvision/{module_name}')
return vision_transforms
Expand Down

0 comments on commit c0c65f2

Please sign in to comment.