Jeffrey Rathgeber Jr commited on
Commit
4ba5dd1
1 Parent(s): df89f66
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -89,7 +89,7 @@ if option == 'MILESTONE 3':
89
 
90
 
91
 
92
- # pred_data = []
93
 
94
  # for i in range(10):
95
  # X_train = pre_populated_tweets[i]
@@ -112,10 +112,21 @@ if option == 'MILESTONE 3':
112
  df = df.assign(Score_Overall=SO)
113
  df = df.assign(Highest_Toxicity_Class_Except_Toxic=HTCET)
114
  df = df.assign(Score_Except_Toxic=SET)
 
 
 
 
 
 
 
 
 
 
 
115
 
116
  st.table(df)
117
 
118
- st.write('test2')
119
 
120
  if option == 'Pipeline':
121
 
 
89
 
90
 
91
 
92
+ pred_data = []
93
 
94
  # for i in range(10):
95
  # X_train = pre_populated_tweets[i]
 
112
  df = df.assign(Score_Overall=SO)
113
  df = df.assign(Highest_Toxicity_Class_Except_Toxic=HTCET)
114
  df = df.assign(Score_Except_Toxic=SET)
115
+
116
+ X_train = pre_populated_tweets[0]
117
+ batch = tokenizers[0](X_train, padding=True, truncation=True, max_length=512, return_tensors="pt")
118
+
119
+ with torch.no_grad():
120
+ outputs = models[0](**batch, labels=torch.tensor([1, 0]))
121
+ predictions = F.softmax(outputs.logits, dim=1)
122
+ labels = torch.argmax(predictions, dim=1)
123
+ labels = [model.config.id2label[label_id] for label_id in labels.tolist()]
124
+ pred_data.append(predictions)
125
+
126
 
127
  st.table(df)
128
 
129
+ st.write(pred_data)
130
 
131
  if option == 'Pipeline':
132