Spaces:
Runtime error
Runtime error
Oliver Li
commited on
Commit
·
c985984
1
Parent(s):
5dd2487
bug fix
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import pandas as pd
|
|
| 3 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
| 4 |
|
| 5 |
# Function to load the pre-trained model
|
| 6 |
-
|
| 7 |
def load_finetune_model(model_name):
|
| 8 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 9 |
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
|
@@ -104,6 +104,9 @@ for d in initial_table_data:
|
|
| 104 |
initial_table_df = pd.concat([initial_table_df, pd.DataFrame(d)], ignore_index=True)
|
| 105 |
# Load the model and perform toxicity analysis
|
| 106 |
|
|
|
|
|
|
|
|
|
|
| 107 |
if st.button("Analyze"):
|
| 108 |
if not text:
|
| 109 |
st.write("Please enter a text.")
|
|
@@ -128,15 +131,11 @@ if st.button("Analyze"):
|
|
| 128 |
# print("Before concatenation:")
|
| 129 |
# print(table_df)
|
| 130 |
# Concatenate the new data frame with the existing data frame
|
| 131 |
-
|
| 132 |
-
ss.table_df = pd.concat([pd.DataFrame(table_data), ss.table_df, initial_table_data], ignore_index=True)
|
| 133 |
-
ss.first_run = False
|
| 134 |
-
else:
|
| 135 |
-
ss.table_df = pd.concat([pd.DataFrame(table_data), ss.table_df], ignore_index=True)
|
| 136 |
# print("After concatenation:")
|
| 137 |
# print(table_df)
|
| 138 |
# Update the table with the new data frame
|
| 139 |
-
st.table(
|
| 140 |
else:
|
| 141 |
st.empty()
|
| 142 |
sentiment_pipeline = load_model(selected_model)
|
|
|
|
| 3 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
| 4 |
|
| 5 |
# Function to load the pre-trained model
|
| 6 |
+
|
| 7 |
def load_finetune_model(model_name):
|
| 8 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 9 |
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
|
|
|
| 104 |
initial_table_df = pd.concat([initial_table_df, pd.DataFrame(d)], ignore_index=True)
|
| 105 |
# Load the model and perform toxicity analysis
|
| 106 |
|
| 107 |
+
if "table" not in st.session_state:
|
| 108 |
+
st.session_state['table'] = initial_table_df
|
| 109 |
+
|
| 110 |
if st.button("Analyze"):
|
| 111 |
if not text:
|
| 112 |
st.write("Please enter a text.")
|
|
|
|
| 131 |
# print("Before concatenation:")
|
| 132 |
# print(table_df)
|
| 133 |
# Concatenate the new data frame with the existing data frame
|
| 134 |
+
st.session_state['table'] = pd.concat([pd.DataFrame(table_data), st.session_state['table']], ignore_index=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
# print("After concatenation:")
|
| 136 |
# print(table_df)
|
| 137 |
# Update the table with the new data frame
|
| 138 |
+
st.table(st.session_state['table'])
|
| 139 |
else:
|
| 140 |
st.empty()
|
| 141 |
sentiment_pipeline = load_model(selected_model)
|