# Image Embedding Pipeline with Resnet50 Authors: derekdqc, shiyu22 ## Overview This pipeline is used to **extract the feature vector of the image**. First step is to normalize the image, and then use resnet50 model to generate the vector. ## Interface **Args:** ​ img_tensor(`PIL.Image`): ​ The image to be encoded. **Returns:** ​ (`Tuple[('cnn', numpy.ndarray)]`) ​ The embedding of the image. ## How to use 1. Install [Towhee](https://github.com/towhee-io/towhee) ```bash $ pip3 install towhee ``` > You can refer to [Getting Started with Towhee](https://towhee.io/) for more details. If you have any questions, you can [submit an issue to the towhee repository](https://github.com/towhee-io/towhee/issues). 2. Run it with Towhee ```python >>> from towhee import pipeline >>> from PIL import Image >>> img = Image.open('path/to/your/image') # for example, './test_data/test.jpg' >>> embedding_pipeline = pipeline('towhee/image-embedding-resnet50') >>> embedding = embedding_pipeline(img) ``` ## How it works You can learn the pipeline and operator in [Towhee architecture](https://github.com/towhee-io/towhee#towhee-architecture). This pipeline includes two main functions: [towhee/transform-image](https://hub.towhee.io/towhee/transform-image) and [towhee/resnet50-image-embedding](https://hub.towhee.io/towhee/resnet50-image-embedding). It is necessary to ensure that the input and output of the four Operators correspond to each other, and the input and output data types can be defined by DataFrame. ![img](./readme_res/pipeline.png)