Upload handler.py with huggingface_hub
Browse files- handler.py +19 -0
handler.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Dict, List, Any
|
2 |
+
import en_gendered_job_advertisements
|
3 |
+
|
4 |
+
|
5 |
+
class EndpointHandler():
|
6 |
+
def __init__(self, path=""):
|
7 |
+
|
8 |
+
self.model = en_gendered_job_advertisements.load()
|
9 |
+
|
10 |
+
# Preload all the elements you are going to need at inference.
|
11 |
+
# pseudo:
|
12 |
+
# self.model= load_model(path)
|
13 |
+
|
14 |
+
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
15 |
+
inputs = data.pop("inputs",data)
|
16 |
+
|
17 |
+
prediction = self.model(inputs)
|
18 |
+
|
19 |
+
return prediction
|