Update handler.py
Browse files- handler.py +3 -3
handler.py
CHANGED
@@ -3,14 +3,14 @@ from PIL import Image
|
|
3 |
import torch
|
4 |
import base64
|
5 |
from io import BytesIO
|
6 |
-
from transformers import AutoProcessor,
|
7 |
|
8 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
9 |
|
10 |
class EndpointHandler():
|
11 |
def __init__(self, path=""):
|
12 |
-
self.processor = AutoProcessor.from_pretrained("Salesforce/blip-
|
13 |
-
self.model =
|
14 |
|
15 |
def __call__(self, data: Any) -> List[float]:
|
16 |
inputs = data.pop("inputs", data)
|
|
|
3 |
import torch
|
4 |
import base64
|
5 |
from io import BytesIO
|
6 |
+
from transformers import AutoProcessor, BlipForQuestionAnswering
|
7 |
|
8 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
9 |
|
10 |
class EndpointHandler():
|
11 |
def __init__(self, path=""):
|
12 |
+
self.processor = AutoProcessor.from_pretrained("Salesforce/blip-vqa-capfilt-large")
|
13 |
+
self.model = BlipForQuestionAnswering.from_pretrained("Salesforce/blip-vqa-capfilt-large").to(device)
|
14 |
|
15 |
def __call__(self, data: Any) -> List[float]:
|
16 |
inputs = data.pop("inputs", data)
|