From 4255c724a1a10a8329695cac5d031ae0fb8a6b24 Mon Sep 17 00:00:00 2001 From: wxywb Date: Wed, 1 Feb 2023 12:49:53 +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 57a9adb..0eb70fc 100644 --- a/README.md +++ b/README.md @@ -22,38 +22,28 @@ Load an image from path './teddy.jpg' to generate an image embedding. Read the text 'Плюшевый мишка на скейтборде на Таймс-сквер.' 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('./teddy.jpg') \ - .image_decode() \ - .image_text_embedding.ru_clip(model_name='ruclip-vit-base-patch32-224', modality='image') \ - .show() +from towhee.dc2 import pipe, ops, DataCollection -towhee.dc(["'Плюшевый мишка на скейтборде на Таймс-сквер."]) \ - .image_text_embedding.ru_clip(model_name='ruclip-vit-base-patch32-224', modality='text') \ - .show() -``` -result1 -result2 - -*Write a same pipeline with explicit inputs/outputs name specifications:* - -```python -import towhee +img_pipe = ( + pipe.input('url') + .map('url', 'img', ops.image_decode.cv2_rgb()) + .map('img', 'vec', ops.image_text_embedding.ru_clip(model_name='ruclip-vit-base-patch32-224', modality='image')) + .output('img', 'vec') +) -towhee.glob['path']('./teddy.jpg') \ - .image_decode['path', 'img']() \ - .image_text_embedding.ru_clip['img', 'vec'](model_name='ruclip-vit-base-patch32-224', modality='image') \ - .select['img', 'vec']() \ - .show() +text_pipe = ( + pipe.input('text') + .map('text', 'vec', ops.image_text_embedding.ru_clip(model_name='ruclip-vit-base-patch32-224', modality='text')) + .output('text', 'vec') +) -towhee.dc['text'](["Плюшевый мишка на скейтборде на Таймс-сквер."]) \ - .image_text_embedding.ru_clip['text','vec'](model_name='ruclip-vit-base-patch32-224', modality='text') \ - .select['text', 'vec']() \ - .show() +DataCollection(img_pipe('./teddy.jpg')).show() +DataCollection(text_pipe('Плюшевый мишка на скейтборде на Таймс-сквер.')).show() ``` result1 result2