Antoine commited on
Commit
01f73e6
1 Parent(s): 2ebf42c

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_large-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.batch_predict_entities(inputs, labels)
15
+ return prediction
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gliner