Spaces:
Runtime error
Runtime error
import streamlit as st | |
from transformers import pipeline | |
# Load the grammar correction model pipeline | |
corrector = pipeline("text2text-generation", model="vennify/t5-base-grammar-correction") | |
# Load the text classification model pipeline | |
classifier = pipeline("text-classification", model="Alicewuu/bias_detection", return_all_scores=True) | |
# Streamlit application title | |
st.title("Text Bias Detection") | |
st.write("Detection for 2 classes") | |
# Text input for user to enter the text to classify | |
text = st.text_area("Enter the text to detect", "") | |
# Perform text classification when the user clicks the "Detect" button | |
if st.button("Detect"): | |
corrected_text = corrector(text, num_beams=5, max_length=1000)[0]["generated_text"] | |
result = classifier(corrected_text) | |
bias_score = result[0][0]["score"] | |
bias_detected = bias_score >= 0.5 | |
# Display the classification result | |
st.write("The text with correct grammar:", corrected_text) | |
st.write("Biased:", bias_detected) | |
st.write("Score:", bias_score) | |