Antoine commited on
Commit
826f064
1 Parent(s): 9fe500c

add custom handler

Browse files
Files changed (2) hide show
  1. handler.py +15 -0
  2. requirements.txt +1 -0
handler.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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("urchade/gliner_medium-v2.1")
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
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gliner