add compatibility for torchvision>0.10.0

add compatibility for torchvision>0.10.0
        Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/12292460
This commit is contained in:
xianzhe.xxz
2023-04-11 19:59:59 +08:00
committed by yuze.zyz
parent 2c15888084
commit 2fe3812f98

View File

@@ -73,14 +73,25 @@ def _geometric_aug_func(x,
labels_new.append(labels[i])
else:
x_crop = transforms.functional.to_pil_image(x_crop.cpu())
x_crop = transforms.functional.affine(
x_crop,
angle,
translate,
scale,
shear,
resample=2,
fillcolor=tuple([int(i) for i in pixel_mean]))
try:
x_crop = transforms.functional.affine(
x_crop,
angle,
translate,
scale,
shear,
resample=2,
fillcolor=tuple([int(i) for i in pixel_mean]))
except Exception:
x_crop = transforms.functional.affine(
x_crop,
angle,
translate,
scale,
shear,
interpolation=2,
fill=tuple([int(i) for i in pixel_mean]))
x_crop = transforms.functional.to_tensor(x_crop).to(x.device)
x_crops.append(x_crop)
y = _transform(x, x_crops, boxes_crops, translate)