From 8185d07e617aca0d5d542c7034f1abde339fcdca Mon Sep 17 00:00:00 2001 From: shiyu22 Date: Fri, 10 Dec 2021 14:43:36 +0800 Subject: [PATCH] Update Signed-off-by: shiyu22 --- README.md | 20 ++++++++++++-------- image_embedding_resnet50.yaml | 14 +++++++------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index b60c0b4..21b35f8 100644 --- a/README.md +++ b/README.md @@ -4,21 +4,25 @@ 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. +This pipeline is used to **extract the feature vector of a given image**. + +The pipeline performs two major steps. First, normalize the image, and then use resnet50 model to generate the vector. ## Interface -**Args:** +**Pipeline Input Arguments:** + +- img(`PIL.Image`): -​ img_tensor(`PIL.Image`): + The image to be encoded. `PIL.Image` is the currently supported image type. -​ The image to be encoded. +**Pipeline Returns:** -**Returns:** +- (`Tuple[('cnn', numpy.ndarray)]`) -​ (`Tuple[('cnn', numpy.ndarray)]`) + The pipeline returns a tuple. -​ The embedding of the image. + - The `feature_vector` field contains the embedding of the image. ## How to use @@ -43,6 +47,6 @@ $ pip3 install towhee ## 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. +This pipeline includes two main operators: transform image (implemented as [towhee/transform-image](https://hub.towhee.io/towhee/transform-image)) and image embedding (implemented as [towhee/resnet50-image-embedding](https://hub.towhee.io/towhee/resnet50-image-embedding)). The transform image operator will first convert the original image into a normalized format, such as with 512x512 resolutions. Then, the normalized image will be encoded via image embedding operator, and finally we get a feature vector of the given image. (The basic concepts of pipeline and operator are introduced in [Towhee architecture](https://github.com/towhee-io/towhee#towhee-architecture).) ![img](./readme_res/pipeline.png) diff --git a/image_embedding_resnet50.yaml b/image_embedding_resnet50.yaml index 3ed4a1f..40bbf44 100644 --- a/image_embedding_resnet50.yaml +++ b/image_embedding_resnet50.yaml @@ -7,7 +7,7 @@ operators: inputs: - df: '_start_df' - name: 'img_tensor' + name: 'img' col: 0 outputs: - @@ -23,7 +23,7 @@ operators: inputs: - df: 'image' - name: 'img_tensor' + name: 'img' col: 0 outputs: - @@ -53,7 +53,7 @@ operators: inputs: - df: 'embedding' - name: 'cnn' + name: 'feature_vector' col: 0 outputs: - @@ -65,13 +65,13 @@ dataframes: name: '_start_df' columns: - - name: 'img_tensor' + name: 'img' vtype: 'PIL.Image' - name: 'image' columns: - - name: 'img_tensor' + name: 'img' vtype: 'PIL.Image' - name: 'image_preproc' @@ -83,11 +83,11 @@ dataframes: name: 'embedding' columns: - - name: 'cnn' + name: 'feature_vector' vtype: 'numpy.ndarray' - name: '_end_df' columns: - - name: 'cnn' + name: 'feature_vector' vtype: 'numpy.ndarray'