Update pipeline.py
Browse files- pipeline.py +5 -6
pipeline.py
CHANGED
@@ -34,7 +34,7 @@ class PreTrainedPipeline():
|
|
34 |
(0.48145466, 0.4578275, 0.40821073), (0.26862954, 0.26130258, 0.27577711))
|
35 |
])
|
36 |
|
37 |
-
def __call__(self, inputs: "Image.Image") -> List[float]:
|
38 |
"""
|
39 |
Args:
|
40 |
data (:obj:):
|
@@ -44,11 +44,10 @@ class PreTrainedPipeline():
|
|
44 |
- "feature_vector": A list of floats corresponding to the image embedding.
|
45 |
"""
|
46 |
parameters = {"mode": "image"}
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
# BytesIO(base64.b64decode(inputs))).convert("RGB")
|
52 |
# elif isinstance(inputs, "Image.Image"):
|
53 |
# image = Image.open(inputs).convert("RGB")
|
54 |
|
|
|
34 |
(0.48145466, 0.4578275, 0.40821073), (0.26862954, 0.26130258, 0.27577711))
|
35 |
])
|
36 |
|
37 |
+
def __call__(self, inputs: Union[str, "Image.Image"]) -> List[float]:
|
38 |
"""
|
39 |
Args:
|
40 |
data (:obj:):
|
|
|
44 |
- "feature_vector": A list of floats corresponding to the image embedding.
|
45 |
"""
|
46 |
parameters = {"mode": "image"}
|
47 |
+
if isinstance(inputs, str):
|
48 |
+
# decode base64 image to PIL
|
49 |
+
image = Image.open(
|
50 |
+
BytesIO(base64.b64decode(inputs))).convert("RGB")
|
|
|
51 |
# elif isinstance(inputs, "Image.Image"):
|
52 |
# image = Image.open(inputs).convert("RGB")
|
53 |
|