Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix albumentations versions >= 1.4.11 #11870

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions mmdet/datasets/transforms/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@
try:
import albumentations
from albumentations import Compose

# This assumes albumentations' versions are just ints separated by
# periods, e.g. 1.4.11, allowing us to avoid a new dependency.
ALBU_VERSION = tuple(map(int, albumentations.__version__.split('.')))
except ImportError:
albumentations = None
Compose = None
ALBU_VERSION = None

Number = Union[int, float]

Expand Down Expand Up @@ -1627,8 +1632,13 @@ def __init__(self,

self.bbox_params = (
self.albu_builder(bbox_params) if bbox_params else None)
self.aug = Compose([self.albu_builder(t) for t in self.transforms],
bbox_params=self.bbox_params)
if ALBU_VERSION is not None and ALBU_VERSION >= (1, 4, 11):
self.aug = Compose([self.albu_builder(t) for t in self.transforms],
bbox_params=self.bbox_params,
strict=False)
else:
self.aug = Compose([self.albu_builder(t) for t in self.transforms],
bbox_params=self.bbox_params)

if not keymap:
self.keymap_to_albu = {
Expand Down