Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoModelForTokenClassification, pipeline
|
| 3 |
|
|
@@ -45,7 +46,32 @@ pipeline = BiasPipeline()
|
|
| 45 |
|
| 46 |
# Streamlit interface
|
| 47 |
st.title('UnBIAS App')
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
if st.button("Process Text"):
|
| 50 |
if input_text:
|
| 51 |
cleaned_text = pipeline.clean_text(input_text)
|
|
|
|
| 1 |
+
%%writefile debias_app.py
|
| 2 |
import streamlit as st
|
| 3 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoModelForTokenClassification, pipeline
|
| 4 |
|
|
|
|
| 46 |
|
| 47 |
# Streamlit interface
|
| 48 |
st.title('UnBIAS App')
|
| 49 |
+
# List of preloaded example sentences
|
| 50 |
+
example_sentences = [
|
| 51 |
+
"Women are just too emotional to be leaders.",
|
| 52 |
+
"All young people are lazy and addicted to their phones.",
|
| 53 |
+
"People from that country are always dishonest and corrupt.",
|
| 54 |
+
"Men are inherently better at science and math than women.",
|
| 55 |
+
"The elderly are just burdens to society; they contribute nothing.",
|
| 56 |
+
"All poor people are lazy and don't want to work.",
|
| 57 |
+
"People who follow that religion are all terrorists.",
|
| 58 |
+
"Immigrants are taking all our jobs and ruining the country.",
|
| 59 |
+
"All wealthy people achieved success only through manipulation and deceit.",
|
| 60 |
+
"People with tattoos are not professional.",
|
| 61 |
+
"All politicians are liars and cannot be trusted.",
|
| 62 |
+
"Blue-collar workers don't have any real skills.",
|
| 63 |
+
"Anyone who doesn't attend college is unintelligent.",
|
| 64 |
+
"Only people from the city are sophisticated.",
|
| 65 |
+
"Rural folks have backward mindsets and don't understand progress.",
|
| 66 |
+
"All artists are always broke and unreliable.",
|
| 67 |
+
"Anyone from that region is uneducated and narrow-minded.",
|
| 68 |
+
"People without jobs are simply not trying hard enough."
|
| 69 |
+
]
|
| 70 |
+
|
| 71 |
+
# Dropdown for selecting an example sentence or entering your own
|
| 72 |
+
selected_sentence = st.selectbox("Choose an example or type your own below:", [""] + example_sentences)
|
| 73 |
+
input_text = st.text_area("Enter text:", selected_sentence, height=150)
|
| 74 |
+
|
| 75 |
if st.button("Process Text"):
|
| 76 |
if input_text:
|
| 77 |
cleaned_text = pipeline.clean_text(input_text)
|