tweetpie commited on
Commit
41fa603
·
verified ·
1 Parent(s): 3e9b986

Update layout

Browse files
Files changed (1) hide show
  1. app.py +19 -15
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.cache(allow_output_mutation=True)
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
- # Sidebar setup for configuration
14
- st.sidebar.header("Configuration")
15
- model_selection = st.sidebar.selectbox(
16
- "Select a model",
17
  options=['alm', 'blm'],
18
  index=0 # Default selection
19
  )
20
 
21
- # Sidebar inputs with headers for entities and aspects
22
- st.sidebar.header("Entities")
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
- st.sidebar.header("Aspects")
28
- pro_aspects = st.sidebar.text_input("Pro Aspects", help="Enter pro aspects separated by commas")
29
- anti_aspects = st.sidebar.text_input("Anti Aspects", help="Enter anti aspects separated by commas")
30
- neutral_aspects = st.sidebar.text_input("Neutral Aspects", help="Enter neutral aspects separated by commas")
 
31
 
32
- generate_button = st.sidebar.button("Generate")
 
 
 
 
 
 
 
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()