diff --git a/README.md b/README.md index f430260..4ffbcd0 100644 --- a/README.md +++ b/README.md @@ -18,28 +18,19 @@ This operator generates the caption with [CapDec](https://arxiv.org/abs/2211.005 Load an image from path './image.jpg' to generate the caption. - *Write the pipeline in simplified style*: +*Write a pipeline with explicit inputs/outputs name specifications:* ```python -import towhee +from towhee.dc2 import pipe, ops, DataCollection -towhee.glob('./image.jpg') \ - .image_decode() \ - .image_captioning.capdec(model_name='capdec_noise_0') \ - .show() -``` -result1 - -*Write a same pipeline with explicit inputs/outputs name specifications:* - -```python -import towhee +p = ( + pipe.input('url') + .map('url', 'img', ops.image_decode.cv2_rgb()) + .map('img', 'text', ops.image_captioning.capdec(model_name='capdec_noise_0') + .output('img', 'text') +) -towhee.glob['path']('./image.jpg') \ - .image_decode['path', 'img']() \ - .image_captioning.capdec['img', 'text'](model_name='capdec_noise_0') \ - .select['img', 'text']() \ - .show() +DataCollection(p('./image.jpg')).show() ``` result2 diff --git a/cap.png b/cap.png new file mode 100644 index 0000000..119ac30 Binary files /dev/null and b/cap.png differ diff --git a/capdec.py b/capdec.py index ad2a844..0064d1a 100644 --- a/capdec.py +++ b/capdec.py @@ -55,7 +55,7 @@ class Capdec(NNOperator): self.clip_model = clip.create_model(model_name='clip_resnet_r50x4', pretrained=True, jit=True) self.clip_model.to(self.device) self.clip_tfms = clip.get_transforms(model_name='clip_resnet_r50x4') - self.tokenizer = GPT2Tokenizer.from_pretrained("gpt2").to(self.device) + self.tokenizer = GPT2Tokenizer.from_pretrained("gpt2") self.generate_beam = generate_beam self.generate2 = generate2 diff --git a/tabular.png b/tabular.png new file mode 100644 index 0000000..83bb96c Binary files /dev/null and b/tabular.png differ