logo
Readme
Files and versions

56 lines
1.8 KiB

# Template: Image Embedding Operator
3 years ago
Authors:
## **Overview**
> <font color=red>**Note:** this is just a **template**, not a runnable pipeline.</font>
This **class template for the image embedding operator** defines the image embedding functions, as well as the standard inputs and outputs. You can complete the operator by filling in the function(`__init__`, `__call__` ) in [image_embedding_operator_template.py](http://./image_embedding_operator_template.py) and update this README file. FYI, [image-embedding-resnet50](https://hub.towhee.io/towhee/image-embedding-resnet50) is based on this template.
This Operator generates feature vectors from "someone" model, which is trained on "someone" dataset.
## **Interface**
```python
__init__(self, model_name: str, framework: str = 'pytorch')
```
**Args:**
- model_name:
- the model name for embedding
- supported types: `str`, for example 'resnet50'
- framework:
- the framework of the model
- supported types: `str`, default is 'pytorch'
```python
__call__(self, img_tensor: torch.Tensor)
```
**Args:**
- img_path:
- path to the input image
- supported types: `str`
**Returns:**
The Operator returns a tuple `Tuple[('feature_vector', numpy.ndarray)]` containing following fields:
- feature_vector:
- the embedding of the image
- data type: `numpy.ndarray`
## **Requirements**
You can get the required python package by [requirements.txt](https://zilliverse.feishu.cn/docs/requirements.txt).
## **How it works**
The `towhee/image-embedding-operator-template` 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-pipeline-template](https://hub.towhee.io/towhee/image-embedding-pipeline-template) pipeline.
## **Reference**