|
@ -15,7 +15,6 @@ |
|
|
from typing import NamedTuple, Union |
|
|
from typing import NamedTuple, Union |
|
|
|
|
|
|
|
|
import torch |
|
|
import torch |
|
|
import numpy as np |
|
|
|
|
|
from PIL import Image |
|
|
from PIL import Image |
|
|
from torchvision import transforms |
|
|
from torchvision import transforms |
|
|
|
|
|
|
|
@ -43,14 +42,14 @@ class TransformImage(Operator): |
|
|
] |
|
|
] |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
def __call__(self, img: Union[np.ndarray, Image.Image, torch.Tensor, str]) -> NamedTuple('Outputs', [('img_transformed', torch.Tensor)]): |
|
|
|
|
|
|
|
|
def __call__(self, img: Union[Image.Image, torch.Tensor, str]) -> NamedTuple('Outputs', [('img_transformed', torch.Tensor)]): |
|
|
""" |
|
|
""" |
|
|
Call it when use this class. |
|
|
Call it when use this class. |
|
|
|
|
|
|
|
|
Args: |
|
|
Args: |
|
|
img(`Union[np.ndarray, Image.Image, torch.Tensor, str]`): |
|
|
|
|
|
|
|
|
img(`Union[mage.Image, torch.Tensor, str]`): |
|
|
The image data to be normalized, you can try one of the |
|
|
The image data to be normalized, you can try one of the |
|
|
four formats: np.ndarray, Image.Image, torch.Tensor and str. |
|
|
|
|
|
|
|
|
four formats: Image.Image, torch.Tensor and str. |
|
|
Returns: |
|
|
Returns: |
|
|
(`torch.Tensor`) |
|
|
(`torch.Tensor`) |
|
|
The normalized image tensor. |
|
|
The normalized image tensor. |
|
|