MahmoudNasser commited on
Commit
95dabf2
1 Parent(s): 7d7fd9c

Update main.py

Browse files

Emotion prediction

Files changed (1) hide show
  1. main.py +5 -7
main.py CHANGED
@@ -174,13 +174,11 @@ def modelsummary(data):
174
  result = remove_punctuations(result)
175
  return { 'summary':result}
176
 
177
- def modelpredict(data):
178
- data = txt_preprocess(data)
179
- pred = model.predict(pd.Series([data]))
180
- labelpred = np.argmax(pred,axis=0)
181
- dict_labels={"label":original_values(labelpred)}
182
- return dict_labels
183
- # return {"anger": .90, "happy": .02, "emotionlabel": "anger"}
184
 
185
  #OTP code
186
  def genereteotp (email):
 
174
  result = remove_punctuations(result)
175
  return { 'summary':result}
176
 
177
+ def predict(data):
178
+ map = {0:'anger', 1:'sadness', 2:'joy', 3:'surprise', 4:'love', 5:'sympathy', 6:'fear'}
179
+ text = txt_preprocess(data)
180
+ pred=model.predict(pd.Series([data]))
181
+ return map[np.argmax(pred,axis=-1)[0]]
 
 
182
 
183
  #OTP code
184
  def genereteotp (email):