towhee
copied
Readme
Files and versions
1.7 KiB
Image Preprocessing Operator
Authors: derekdqc, shiyu22
Overview
This operator uses PyTorch to transform the image, such as cropping, PIL.Image and Tensor conversion, normalization and other operations on the image.
In computer vision (CV) directions, image transformations are usually an indispensable part, which can be used to pre-process images and enhance data. And transforms are common image transformations, they can be chained together using Compose
in Pytorch.
Interface
__init__(self, size: int)
Args:
- size:
- the size of the output image
- supported types:
int
__call__(self, img: Union[np.ndarray, Image.Image, torch.Tensor, str])
Args:
- img:
- the input image to be processed
- supported type:
np.ndarry
orPIL.image
orstr
(path of the image)
Returns:
The Operator returns a tuple Tuple[('img_transformed', torch.Tensor)]
containing following fields:
- img_transformed:
- the tensor of the transformed image
- data type:
torch.Tensor
Requirements
You can get the required python package by requirements.txt.
How it works
The towhee/transform-image
Operator is used for image transformation and is an important part of data preprocessing. It can be added to the pipeline and is usually used as the first custom operator of the pipeline. For example, it's the first Operator named processing within image-embedding-resnet50 pipeline, and it is the red box in the picture below.
Reference
1.7 KiB
Image Preprocessing Operator
Authors: derekdqc, shiyu22
Overview
This operator uses PyTorch to transform the image, such as cropping, PIL.Image and Tensor conversion, normalization and other operations on the image.
In computer vision (CV) directions, image transformations are usually an indispensable part, which can be used to pre-process images and enhance data. And transforms are common image transformations, they can be chained together using Compose
in Pytorch.
Interface
__init__(self, size: int)
Args:
- size:
- the size of the output image
- supported types:
int
__call__(self, img: Union[np.ndarray, Image.Image, torch.Tensor, str])
Args:
- img:
- the input image to be processed
- supported type:
np.ndarry
orPIL.image
orstr
(path of the image)
Returns:
The Operator returns a tuple Tuple[('img_transformed', torch.Tensor)]
containing following fields:
- img_transformed:
- the tensor of the transformed image
- data type:
torch.Tensor
Requirements
You can get the required python package by requirements.txt.
How it works
The towhee/transform-image
Operator is used for image transformation and is an important part of data preprocessing. It can be added to the pipeline and is usually used as the first custom operator of the pipeline. For example, it's the first Operator named processing within image-embedding-resnet50 pipeline, and it is the red box in the picture below.