Update handler.py
Browse files- handler.py +9 -0
handler.py
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
def __init__(self, path=""):
|
| 2 |
# load the optimized model
|
| 3 |
self.processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-large")
|
|
|
|
| 1 |
+
from typing import Dict, List, Any
|
| 2 |
+
from PIL import Image
|
| 3 |
+
import torch
|
| 4 |
+
from io import BytesIO
|
| 5 |
+
from transformers import BlipForConditionalGeneration, BlipProcessor
|
| 6 |
+
|
| 7 |
+
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 8 |
+
|
| 9 |
+
class EndpointHandler():
|
| 10 |
def __init__(self, path=""):
|
| 11 |
# load the optimized model
|
| 12 |
self.processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-large")
|