Spaces:
Runtime error
Runtime error
Commit
·
aa752b7
1
Parent(s):
585c098
Update app.py
Browse files
app.py
CHANGED
@@ -143,20 +143,11 @@
|
|
143 |
import streamlit as st
|
144 |
import transformers
|
145 |
import torch
|
146 |
-
import tokenizers # Import tokenizers explicitly
|
147 |
|
148 |
# Load the model and tokenizer
|
149 |
model = transformers.AutoModelForSequenceClassification.from_pretrained("DeeeTeeee01/mytest_trainer_roberta-base")
|
150 |
tokenizer = transformers.AutoTokenizer.from_pretrained("DeeeTeeee01/mytest_trainer_roberta-base")
|
151 |
|
152 |
-
# Define the custom hash function for tokenizers.Tokenizer (Unused in this version)
|
153 |
-
def tokenizer_hash_func(tokenizer):
|
154 |
-
return tokenizer.__str__()
|
155 |
-
|
156 |
-
# Define the custom hash function for tokenizers.AddedToken (Unused in this version)
|
157 |
-
def added_token_hash_func(token):
|
158 |
-
return token.__str__()
|
159 |
-
|
160 |
# Define the function for sentiment analysis without caching
|
161 |
def predict_sentiment(text):
|
162 |
# Load the pipeline
|
@@ -196,9 +187,9 @@ if predict_button and text:
|
|
196 |
|
197 |
# Display individual percentages
|
198 |
st.write("Sentiment Breakdown:")
|
199 |
-
st.write(f"- Negative: {score[
|
200 |
-
st.write(f"- Positive: {score[
|
201 |
-
st.write(f"- Neutral: {score[
|
202 |
|
203 |
# Define the CSS style for the app
|
204 |
st.markdown(
|
|
|
143 |
import streamlit as st
|
144 |
import transformers
|
145 |
import torch
|
|
|
146 |
|
147 |
# Load the model and tokenizer
|
148 |
model = transformers.AutoModelForSequenceClassification.from_pretrained("DeeeTeeee01/mytest_trainer_roberta-base")
|
149 |
tokenizer = transformers.AutoTokenizer.from_pretrained("DeeeTeeee01/mytest_trainer_roberta-base")
|
150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
# Define the function for sentiment analysis without caching
|
152 |
def predict_sentiment(text):
|
153 |
# Load the pipeline
|
|
|
187 |
|
188 |
# Display individual percentages
|
189 |
st.write("Sentiment Breakdown:")
|
190 |
+
st.write(f"- Negative: {score[0]*100:.2f}%")
|
191 |
+
st.write(f"- Positive: {score[1]*100:.2f}%")
|
192 |
+
st.write(f"- Neutral: {score[2]*100:.2f}%")
|
193 |
|
194 |
# Define the CSS style for the app
|
195 |
st.markdown(
|