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`](https://pytorch.org/vision/stable/transforms.html#torchvision.transforms.Compose) in Pytorch.
You can get the required python package by [requirements.txt](./requirements.txt). In fact, Towhee will automatically install these packages when you first load the Operator Repo, so you don't need to install them manually, here is just a list.
- towhee
- torch
- torchvision
- numpy
- pillow
### 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](https://hub.towhee.io/towhee/image-embedding-resnet50) pipeline, and it is the red box in the picture below.

When using this Operator to write Pipline's Yaml file, you need to declare the following content according to the interface of TransformImage class:
> In the Interface section, we said that the input of the Operator can be np.ndarry, PIL.image, or str path of the image, but here we only use PIL.Image as an example, which is also used in [image_embedding_resnet50](https://hub.towhee.io/towhee/image-embedding-resnet50) pipeline, of course you can also change to the dataframe you want.
### File Structure
Here is the main file structure of the `transform-image` Operator. If you want to learn more about the source code or modify it yourself, you can learn from it.