Spaces:
Runtime error
Runtime error
Oliver Li
commited on
Commit
·
d1a1e86
1
Parent(s):
d8d71bd
modified table display
Browse files
app.py
CHANGED
@@ -102,13 +102,14 @@ initial_table_data = [{'Text (portion)': ["who's speaking? \n you goddamn cocksu
|
|
102 |
for d in initial_table_data:
|
103 |
table_df = pd.concat([table_df, pd.DataFrame(d)], ignore_index=True)
|
104 |
# Load the model and perform toxicity analysis
|
|
|
105 |
if st.button("Analyze"):
|
106 |
if not text:
|
107 |
st.write("Please enter a text.")
|
108 |
else:
|
109 |
with st.spinner("Analyzing toxicity..."):
|
110 |
if selected_model == "Olivernyu/finetuned_bert_base_uncased":
|
111 |
-
st.
|
112 |
toxicity_detector = load_model(selected_model)
|
113 |
outputs = toxicity_detector(text, top_k=2)
|
114 |
category_names = ["toxic", "severe_toxic", "obscene", "threat", "insult", "identity_hate"]
|
@@ -127,6 +128,7 @@ if st.button("Analyze"):
|
|
127 |
table_df = pd.concat([pd.DataFrame(table_data), table_df], ignore_index=True)
|
128 |
st.table(table_df)
|
129 |
else:
|
|
|
130 |
sentiment_pipeline = load_model(selected_model)
|
131 |
result = sentiment_pipeline(text)
|
132 |
st.write(f"Sentiment: {result[0]['label']} (confidence: {result[0]['score']:.2f})")
|
|
|
102 |
for d in initial_table_data:
|
103 |
table_df = pd.concat([table_df, pd.DataFrame(d)], ignore_index=True)
|
104 |
# Load the model and perform toxicity analysis
|
105 |
+
st.table(table_df)
|
106 |
if st.button("Analyze"):
|
107 |
if not text:
|
108 |
st.write("Please enter a text.")
|
109 |
else:
|
110 |
with st.spinner("Analyzing toxicity..."):
|
111 |
if selected_model == "Olivernyu/finetuned_bert_base_uncased":
|
112 |
+
st.empty()
|
113 |
toxicity_detector = load_model(selected_model)
|
114 |
outputs = toxicity_detector(text, top_k=2)
|
115 |
category_names = ["toxic", "severe_toxic", "obscene", "threat", "insult", "identity_hate"]
|
|
|
128 |
table_df = pd.concat([pd.DataFrame(table_data), table_df], ignore_index=True)
|
129 |
st.table(table_df)
|
130 |
else:
|
131 |
+
st.empty()
|
132 |
sentiment_pipeline = load_model(selected_model)
|
133 |
result = sentiment_pipeline(text)
|
134 |
st.write(f"Sentiment: {result[0]['label']} (confidence: {result[0]['score']:.2f})")
|