Browse Source
update the readme.
Signed-off-by: wxywb <xy.wang@zilliz.com>
main
wxywb
2 years ago
3 changed files with
11 additions and
20 deletions
-
README.md
-
clip/_clip.py
-
magic.py
|
@ -18,28 +18,19 @@ This operator generates the caption with [MAGIC](https://arxiv.org/abs/2205.0265 |
|
|
|
|
|
|
|
|
Load an image from path './image.jpg' to generate the caption. |
|
|
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 |
|
|
```python |
|
|
import towhee |
|
|
|
|
|
|
|
|
from towhee.dc2 import pipe, ops, DataCollection |
|
|
|
|
|
|
|
|
towhee.glob('./image.jpg') \ |
|
|
|
|
|
.image_decode() \ |
|
|
|
|
|
.image_captioning.magic(model_name='magic_mscoco') \ |
|
|
|
|
|
.show() |
|
|
|
|
|
``` |
|
|
|
|
|
<img src="./cap.png" alt="result1" style="height:20px;"/> |
|
|
|
|
|
|
|
|
|
|
|
*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.magic(model_name='magic_mscoco')) |
|
|
|
|
|
.output('img', 'text') |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
towhee.glob['path']('./image.jpg') \ |
|
|
|
|
|
.image_decode['path', 'img']() \ |
|
|
|
|
|
.image_captioning.magic['img', 'text'](model_name='magic_mscoco') \ |
|
|
|
|
|
.select['img', 'text']() \ |
|
|
|
|
|
.show() |
|
|
|
|
|
|
|
|
DataCollection(p('./image.jpg')).show() |
|
|
``` |
|
|
``` |
|
|
<img src="./tab.png" alt="result2" style="height:60px;"/> |
|
|
<img src="./tab.png" alt="result2" style="height:60px;"/> |
|
|
|
|
|
|
|
|
|
@ -40,7 +40,7 @@ class Magic(NNOperator): |
|
|
sys.path.append(path + '/clip') |
|
|
sys.path.append(path + '/clip') |
|
|
sys.path.append(path + '/language_model') |
|
|
sys.path.append(path + '/language_model') |
|
|
print(sys.path) |
|
|
print(sys.path) |
|
|
from clip import CLIP |
|
|
|
|
|
|
|
|
from _clip import CLIP |
|
|
from simctg import SimCTG |
|
|
from simctg import SimCTG |
|
|
sys.path.pop() |
|
|
sys.path.pop() |
|
|
sys.path.pop() |
|
|
sys.path.pop() |
|
|