From 249805b716bb9e4dc927a82ca98fceb56d3be672 Mon Sep 17 00:00:00 2001 From: Jael Gu Date: Fri, 28 Apr 2023 15:51:38 +0800 Subject: [PATCH] Update readme Signed-off-by: Jael Gu --- README.md | 46 ++++++++++------------------------------------ 1 file changed, 10 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index e4d5a31..b03f4a0 100644 --- a/README.md +++ b/README.md @@ -18,48 +18,22 @@ As suggested, it is suitable to extract features at high level or warm up a larg Generate embeddings for the audio "test.wav". -*Write the pipeline in simplified style*: +*Write a same pipeline with explicit inputs/outputs name specifications:* ```python -import towhee - -( - towhee.glob('test.wav') - .audio_decode.ffmpeg() - .runas_op(func=lambda x:[y[0] for y in x]) - .audio_embedding.vggish() - .show() +from towhee import pipe, ops + +p = ( + pipe.input('path') + .map('path', 'frame', ops.audio_decode.ffmpeg()) + .map('frame', 'vecs', ops.audio_embedding.vggish()) + .output('vecs') ) + +p('test.wav').get()[0] ``` | [-0.4931737, -0.40068552, -0.032327592, ...] shape=(10, 128) | -*Write a same pipeline with explicit inputs/outputs name specifications:* - -```python -import towhee - -( - towhee.glob['path']('test.wav') - .audio_decode.ffmpeg['path', 'frames']() - .runas_op['frames', 'frames'](func=lambda x:[y[0] for y in x]) - .audio_embedding.vggish['frames', 'vecs']() - .select['path', 'vecs']() - .show() -) -``` - [array([[-0.4931737 , -0.40068552, -0.03232759, ..., -0.33428153, - 0.1333081 , -0.25221825], - [-0.49023268, -0.40161428, -0.03255743, ..., -0.33395663, - 0.13261834, -0.25324696], - [-0.4992406 , -0.39848825, -0.03186834, ..., -0.33684137, - 0.13326398, -0.25385314], - ..., - [-0.49047503, -0.40119144, -0.03144619, ..., -0.33282205, - 0.13334712, -0.2520305 ], - [-0.48861542, -0.40097567, -0.03173053, ..., -0.33255234, - 0.13278192, -0.25157905], - [-0.4886143 , -0.40098593, -0.03175077, ..., -0.3325425 , - 0.13271847, -0.25159872]], dtype=float32)]