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

Correct Resize pipeline #211

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Update augmentation.py
  • Loading branch information
makecent committed Jan 11, 2022
commit 880e94bc53ce668e632b7b8dcf07b042b0764b41
19 changes: 9 additions & 10 deletions mmgen/datasets/pipelines/augmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,18 @@ def __call__(self, results):
new_w = min(self.max_size - (self.max_size % self.size_factor),
new_w)
scale = (new_w, new_h)
elif isinstance(self.scale, tuple) and (np.inf in self.scale):
elif isinstance(self.scale, tuple):
# find inf in self.scale, calculate ``scale`` manually
h, w = results[self.keys[0]].shape[:2]
if h < w:
scale = (int(self.scale[-1] / h * w), self.scale[-1])
if np.inf in self.scale:
h, w = results[self.keys[0]].shape[:2]
if h < w:
scale = (int(self.scale[-1] / h * w), self.scale[-1])
else:
scale = (self.scale[-1], int(self.scale[-1] / w * h))
else:
scale = (self.scale[-1], int(self.scale[-1] / w * h))
else:
# direct use the given ones
if mmcv.is_tuple_of(self.scale, int):
scale = self.scale[::-1]
else:
scale = float(self.scale)
else:
scale = float(self.scale)

# here we assume all images in self.keys have the same input size
for key in self.keys:
Expand Down