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
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
**Input Arguments:**
- img_path:
- path to the input image
- the input image path
- supported types: `str`
**Pipeline Output:**
@ -21,7 +21,8 @@ The pipeline returns a tuple `Tuple[('feature_vector', numpy.ndarray)]` containi
- feature_vector:
- the embedding of input image
- data type: `numpy.ndarray`
- shape: (2048,)
- shape: (1, 2048)
## How to use
1. Install [Towhee](https://github.com/towhee-io/towhee)
@ -37,15 +38,7 @@ $ pip3 install towhee
```python
>>> from towhee import pipeline
>>> img_path = 'path/to/your/image'
>>> 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:
-
name: '_start_op'
function: '_start_op'
init_args:
- name: _start_op
function: _start_op
init_args: null
inputs:
-
df: '_start_df'
name: 'img_path'
- df: _start_df
name: img_path
col: 0
outputs:
-
df: 'img_str'
- df: img_str
iter_info:
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:
-
df: 'img_str'
name: 'image_path'
- df: img_str
name: image_path
col: 0
outputs:
-
df: 'image'
- df: image
iter_info:
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:
model_name: 'resnet50'
model_name: resnet50
inputs:
-
df: 'image'
name: 'image'
- df: image
name: image
col: 0
outputs:
-
df: 'embedding'
- df: embedding
iter_info:
type: map
-
name: '_end_op'
function: '_end_op'
init_args:
- name: _end_op
function: _end_op
init_args: null
inputs:
-
df: 'embedding'
name: 'feature_vector'
- df: embedding
name: feature_vector
col: 0
outputs:
-
df: '_end_df'
- df: _end_df
iter_info:
type: map
dataframes:
-
name: '_start_df'
- name: _start_df
columns:
-
name: 'img_path'
vtype: 'str'
-
name: 'img_str'
- name: img_path
vtype: str
- name: img_str
columns:
-
name: 'img_path'
vtype: 'str'
-
name: 'image'
- name: img_path
vtype: str
- name: image
columns:
-
name: 'image'
vtype: 'towhee.types.Image'
-
name: 'embedding'
- name: image
vtype: towhee.types.Image
- name: embedding
columns:
-
name: 'feature_vector'
vtype: 'numpy.ndarray'
-
name: '_end_df'
- name: feature_vector
vtype: numpy.ndarray
- name: _end_df
columns:
-
name: 'feature_vector'
vtype: 'numpy.ndarray'
- name: feature_vector
vtype: numpy.ndarray

Loading…
Cancel
Save