Manu Biot
commited on
Commit
·
b121d58
1
Parent(s):
6f0d3f3
Add requirements.txt for endpoint dependencies
Browse files- handler.py +12 -11
handler.py
CHANGED
|
@@ -1,14 +1,15 @@
|
|
| 1 |
from gliner import GLiNER
|
| 2 |
-
from typing import Dict
|
| 3 |
|
| 4 |
-
|
|
|
|
| 5 |
def __init__(self, path=""):
|
| 6 |
-
self.model = GLiNER.from_pretrained(
|
| 7 |
-
|
| 8 |
-
def __call__(self, data: Dict[str,
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
return
|
|
|
|
| 1 |
from gliner import GLiNER
|
| 2 |
+
from typing import Dict, List, Any
|
| 3 |
|
| 4 |
+
|
| 5 |
+
class EndpointHandler():
|
| 6 |
def __init__(self, path=""):
|
| 7 |
+
self.model = GLiNER.from_pretrained("Mbiot/gliner-custom")
|
| 8 |
+
|
| 9 |
+
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
| 10 |
+
# get inputs
|
| 11 |
+
inputs = data.pop("inputs", data)
|
| 12 |
+
labels = data.pop("labels", None)
|
| 13 |
+
|
| 14 |
+
prediction = self.model.predict_entities(inputs, labels)
|
| 15 |
+
return prediction
|