Spaces:
Runtime error
Runtime error
Oliver Li
commited on
Commit
·
d8d71bd
1
Parent(s):
6e993f1
bug fix
Browse files
app.py
CHANGED
@@ -100,7 +100,7 @@ initial_table_data = [{'Text (portion)': ["who's speaking? \n you goddamn cocksu
|
|
100 |
'Toxicity class 2': ['obscene'],
|
101 |
'Class 2 probability': 0.16506287455558777}]
|
102 |
for d in initial_table_data:
|
103 |
-
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:
|
@@ -108,6 +108,7 @@ if st.button("Analyze"):
|
|
108 |
else:
|
109 |
with st.spinner("Analyzing toxicity..."):
|
110 |
if selected_model == "Olivernyu/finetuned_bert_base_uncased":
|
|
|
111 |
toxicity_detector = load_model(selected_model)
|
112 |
outputs = toxicity_detector(text, top_k=2)
|
113 |
category_names = ["toxic", "severe_toxic", "obscene", "threat", "insult", "identity_hate"]
|
@@ -123,7 +124,7 @@ if st.button("Analyze"):
|
|
123 |
"Toxicity class 2": [results[1][0]],
|
124 |
f"Class 2 probability": results[1][1]
|
125 |
}
|
126 |
-
table_df = pd.concat([
|
127 |
st.table(table_df)
|
128 |
else:
|
129 |
sentiment_pipeline = load_model(selected_model)
|
|
|
100 |
'Toxicity class 2': ['obscene'],
|
101 |
'Class 2 probability': 0.16506287455558777}]
|
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:
|
|
|
108 |
else:
|
109 |
with st.spinner("Analyzing toxicity..."):
|
110 |
if selected_model == "Olivernyu/finetuned_bert_base_uncased":
|
111 |
+
st.table(table_df)
|
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"]
|
|
|
124 |
"Toxicity class 2": [results[1][0]],
|
125 |
f"Class 2 probability": results[1][1]
|
126 |
}
|
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)
|