|
|
@ -18,20 +18,26 @@ who maintains SOTA deep-learning models and tools in computer vision. |
|
|
|
Load an image from path './towhee.jpeg' |
|
|
|
and use the pre-trained ResNet50 model ('resnet50') to generate an image embedding. |
|
|
|
|
|
|
|
*Write the pipeline in simplified style:* |
|
|
|
*Write a same pipeline with explicit inputs/outputs name specifications:* |
|
|
|
|
|
|
|
- **option 1:** |
|
|
|
|
|
|
|
```python |
|
|
|
import towhee |
|
|
|
from towhee.dc2 import pipe, ops, DataCollection |
|
|
|
|
|
|
|
towhee.glob('./towhee.jpeg') \ |
|
|
|
.image_decode() \ |
|
|
|
.image_embedding.timm(model_name='resnet50') \ |
|
|
|
.show() |
|
|
|
p = ( |
|
|
|
pipe.input('path') |
|
|
|
.map('path', 'img', ops.image_decode()) |
|
|
|
.map('img', 'vec', ops.image_embedding.timm(model_name='resnet50')) |
|
|
|
.output('img', 'vec') |
|
|
|
) |
|
|
|
|
|
|
|
DataCollection(p('towhee.jpeg')).show() |
|
|
|
``` |
|
|
|
<img src="./result1.png" height="50px"/> |
|
|
|
|
|
|
|
*Write a same pipeline with explicit inputs/outputs name specifications:* |
|
|
|
<img src="./result.png" height="150px"/> |
|
|
|
|
|
|
|
- **option 2:** |
|
|
|
```python |
|
|
|
import towhee |
|
|
|
|
|
|
@ -41,7 +47,6 @@ towhee.glob['path']('./towhee.jpeg') \ |
|
|
|
.select['img', 'vec']() \ |
|
|
|
.show() |
|
|
|
``` |
|
|
|
<img src="./result2.png" height="150px"/> |
|
|
|
|
|
|
|
<br /> |
|
|
|
|
|
|
@ -104,6 +109,13 @@ Save model to local with specified format. |
|
|
|
|
|
|
|
The path where model is saved to. By default, it will save model to the operator directory. |
|
|
|
|
|
|
|
```python |
|
|
|
from towhee import ops |
|
|
|
|
|
|
|
op = ops.image_embedding.timm(model_name='resnet50').get_op() |
|
|
|
op.save_model('onnx', 'test.onnx') |
|
|
|
``` |
|
|
|
|
|
|
|
<br /> |
|
|
|
|
|
|
|
***supported_model_names(format=None)*** |
|
|
|