diff --git a/README.md b/README.md index 5e12456..ee8f8fb 100644 --- a/README.md +++ b/README.md @@ -18,47 +18,34 @@ Load a video from path './demo_video.mp4' to generate a video embedding. Read the text 'kids feeding and playing with the horse' to generate a text embedding. - *Write the pipeline in simplified style*: - - Encode video (default): ```python -import towhee -towhee.dc(['./demo_video.mp4']) \ - .video_decode.ffmpeg() \ - .video_text_embedding.bridge_former(model_name='frozen_model', modality='video') \ - .show() +from towhee.dc2 import pipe, ops, DataCollection + +p = ( + pipe.input('video_path') \ + .map('video_path', 'video_frames', ops.video_decode.ffmpeg()) \ + .map('video_frames', 'vec', ops.video_text_embedding.bridge_former(model_name='frozen_model', modality='video')) \ + .output('video_path', 'video_frames', 'vec') +) +DataCollection(p('./demo_video.mp4')).show() ``` - + - Encode text: ```python -import towhee +from towhee.dc2 import pipe, ops, DataCollection -towhee.dc(['kids feeding and playing with the horse']) \ - .video_text_embedding.bridge_former(model_name='frozen_model', modality='text') \ - .show() -``` - +p = ( + pipe.input('text') \ + .map('text', 'vec', ops.video_text_embedding.bridge_former(model_name='frozen_model', modality='text')) \ + .output('text', 'vec') +) -*Write a same pipeline with explicit inputs/outputs name specifications:* - -```python -import towhee - -towhee.dc['path'](['./demo_video.mp4']) \ - .video_decode.ffmpeg['path', 'frames']() \ - .video_text_embedding.bridge_former['frames', 'vec'](model_name='frozen_model', modality='video') \ - .select['path', 'vec']() \ - .show(formatter={'path': 'video_path'}) - -towhee.dc['text'](["kids feeding and playing with the horse"]) \ - .video_text_embedding.bridge_former['text','vec'](model_name='frozen_model', modality='text') \ - .select['text', 'vec']() \ - .show() +DataCollection(p('kids feeding and playing with the horse')).show() ``` - - +
diff --git a/result1.png b/result1.png deleted file mode 100644 index d083d3e..0000000 Binary files a/result1.png and /dev/null differ diff --git a/result2.png b/result2.png deleted file mode 100644 index 73d17f6..0000000 Binary files a/result2.png and /dev/null differ diff --git a/result3.png b/result3.png deleted file mode 100644 index 22afb2b..0000000 Binary files a/result3.png and /dev/null differ diff --git a/result4.png b/result4.png deleted file mode 100644 index 7a88200..0000000 Binary files a/result4.png and /dev/null differ diff --git a/text_emb_result.png b/text_emb_result.png new file mode 100644 index 0000000..27f6852 Binary files /dev/null and b/text_emb_result.png differ diff --git a/video_emb_result.png b/video_emb_result.png new file mode 100644 index 0000000..a830ed4 Binary files /dev/null and b/video_emb_result.png differ