diff --git a/README.md b/README.md index 28196d9..e490a76 100644 --- a/README.md +++ b/README.md @@ -13,34 +13,24 @@ This operator extracts features for images with [Multi-Path Vision Transformer ( ## Code Example -Load an image from path './towhee.jpeg' -and use the pre-trained mpvit_base model to generate an image embedding. - - *Write the pipeline in simplified style:* - -```python -import towhee - -towhee.glob('./towhee.jpeg') \ - .image_decode() \ - .image_embedding.mpvit(model_name='mpvit_base') \ - .show() -``` - -![](result1.png) +Load an image from path 'towhee.jpeg' +and use the pre-trained 'mpvit_base' model to generate an image embedding. *Write a same pipeline with explicit inputs/outputs name specifications:* ```python -import towhee +from towhee.dc2 import pipe, ops, DataCollection + +p = ( + pipe.input('path') + .map('path', 'img', ops.image_decode()) + .map('img', 'vec', ops.image_embedding.mpvit(model_name='mpvit_base')) + .output('img', 'vec') +) -towhee.glob['path']('./towhee.jpeg') \ - .image_decode['path', 'img']() \ - .image_embedding.mpvit['img', 'vec'](model_name='mpvit_base') \ - .select['img', 'vec']() \ - .show() +DataCollection(p('towhee.jpeg')).show() ``` -![](result2.png) +![](result.png)
diff --git a/result.png b/result.png new file mode 100644 index 0000000..d63ddb3 Binary files /dev/null and b/result.png differ