towhee
/
image-embedding-resnet50
copied
4 changed files with 131 additions and 2 deletions
@ -1,3 +1,20 @@ |
|||||
# image-embedding-resnet50 |
|
||||
|
# Image Embedding Pipeline with Resnet50 |
||||
|
|
||||
This is another test repo |
|
||||
|
Authors: name or github-name(email) |
||||
|
|
||||
|
## Overview |
||||
|
|
||||
|
Introduce the functions of pipeline. |
||||
|
|
||||
|
## Interface |
||||
|
|
||||
|
The interface of pipeline.(input & output) |
||||
|
|
||||
|
## How to use |
||||
|
|
||||
|
- Requirements from requirements.txt |
||||
|
- Run it with Towhee |
||||
|
|
||||
|
## How it works |
||||
|
|
||||
|
- op1->op2->op3 , and intro all the op used. (auto generate graph) |
@ -0,0 +1,94 @@ |
|||||
|
name: 'image-embedding-resnet50' |
||||
|
operators: |
||||
|
- |
||||
|
name: '_start_op' |
||||
|
function: '_start_op' |
||||
|
init_args: |
||||
|
inputs: |
||||
|
- |
||||
|
df: '_start_df' |
||||
|
name: 'img_tensor' |
||||
|
col: 0 |
||||
|
outputs: |
||||
|
- |
||||
|
df: 'image' |
||||
|
iter_info: |
||||
|
type: map |
||||
|
- |
||||
|
name: 'preprocessing' |
||||
|
function: 'towhee/transform-image' # same as 'transform-image', default author is towhee |
||||
|
tag: 'main' # optional |
||||
|
init_args: |
||||
|
size: 256 |
||||
|
inputs: |
||||
|
- |
||||
|
df: 'image' |
||||
|
name: 'img_tensor' |
||||
|
col: 0 |
||||
|
outputs: |
||||
|
- |
||||
|
df: 'image_preproc' |
||||
|
iter_info: |
||||
|
type: map |
||||
|
- |
||||
|
name: 'embedding_model' |
||||
|
function: 'towhee/resnet50-image-embedding' # same as 'resnet50-image-embedding', default user is towhee |
||||
|
tag: 'main' # optional |
||||
|
init_args: |
||||
|
model_name: 'resnet50' |
||||
|
inputs: |
||||
|
- |
||||
|
df: 'image_preproc' |
||||
|
name: 'img_tensor' |
||||
|
col: 0 |
||||
|
outputs: |
||||
|
- |
||||
|
df: 'embedding' |
||||
|
iter_info: |
||||
|
type: map |
||||
|
- |
||||
|
name: '_end_op' |
||||
|
function: |
||||
|
name: '_end_op' |
||||
|
init_args: |
||||
|
inputs: |
||||
|
- |
||||
|
df: 'embedding' |
||||
|
name: 'cnn' |
||||
|
col: 0 |
||||
|
outputs: |
||||
|
- |
||||
|
df: '_end_df' |
||||
|
iter_info: |
||||
|
type: map |
||||
|
dataframes: |
||||
|
- |
||||
|
name: '_start_df' |
||||
|
columns: |
||||
|
- |
||||
|
name: 'img_tensor' |
||||
|
vtype: 'PIL.Image' |
||||
|
- |
||||
|
name: 'image' |
||||
|
columns: |
||||
|
- |
||||
|
name: 'img_tensor' |
||||
|
vtype: 'PIL.Image' |
||||
|
- |
||||
|
name: 'image_preproc' |
||||
|
columns: |
||||
|
- |
||||
|
name: 'img_transformed' |
||||
|
vtype: 'torch.Tensor' |
||||
|
- |
||||
|
name: 'embedding' |
||||
|
columns: |
||||
|
- |
||||
|
name: 'cnn' |
||||
|
vtype: 'numpy.ndarray' |
||||
|
- |
||||
|
name: '_end_df' |
||||
|
columns: |
||||
|
- |
||||
|
name: 'cnn' |
||||
|
vtype: 'numpy.ndarray' |
After Width: | Height: | Size: 178 KiB |
@ -0,0 +1,18 @@ |
|||||
|
import unittest |
||||
|
from towhee import pipeline |
||||
|
from PIL import Image |
||||
|
|
||||
|
|
||||
|
class TestImageEmbeddingResnet50(unittest.TestCase): |
||||
|
test_img = './test_data/test.jpg' |
||||
|
test_img = Image.open(test_img) |
||||
|
|
||||
|
def test_image_embedding_resnet50(self): |
||||
|
self.dimension = 1000 |
||||
|
embedding_pipeline = pipeline('towhee/image-embedding-resnet50') |
||||
|
embedding = embedding_pipeline(self.test_img) |
||||
|
assert (1, self.dimension) == op(img_tensor)[0].shape |
||||
|
|
||||
|
|
||||
|
if __name__ == '__main__': |
||||
|
unittest.main() |
Loading…
Reference in new issue