Spaces:
Running
Running
johnpaulbin
commited on
Commit
•
3e07850
1
Parent(s):
fcf5457
Update app.py
Browse files
app.py
CHANGED
@@ -120,6 +120,24 @@ def translate():
|
|
120 |
|
121 |
return output
|
122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
# Define more routes for other operations like download_model, etc.
|
124 |
if __name__ == "__main__":
|
125 |
config = Config()
|
|
|
120 |
|
121 |
return output
|
122 |
|
123 |
+
|
124 |
+
@app.route('/inferverbose', methods=['POST'])
|
125 |
+
def translateverbose():
|
126 |
+
data = request.get_json()
|
127 |
+
|
128 |
+
TEXT = data['text'].lower()
|
129 |
+
probs = deepmojify(TEXT, prob_only=True)
|
130 |
+
embedding = sentencemodel.encode(TEXT, convert_to_tensor=True)
|
131 |
+
INPUT = torch.cat((probs, embedding))
|
132 |
+
output = F.softmax(model(INPUT.view(1, -1)), dim=1)
|
133 |
+
|
134 |
+
if output[0][1] > 0.68:
|
135 |
+
output = "true" + str(output[0][1])
|
136 |
+
else:
|
137 |
+
output = "false" + str(output[0][0])
|
138 |
+
|
139 |
+
return output
|
140 |
+
|
141 |
# Define more routes for other operations like download_model, etc.
|
142 |
if __name__ == "__main__":
|
143 |
config = Config()
|