diff --git a/README.md b/README.md index fdc8b92..8d1e949 100644 --- a/README.md +++ b/README.md @@ -21,38 +21,26 @@ Load an image from path './teddy.jpg' to generate an image embedding. Read the text 'A teddybear on a skateboard in Times Square.' to generate an text embedding. - *Write the pipeline in simplified style*: +*Write a pipeline with explicit inputs/outputs name specifications:* ```python -import towhee - -towhee.glob('./dog.jpg') \ - .image_decode() \ - .image_text_embedding.taiyi(model_name='taiyi-clip-roberta-102m-chinese', modality='image') \ - .show() - -towhee.dc(["一只小狗"]) \ - .image_text_embedding.taiyi(model_name='taiyi-clip-roberta-102m-chinese', modality='text') \ - .show() -``` -result1 -result2 - -*Write a same pipeline with explicit inputs/outputs name specifications:* - -```python -import towhee - -towhee.glob['path']('./dog.jpg') \ - .image_decode['path', 'img']() \ - .image_text_embedding.taiyi['img', 'vec'](model_name='taiyi-clip-roberta-102m-chinese', modality='image') \ - .select['img', 'vec']() \ - .show() - -towhee.dc['text'](["一只小狗"]) \ - .image_text_embedding.taiyi['text','vec'](model_name='taiyi-clip-roberta-102m-chinese', modality='text') \ - .select['text', 'vec']() \ - .show() +from towhee.dc2 import pipe, ops, DataCollection + +img_pipe = ( + pipe.input('url') + .map('url', 'img', ops.image_decode.cv2_rgb()) + .map('img', 'vec', ops.image_text_embedding.taiyi(model_name='taiyi-clip-roberta-102m-chinese', modality='image')) + .output('img', 'vec') +) + +text_pipe = ( + pipe.input('text') + .map('text', 'vec', ops.image_text_embedding.taiyi(model_name='taiyi-clip-roberta-102m-chinese', modality='text')) + .output('text', 'vec') +) + +DataCollection(img_pipe('./dog.jpg')).show() +DataCollection(text_pipe('一只小狗')).show() ``` result1 result2