noelfranthomas commited on
Commit
912126e
1 Parent(s): 9213373
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -74,6 +74,16 @@ input_text = st.text_input("Enter your text here")
74
 
75
  if st.button("Predict"):
76
 
 
 
 
 
 
 
 
 
 
 
77
  # Tokenize the input text
78
  inputs = tokenizer_t_class.encode(input_text, return_tensors="pt")
79
  # Get the model's predictions
@@ -88,15 +98,4 @@ if st.button("Predict"):
88
  # Filter out subwords
89
  filtered_token_labels = [(token, label) for token, label in token_labels if not token.startswith("##")]
90
  # Return the tokens and their predicted labels
91
- st.write({"token_labels": filtered_token_labels})
92
-
93
-
94
- inputs = tokenizer_emotion(input.text, return_tensors="pt")
95
- # Get the model's predictions
96
- outputs = model_emotion(**inputs)
97
- # Get the predicted class
98
- predicted_class_idx = torch.argmax(outputs.logits).item()
99
- # Decode the predicted class
100
- predicted_class = model_emotion.config.id2label[predicted_class_idx]
101
- # Return the prediction
102
- st.write({"predicted_emotion": predicted_class})
 
74
 
75
  if st.button("Predict"):
76
 
77
+ inputs = tokenizer_emotion(input_text, return_tensors="pt")
78
+ # Get the model's predictions
79
+ outputs = model_emotion(**inputs)
80
+ # Get the predicted class
81
+ predicted_class_idx = torch.argmax(outputs.logits).item()
82
+ # Decode the predicted class
83
+ predicted_class = model_emotion.config.id2label[predicted_class_idx]
84
+ # Return the prediction
85
+ st.write({"predicted_emotion": predicted_class})
86
+
87
  # Tokenize the input text
88
  inputs = tokenizer_t_class.encode(input_text, return_tensors="pt")
89
  # Get the model's predictions
 
98
  # Filter out subwords
99
  filtered_token_labels = [(token, label) for token, label in token_labels if not token.startswith("##")]
100
  # Return the tokens and their predicted labels
101
+ st.write({"token_labels": filtered_token_labels})