|
|
@ -13,35 +13,34 @@ which maintains SOTA deep-learning models and tools in computer vision. |
|
|
|
|
|
|
|
## Code Example |
|
|
|
|
|
|
|
Load an image from path './dog.jpg' |
|
|
|
Load an image from path './towhee.jpg' |
|
|
|
and use the pretrained ResNet50 model ('resnet50') to generate an image embedding. |
|
|
|
|
|
|
|
*Write the pipeline in simplified style*: |
|
|
|
|
|
|
|
```python |
|
|
|
from towhee import dc |
|
|
|
import towhee |
|
|
|
|
|
|
|
dc.glob('./dog.jpg') \ |
|
|
|
.image_decode.cv2() \ |
|
|
|
.image_embedding.timm(model_name='resnet50') \ |
|
|
|
.show() |
|
|
|
towhee.glob('./towhee.jpg') \ |
|
|
|
.image_decode.cv2() \ |
|
|
|
.image_embedding.timm(model_name='resnet50') \ |
|
|
|
.show() |
|
|
|
``` |
|
|
|
| [0.052790146, 0.0, 0.0, ...] shape=(2048,) | |
|
|
|
<img src="https://towhee.io/image-embedding/timm/src/branch/main/result1.png" alt="result1" style="width:50px;"/> |
|
|
|
|
|
|
|
![result1](result1.png) |
|
|
|
|
|
|
|
*Write a same pipeline with explicit inputs/outputs name specifications:* |
|
|
|
|
|
|
|
```python |
|
|
|
from towhee import dc |
|
|
|
import towhee |
|
|
|
|
|
|
|
dc.glob['path']('./dog.jpg') \ |
|
|
|
.image_decode.cv2['path', 'img']() \ |
|
|
|
.image_embedding.timm['img', 'vec'](model_name='resnet50') \ |
|
|
|
.select('vec') \ |
|
|
|
.to_list() |
|
|
|
towhee.glob['path']('./dog.jpg') \ |
|
|
|
.image_decode.cv2['path', 'img']() \ |
|
|
|
.image_embedding.timm['img', 'vec'](model_name='resnet50') \ |
|
|
|
.select('img', 'vec') \ |
|
|
|
.show('img', 'vec') |
|
|
|
``` |
|
|
|
[array([0.05279015, 0. , 0. , ..., 0.00239191, 0.06632169, |
|
|
|
0. ], dtype=float32)] |
|
|
|
|
|
|
|
|
|
|
|
## Factory Constructor |
|
|
|
|
|
|
|