Browse Source
Update
Signed-off-by: Jael Gu <mengjia.gu@zilliz.com>
main
2 changed files with
12 additions and
22 deletions
-
README.md
-
BIN
result.png
|
@ -13,34 +13,24 @@ This operator extracts features for images with [Multi-Path Vision Transformer ( |
|
|
|
|
|
|
|
|
## Code Example |
|
|
## 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() |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
 |
|
|
|
|
|
|
|
|
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:* |
|
|
*Write a same pipeline with explicit inputs/outputs name specifications:* |
|
|
|
|
|
|
|
|
```python |
|
|
```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() |
|
|
``` |
|
|
``` |
|
|
 |
|
|
|
|
|
|
|
|
 |
|
|
|
|
|
|
|
|
<br /> |
|
|
<br /> |
|
|
|
|
|
|
|
|
Width:
|
Height:
|
Size: 81 KiB
|