Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,8 +2,6 @@ import streamlit as st
|
|
2 |
from transformers import AutoTokenizer, TFAutoModelForSequenceClassification
|
3 |
import tensorflow as tf
|
4 |
|
5 |
-
# Load the fine-tuned model
|
6 |
-
model_path = "./model" # Replace with your model path
|
7 |
tokenizer = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
|
8 |
model = TFAutoModelForSequenceClassification.from_pretrained('spectre0108/roberta-finetune-slangs')
|
9 |
|
@@ -13,10 +11,8 @@ def predict_sentiment(text):
|
|
13 |
output = model(tokenized)
|
14 |
logits = output.logits.numpy()
|
15 |
|
16 |
-
# Apply softmax to each row (axis=1)
|
17 |
probabilities = tf.nn.softmax(logits, axis=1).numpy()
|
18 |
|
19 |
-
# Get the predicted label (class with the highest probability)
|
20 |
predicted_label = tf.argmax(probabilities, axis=1).numpy().item()
|
21 |
positive_prob = probabilities[0][1]
|
22 |
negative_prob = probabilities[0][0]
|
|
|
2 |
from transformers import AutoTokenizer, TFAutoModelForSequenceClassification
|
3 |
import tensorflow as tf
|
4 |
|
|
|
|
|
5 |
tokenizer = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
|
6 |
model = TFAutoModelForSequenceClassification.from_pretrained('spectre0108/roberta-finetune-slangs')
|
7 |
|
|
|
11 |
output = model(tokenized)
|
12 |
logits = output.logits.numpy()
|
13 |
|
|
|
14 |
probabilities = tf.nn.softmax(logits, axis=1).numpy()
|
15 |
|
|
|
16 |
predicted_label = tf.argmax(probabilities, axis=1).numpy().item()
|
17 |
positive_prob = probabilities[0][1]
|
18 |
negative_prob = probabilities[0][0]
|