AhmadT198 commited on
Commit
15fd446
·
verified ·
1 Parent(s): 82d14d8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
app.py CHANGED
@@ -48,7 +48,7 @@ index_to_class = dict((v,k) for k,v in class_to_index.items())
48
  names_to_ids = lambda labels: np.array([class_to_index.get(x) for x in labels])
49
  train_labels = names_to_ids(labels)
50
 
51
- @spaces.GPU(duration=150)
52
  def load_model():
53
 
54
 
@@ -76,21 +76,21 @@ def load_model():
76
  ]
77
  )
78
 
79
- test_tweets, test_labels = get_tweet(test)
80
- test_seq = get_sequences(tokenizer, test_tweets)
81
- test_labels = names_to_ids(test_labels)
82
 
83
- _ = model.evaluate(test_seq, test_labels)
84
- i = random.randint(0, len(test_labels) - 1)
85
- print('Sentence:', test_tweets[i])
86
- print('Emotion:', index_to_class[test_labels[i]])
87
- p = model.predict(np.expand_dims(test_seq[i],axis=0))[0]
88
- pred_class = index_to_class[np.argmax(p).astype('uint8')]
89
-
90
- print('Predicted Emotion:', pred_class)
91
 
92
- preds = (model.predict(test_seq) > 0.5).astype("int32")
93
- print(preds)
94
 
95
  return model
96
 
 
48
  names_to_ids = lambda labels: np.array([class_to_index.get(x) for x in labels])
49
  train_labels = names_to_ids(labels)
50
 
51
+ @spaces.GPU(duration=125)
52
  def load_model():
53
 
54
 
 
76
  ]
77
  )
78
 
79
+ # test_tweets, test_labels = get_tweet(test)
80
+ # test_seq = get_sequences(tokenizer, test_tweets)
81
+ # test_labels = names_to_ids(test_labels)
82
 
83
+ # _ = model.evaluate(test_seq, test_labels)
84
+ # i = random.randint(0, len(test_labels) - 1)
85
+ # print('Sentence:', test_tweets[i])
86
+ # print('Emotion:', index_to_class[test_labels[i]])
87
+ # p = model.predict(np.expand_dims(test_seq[i],axis=0))[0]
88
+ # pred_class = index_to_class[np.argmax(p).astype('uint8')]
89
+
90
+ # print('Predicted Emotion:', pred_class)
91
 
92
+ # preds = (model.predict(test_seq) > 0.5).astype("int32")
93
+ # print(preds)
94
 
95
  return model
96