Commit ·
cabb5b4
1
Parent(s): 39120fd
chore: change model
Browse files- handler.py +6 -3
handler.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
# +
|
| 2 |
-
from typing import Dict, Any
|
| 3 |
from PIL import Image
|
| 4 |
import torch
|
| 5 |
import requests
|
|
@@ -13,10 +13,13 @@ class EndpointHandler():
|
|
| 13 |
def __init__(self, path=""):
|
| 14 |
# load the optimized model
|
| 15 |
|
| 16 |
-
self.processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-
|
| 17 |
-
self.model = BlipForConditionalGeneration.from_pretrained(
|
|
|
|
|
|
|
| 18 |
self.model.eval()
|
| 19 |
self.model = self.model.to(device)
|
|
|
|
| 20 |
|
| 21 |
|
| 22 |
def __call__(self, data: Any) -> Dict[str, Any]:
|
|
|
|
| 1 |
# +
|
| 2 |
+
from typing import Dict, List, Any
|
| 3 |
from PIL import Image
|
| 4 |
import torch
|
| 5 |
import requests
|
|
|
|
| 13 |
def __init__(self, path=""):
|
| 14 |
# load the optimized model
|
| 15 |
|
| 16 |
+
self.processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
|
| 17 |
+
self.model = BlipForConditionalGeneration.from_pretrained(
|
| 18 |
+
"Salesforce/blip-image-captioning-base"
|
| 19 |
+
).to(device)
|
| 20 |
self.model.eval()
|
| 21 |
self.model = self.model.to(device)
|
| 22 |
+
|
| 23 |
|
| 24 |
|
| 25 |
def __call__(self, data: Any) -> Dict[str, Any]:
|