logo
Browse Source

Update

Signed-off-by: shiyu22 <shiyu.chen@zilliz.com>
main
shiyu22 3 years ago
parent
commit
d60944e8bd
  1. 5
      README.md
  2. 7
      transform_image.py
  3. 2
      transform_image.yaml

5
README.md

@ -21,14 +21,14 @@ __init__(self, size: int)
- supported types: `int`
```python
__call__(self, img: Union[np.ndarray, Image.Image, torch.Tensor, str])
__call__(self, img: Union[Image.Image, torch.Tensor, str])
```
**Args:**
- img:
- the input image to be processed
- supported type: `np.ndarry` or ` PIL.image` or `str` (path of the image)
- supported type: ` PIL.image` or `str` (path of the image)
**Returns:**
@ -51,4 +51,3 @@ The `towhee/transform-image` Operator is used for image transformation and is an
## Reference
- https://pytorch.org/vision/stable/transforms.html

7
transform_image.py

@ -15,7 +15,6 @@
from typing import NamedTuple, Union
import torch
import numpy as np
from PIL import Image
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.
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
four formats: np.ndarray, Image.Image, torch.Tensor and str.
four formats: Image.Image, torch.Tensor and str.
Returns:
(`torch.Tensor`)
The normalized image tensor.

2
transform_image.yaml

@ -8,6 +8,6 @@ init:
size: int
call:
input:
img: Union[np.ndarray, Image.Image, torch.Tensor, str]
img: Union[Image.Image, torch.Tensor, str]
output:
img_transformed: torch.Tensor
Loading…
Cancel
Save