|
@ -18,20 +18,26 @@ who maintains SOTA deep-learning models and tools in computer vision. |
|
|
Load an image from path './towhee.jpeg' |
|
|
Load an image from path './towhee.jpeg' |
|
|
and use the pre-trained ResNet50 model ('resnet50') to generate an image embedding. |
|
|
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 |
|
|
```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 |
|
|
```python |
|
|
import towhee |
|
|
import towhee |
|
|
|
|
|
|
|
@ -41,7 +47,6 @@ towhee.glob['path']('./towhee.jpeg') \ |
|
|
.select['img', 'vec']() \ |
|
|
.select['img', 'vec']() \ |
|
|
.show() |
|
|
.show() |
|
|
``` |
|
|
``` |
|
|
<img src="./result2.png" height="150px"/> |
|
|
|
|
|
|
|
|
|
|
|
<br /> |
|
|
<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. |
|
|
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 /> |
|
|
<br /> |
|
|
|
|
|
|
|
|
***supported_model_names(format=None)*** |
|
|
***supported_model_names(format=None)*** |
|
|