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` - supported types: `int`
```python ```python
__call__(self, img: Union[np.ndarray, Image.Image, torch.Tensor, str])
__call__(self, img: Union[Image.Image, torch.Tensor, str])
``` ```
**Args:** **Args:**
- img: - img:
- the input image to be processed - 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:** **Returns:**
@ -51,4 +51,3 @@ The `towhee/transform-image` Operator is used for image transformation and is an
## Reference ## Reference
- https://pytorch.org/vision/stable/transforms.html - https://pytorch.org/vision/stable/transforms.html

7
transform_image.py

@ -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.

2
transform_image.yaml

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