Browse Source
change models folder name.
Signed-off-by: wxywb <xy.wang@zilliz.com>
main
wxywb
2 years ago
4 changed files with
3 additions and
5 deletions
-
README.md
-
clipcap.py
-
clipcap_model/__init__.py
-
clipcap_model/clipcap.py
|
@ -69,16 +69,14 @@ Create the operator via the following factory method |
|
|
|
|
|
|
|
|
## Interface |
|
|
## Interface |
|
|
|
|
|
|
|
|
An image-text embedding operator takes a [towhee image](link/to/towhee/image/api/doc) as input and generate the correspoing caption. |
|
|
|
|
|
|
|
|
An image captioning operator takes a [towhee image](link/to/towhee/image/api/doc) as input and generate the correspoing caption. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
**Parameters:** |
|
|
**Parameters:** |
|
|
|
|
|
|
|
|
***data:*** *towhee.types.Image (a sub-class of numpy.ndarray)* |
|
|
***data:*** *towhee.types.Image (a sub-class of numpy.ndarray)* |
|
|
|
|
|
|
|
|
The image to generate embedding. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The image to generate caption. |
|
|
|
|
|
|
|
|
**Returns:** *str* |
|
|
**Returns:** *str* |
|
|
|
|
|
|
|
|
|
@ -33,7 +33,7 @@ class ClipCap(NNOperator): |
|
|
def __init__(self, model_name: str): |
|
|
def __init__(self, model_name: str): |
|
|
super().__init__() |
|
|
super().__init__() |
|
|
sys.path.append(str(Path(__file__).parent)) |
|
|
sys.path.append(str(Path(__file__).parent)) |
|
|
from models.clipcap import ClipCaptionModel, generate_beam |
|
|
|
|
|
|
|
|
from clipcap_model.clipcap import ClipCaptionModel, generate_beam |
|
|
self.device = "cuda" if torch.cuda.is_available() else "cpu" |
|
|
self.device = "cuda" if torch.cuda.is_available() else "cpu" |
|
|
self.generate_beam = generate_beam |
|
|
self.generate_beam = generate_beam |
|
|
self.tokenizer = GPT2Tokenizer.from_pretrained("gpt2") |
|
|
self.tokenizer = GPT2Tokenizer.from_pretrained("gpt2") |
|
|