From 6c49712f9de25bc1f7e73da134798fec98916c5f Mon Sep 17 00:00:00 2001 From: wxywb Date: Thu, 2 Feb 2023 03:02:16 +0000 Subject: [PATCH] update the readme. Signed-off-by: wxywb --- README.md | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 6277531..112259c 100644 --- a/README.md +++ b/README.md @@ -24,36 +24,26 @@ Read the text 'A teddybear on a skateboard in Times Square.' to generate an text *Write the pipeline in simplified style*: ```python -import towhee -towhee.glob('./teddy.jpg') \ - .image_decode() \ - .image_text_embedding.albef(model_name='albef_4m', modality='image') \ - .show() +from towhee.dc2 import pipe, ops, DataCollection -towhee.dc(["A teddybear on a skateboard in Times Square."]) \ - .image_text_embedding.albef(model_name='albef_4m', modality='text') \ - .show() -``` -result1 -result2 +img_pipe = ( + pipe.input('url') + .map('url', 'img', ops.image_decode.cv2_rgb()) + .map('img', 'vec', ops.image_text_embedding.albef(model_name='albef_4m', modality='image')) + .output('img', 'vec') +) -*Write a same pipeline with explicit inputs/outputs name specifications:* +text_pipe = ( + pipe.input('text') + .map('text', 'vec', ops.image_text_embedding.albef(model_name='albef_4m', modality='text')) + .output('text', 'vec') +) -```python -import towhee - -towhee.glob['path']('./teddy.jpg') \ - .image_decode['path', 'img']() \ - .image_text_embedding.albef['img', 'vec'](model_name='albef_4m', modality='image') \ - .select['img', 'vec']() \ - .show() - -towhee.dc['text'](["A teddybear on a skateboard in Times Square."]) \ - .image_text_embedding.albef['text','vec'](model_name='albef_4m', modality='text') \ - .select['text', 'vec']() \ - .show() +DataCollection(img_pipe('./teddy.jpg')).show() +DataCollection(text_pipe('A teddybear on a skateboard in Times Square.')).show() ``` + result1 result2