logo
Browse Source

upload

main
Filip 3 years ago
parent
commit
1ee99d169d
  1. 23
      README.md
  2. 109
      image_embedding_resnet50.yaml

23
README.md

@ -1,17 +1,17 @@
# Pipeline: Image Embedding using Resnet50
# Pipeline: Image Embedding using resnet50
Authors: derekdqc
Authors: Filip
## Overview ## Overview
The pipeline is used to **extract the feature vector of a given image**. It uses Resnet50 model to generate the vector.
The pipeline is used to **extract the feature vector of a given image**. It uses the the resnet50 model from Ross Wightman's [`timm`](https://github.com/rwightman/pytorch-image-models) to generate the vector.
## Interface ## Interface
**Input Arguments:** **Input Arguments:**
- img_path: - img_path:
- path to the input image
- the input image path
- supported types: `str` - supported types: `str`
**Pipeline Output:** **Pipeline Output:**
@ -21,7 +21,8 @@ The pipeline returns a tuple `Tuple[('feature_vector', numpy.ndarray)]` containi
- feature_vector: - feature_vector:
- the embedding of input image - the embedding of input image
- data type: `numpy.ndarray` - data type: `numpy.ndarray`
- shape: (2048,)
- shape: (1, 2048)
## How to use ## How to use
1. Install [Towhee](https://github.com/towhee-io/towhee) 1. Install [Towhee](https://github.com/towhee-io/towhee)
@ -37,15 +38,7 @@ $ pip3 install towhee
```python ```python
>>> from towhee import pipeline >>> from towhee import pipeline
>>> img_path = 'path/to/your/image'
>>> embedding_pipeline = pipeline('towhee/image-embedding-resnet50') >>> embedding_pipeline = pipeline('towhee/image-embedding-resnet50')
>>> embedding = embedding_pipeline('path/to/your/image') #such as './readme_res/pipeline.png'
>>> embedding = embedding_pipeline(img_path)
``` ```
## How it works
This pipeline includes one operator: [image embedding](https://hub.towhee.io/towhee/image-embedding-operator-template) (implemented as [towhee/resnet-image-embedding](https://hub.towhee.io/towhee/resnet-image-embedding)). The image will be encoded via image embedding operator, then we can get a feature vector of the given image.
> Refer [Towhee architecture](https://github.com/towhee-io/towhee#towhee-architecture) for basic concepts in Towhee: pipeline, operator, dataframe.
![img](./readme_res/pipeline.png)

109
image_embedding_resnet50.yaml

@ -1,94 +1,71 @@
name: 'image-embedding-resnet'
type: 'image-embedding'
name: image_embedding_resnet50
type: image-embedding
operators: operators:
-
name: '_start_op'
function: '_start_op'
init_args:
- name: _start_op
function: _start_op
init_args: null
inputs: inputs:
-
df: '_start_df'
name: 'img_path'
- df: _start_df
name: img_path
col: 0 col: 0
outputs: outputs:
-
df: 'img_str'
- df: img_str
iter_info: iter_info:
type: map type: map
-
name: 'image_decoder'
function: 'towhee/image-decoder'
tag: 'main'
init_args:
- name: image_decoder
function: towhee/image-decoder
tag: main
init_args: null
inputs: inputs:
-
df: 'img_str'
name: 'image_path'
- df: img_str
name: image_path
col: 0 col: 0
outputs: outputs:
-
df: 'image'
- df: image
iter_info: iter_info:
type: map type: map
-
name: 'embedding_model'
function: 'towhee/resnet-image-embedding' # same as 'resnet50-image-embedding', default user is towhee
tag: 'main'
- name: embedding_model
function: towhee/timm-image-embedding
tag: main
init_args: init_args:
model_name: 'resnet50'
model_name: resnet50
inputs: inputs:
-
df: 'image'
name: 'image'
- df: image
name: image
col: 0 col: 0
outputs: outputs:
-
df: 'embedding'
- df: embedding
iter_info: iter_info:
type: map type: map
-
name: '_end_op'
function: '_end_op'
init_args:
- name: _end_op
function: _end_op
init_args: null
inputs: inputs:
-
df: 'embedding'
name: 'feature_vector'
- df: embedding
name: feature_vector
col: 0 col: 0
outputs: outputs:
-
df: '_end_df'
- df: _end_df
iter_info: iter_info:
type: map type: map
dataframes: dataframes:
-
name: '_start_df'
- name: _start_df
columns: columns:
-
name: 'img_path'
vtype: 'str'
-
name: 'img_str'
- name: img_path
vtype: str
- name: img_str
columns: columns:
-
name: 'img_path'
vtype: 'str'
-
name: 'image'
- name: img_path
vtype: str
- name: image
columns: columns:
-
name: 'image'
vtype: 'towhee.types.Image'
-
name: 'embedding'
- name: image
vtype: towhee.types.Image
- name: embedding
columns: columns:
-
name: 'feature_vector'
vtype: 'numpy.ndarray'
-
name: '_end_df'
- name: feature_vector
vtype: numpy.ndarray
- name: _end_df
columns: columns:
-
name: 'feature_vector'
vtype: 'numpy.ndarray'
- name: feature_vector
vtype: numpy.ndarray

Loading…
Cancel
Save