AyushChothe commited on
Commit
81894b1
·
1 Parent(s): b58d9ab

Initial pipeline setup

Browse files
Files changed (2) hide show
  1. pipeline.py +22 -0
  2. requirements.txt +2 -0
pipeline.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import base64
2
+ from io import BytesIO
3
+ from typing import Any, Dict, List
4
+
5
+ from fashion_clip.fashion_clip import FashionCLIP
6
+ from PIL import Image
7
+
8
+
9
+ class PreTrainedPipeline:
10
+ def __init__(self, path=""):
11
+ self.model = FashionCLIP("fashion-clip")
12
+
13
+ def __call__(self, inputs: str) -> List[float]:
14
+ """
15
+ Args:
16
+ inputs (:obj:`str`):
17
+ a string to get the features from.
18
+ Return:
19
+ A :obj:`list` of floats: The features computed by the model.
20
+ """
21
+ image = Image.open(BytesIO(base64.b64decode(inputs)))
22
+ return self.model.encode_images([image], batch_size=1)[0].tolist()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fashion-clip==0.2.1
2
+ Pillow==10.0.0