Update handler.py
Browse files- handler.py +8 -2
handler.py
CHANGED
@@ -19,7 +19,7 @@ class EndpointHandler():
|
|
19 |
self.processor = AutoProcessor.from_pretrained(self.model_name)
|
20 |
self.model = Blip2ForConditionalGeneration.from_pretrained(self.model_name,
|
21 |
device_map="auto",
|
22 |
-
)
|
23 |
|
24 |
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
25 |
"""
|
@@ -44,7 +44,13 @@ class EndpointHandler():
|
|
44 |
# print(imageURL)
|
45 |
# print(text)
|
46 |
# image = Image.open(requests.get(imageBase64, stream=True).raw)
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
image = Image.open(BytesIO(base64.b64decode(imageBase64.split(",")[0].encode())))
|
49 |
###################
|
50 |
|
|
|
19 |
self.processor = AutoProcessor.from_pretrained(self.model_name)
|
20 |
self.model = Blip2ForConditionalGeneration.from_pretrained(self.model_name,
|
21 |
device_map="auto",
|
22 |
+
)#.to(self.device)
|
23 |
|
24 |
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
25 |
"""
|
|
|
44 |
# print(imageURL)
|
45 |
# print(text)
|
46 |
# image = Image.open(requests.get(imageBase64, stream=True).raw)
|
47 |
+
import base64
|
48 |
+
from PIL import Image
|
49 |
+
from io image BytesIO
|
50 |
+
import matplotlib.pyplot as plt
|
51 |
+
#try2
|
52 |
+
# image = Image.open(BytesIO(base64.b64decode(imageBase64)))
|
53 |
+
#try1
|
54 |
image = Image.open(BytesIO(base64.b64decode(imageBase64.split(",")[0].encode())))
|
55 |
###################
|
56 |
|