Update layout
Browse files
app.py
CHANGED
@@ -2,7 +2,7 @@ import streamlit as st
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
# Initialize the model and tokenizer once, to avoid reloading them on each user interaction
|
5 |
-
@st.
|
6 |
def load_model():
|
7 |
classifier = pipeline("text-classification", model="tweetpie/toxic-content-detector")
|
8 |
return classifier
|
@@ -10,26 +10,30 @@ def load_model():
|
|
10 |
# Set up the title
|
11 |
st.title("Toxic Content Classifier Dashboard")
|
12 |
|
13 |
-
#
|
14 |
-
st.
|
15 |
-
|
16 |
-
"Select a model",
|
17 |
options=['alm', 'blm'],
|
18 |
index=0 # Default selection
|
19 |
)
|
20 |
|
21 |
-
#
|
22 |
-
st.
|
23 |
-
pro_entities = st.sidebar.text_input("Pro Entities", help="Enter pro entities separated by commas")
|
24 |
-
anti_entities = st.sidebar.text_input("Anti Entities", help="Enter anti entities separated by commas")
|
25 |
-
neutral_entities = st.sidebar.text_input("Neutral Entities", help="Enter neutral entities separated by commas")
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
31 |
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
# Load the model
|
35 |
classifier = load_model()
|
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
# Initialize the model and tokenizer once, to avoid reloading them on each user interaction
|
5 |
+
@st.cache_resource
|
6 |
def load_model():
|
7 |
classifier = pipeline("text-classification", model="tweetpie/toxic-content-detector")
|
8 |
return classifier
|
|
|
10 |
# Set up the title
|
11 |
st.title("Toxic Content Classifier Dashboard")
|
12 |
|
13 |
+
# Top-level input for model selection
|
14 |
+
model_selection = st.selectbox(
|
15 |
+
"Select an ideology",
|
|
|
16 |
options=['alm', 'blm'],
|
17 |
index=0 # Default selection
|
18 |
)
|
19 |
|
20 |
+
# Layout for entities and aspects inputs
|
21 |
+
col1, col2 = st.columns(2)
|
|
|
|
|
|
|
22 |
|
23 |
+
with col1:
|
24 |
+
st.header("Entities")
|
25 |
+
pro_entities = st.text_input("Pro Entities", help="Enter pro entities separated by commas")
|
26 |
+
anti_entities = st.text_input("Anti Entities", help="Enter anti entities separated by commas")
|
27 |
+
neutral_entities = st.text_input("Neutral Entities", help="Enter neutral entities separated by commas")
|
28 |
|
29 |
+
with col2:
|
30 |
+
st.header("Aspects")
|
31 |
+
pro_aspects = st.text_input("Pro Aspects", help="Enter pro aspects separated by commas")
|
32 |
+
anti_aspects = st.text_input("Anti Aspects", help="Enter anti aspects separated by commas")
|
33 |
+
neutral_aspects = st.text_input("Neutral Aspects", help="Enter neutral aspects separated by commas")
|
34 |
+
|
35 |
+
# Generate button
|
36 |
+
generate_button = st.button("Generate")
|
37 |
|
38 |
# Load the model
|
39 |
classifier = load_model()
|