- model_name(str): the model name for embedding, like 'resnet50'.
The model name for embedding, for example 'resnet50'.
framework (`str`):
The framework of the model, the default is 'pytorch'.
`__call__(self, img_tensor: torch.Tensor)`
`__call__(self, img_tensor: torch.Tensor)`
**params:**
**Args:**
- img_tensor(torch.Tensor): the normalized image tensor.
img_tensor (`torch.Tensor`):
**return:**
The image tensor.
- cnn(numpy.ndarray): the embedding of image.
**Returns:**
## How to use
(`Tuple[('cnn', numpy.ndarray)]`)
### Requirements
The embedding of image.
You can get the required python package by [requirements.txt](./requirements.txt) and [pytorch/requirements.txt](./pytorch/requirements.txt). 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.
## Requirements
- towhee
- torch
- torchvision
- numpy
You can get the required python package by [requirements.txt](./requirements.txt).
### How it works
## How it works
The `towhee/resnet50-image-embedding` Operator implements the function of image embedding, which can add to the pipeline, for example, it's the key Operator named embedding_model within [image_embedding_resnet50](https://hub.towhee.io/towhee/image-embedding-resnet50) pipeline, and it is the red box in the picture below.
The `towhee/resnet50-image-embedding` Operator implements the function of image embedding, which can add to the pipeline, for example, it's the key Operator named embedding_model 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 Pipeline's Yaml file, you need to declare the following content according to the interface of Resnet50ImageEmbedding class:
```yaml
operators:
-
name: 'embedding_model'
function: 'towhee/resnet50-image-embedding'
tag: 'main'
init_args:
model_name: 'resnet50'
inputs:
-
df: 'image_preproc'
name: 'img_tensor'
col: 0
outputs:
-
df: 'embedding'
iter_info:
type: map
dataframes:
-
name: 'image_preproc'
columns:
-
name: 'img_transformed'
vtype: 'torch.Tensor'
-
name: 'embedding'
columns:
-
name: 'cnn'
vtype: 'numpy.ndarray'
```
We can see that in yaml, the **operator** part declares the `init_args` of the class and the `input` and `output` dataframe, and the **dataframe** declares the parameter `name` and `vtype`.
### File Structure
Here is the main file structure of the `resnet50-image-embedding` Operator. If you want to learn more about the source code or modify it yourself, you can learn from it.