Update handler.py
Browse files- handler.py +8 -8
handler.py
CHANGED
@@ -5,16 +5,16 @@ from torch import cuda
|
|
5 |
|
6 |
class EndpointHandler():
|
7 |
def __init__(self, path=""):
|
8 |
-
self.processor = AutoProcessor.from_pretrained(path)
|
9 |
-
self.model = AutoModel.from_pretrained(path, trust_remote_code=True)
|
10 |
-
self.device = "cuda" if cuda.is_available() else "cpu"
|
11 |
-
self.model.to(self.device)
|
12 |
|
13 |
def __call__(self, data: Dict[str, Any]) -> List[List[int]]:
|
14 |
-
image = data.pop("inputs",data)
|
15 |
|
16 |
-
processed = self.processor(images=image, return_tensors="pt").to(self.device)
|
17 |
|
18 |
-
prediction = self.model(processed["pixel_values"])
|
19 |
|
20 |
-
return prediction.item()
|
|
|
5 |
|
6 |
class EndpointHandler():
|
7 |
def __init__(self, path=""):
|
8 |
+
#self.processor = AutoProcessor.from_pretrained(path)
|
9 |
+
#self.model = AutoModel.from_pretrained(path, trust_remote_code=True)
|
10 |
+
#self.device = "cuda" if cuda.is_available() else "cpu"
|
11 |
+
#self.model.to(self.device)
|
12 |
|
13 |
def __call__(self, data: Dict[str, Any]) -> List[List[int]]:
|
14 |
+
#image = data.pop("inputs",data)
|
15 |
|
16 |
+
#processed = self.processor(images=image, return_tensors="pt").to(self.device)
|
17 |
|
18 |
+
#prediction = self.model(processed["pixel_values"])
|
19 |
|
20 |
+
return "OK"#prediction.item()
|