logo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readme
Files and versions

Updated 3 years ago

towhee

Transform Image 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(int):

​ The size of the output image.

__call__(self, img_tensor: Union[np.ndarray, Image.Image, torch.Tensor, str])

Args:

​ img_tensor(Union[np.ndarray, Image.Image, torch.Tensor, str]):

​ Original image data, the type can be np.ndarry, PIL.image, or str path of the image.

Returns:

​ (Tuple[('img_transformed', torch.Tensor)])

​ The tensor of the transformed image.

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.

img

Reference

shiyu22 3115dd01c1 Update 12 Commits
folder-icon readme_src Update 3 years ago
file-icon .gitattributes
841 B
download-icon
Add transform-image op 3 years ago
file-icon .gitignore
3.0 KiB
download-icon
Update and add gitignore 3 years ago
file-icon README.md
1.6 KiB
download-icon
Update 3 years ago
file-icon __init__.py
592 B
download-icon
Add transform-image op 3 years ago
file-icon requirements.txt
0 B
download-icon
Update 3 years ago
file-icon transform_image.py
2.3 KiB
download-icon
Add transform-image op 3 years ago
file-icon transform_image.yaml
283 B
download-icon
Add transform-image op 3 years ago