|
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() |
|
|