728x90

이 transform 코드를 실행하니

transform = transforms.Compose([
    Resize((512, 384), Image.BILINEAR), # 문제가 발생한 부분!
    ToTensor(),
    Normalize(mean=(0.5, 0.5, 0.5), std=(0.2, 0.2, 0.2)),
])

아래와 같은 오류가 발생했다.

UserWarning: Argument interpolation should be of type InterpolationMode instead of int. Please, use InterpolationMode enum.
  warnings.warn(

검색해보니 Resize((512, 384), Image.BILINEAR) <- 이부분에서 발생한 문제였고,

Imagetorchvision.transforms.InterpolationMode 로 바꾸면 해결되는 문제였다.

 

따라서 맨 위에 썼던 코드를 이렇게 바꾸면 된다.

transform = transforms.Compose([
    Resize((512, 384), torchvision.transforms.InterpolationMode.BILINEAR),
    ToTensor(),
    Normalize(mean=(0.5, 0.5, 0.5), std=(0.2, 0.2, 0.2)),
])

BILINEAR뿐 아니라 Image.BICUBIC, Image.LANCZOS에 대해서도 마찬가지로 문제를 해결할 수 있다.

 

 

* 참고

 

"Argument interpolation should be of type InterpolationMode instead of int. " · Issue #285 · rosinality/stylegan2-pytorch

Hi, when i try to get datset, i was faced with a problem. 0it [00:00, ?it/s]/usr/local/lib/python3.7/dist-packages/torchvision/transforms/functional.py:405: UserWarning: Argument interpolation shou...

github.com

 

 

 

 

728x90