File size: 656 Bytes
81894b1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import base64
from io import BytesIO
from typing import Any, Dict, List
from fashion_clip.fashion_clip import FashionCLIP
from PIL import Image
class PreTrainedPipeline:
def __init__(self, path=""):
self.model = FashionCLIP("fashion-clip")
def __call__(self, inputs: str) -> List[float]:
"""
Args:
inputs (:obj:`str`):
a string to get the features from.
Return:
A :obj:`list` of floats: The features computed by the model.
"""
image = Image.open(BytesIO(base64.b64decode(inputs)))
return self.model.encode_images([image], batch_size=1)[0].tolist()
|