pabloruizponce commited on
Commit
870319b
1 Parent(s): 2bc2b10

Create handler.py

Browse files
Files changed (1) hide show
  1. handler.py +16 -0
handler.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoModel
2
+ import numpy as np
3
+
4
+ class EndpointHandler():
5
+ def __init__(self, path=""):
6
+ self.model = AutoModel.from_pretrained("pabloruizponce/in2IN", trust_remote_code=True)
7
+
8
+ def __call__(self, data: Dict[str, str]) -> Dict[str, np.ndarray]:
9
+
10
+ interaction_text = data['interaction_text']
11
+ individual1_text = data['individual1_text']
12
+ individual2_text = data['individual2_text']
13
+
14
+ prediction = self.model(interaction_text, individual1_text, individual2_text)
15
+ prediction = {'individual1': prediction[0], 'individual2': prediction[1]}
16
+ return prediction