CoolFace
Apppublic

PurtiSharma/toxic_comments

sourceHugging Faceupdated 3y agoView on Hugging Face
1likes
app.py45 linesDownload Raw Back to root
1import streamlit as st2import pickle3 4 5new_model = pickle.load(open('mytoxiccomentlgmodel.pickle', 'rb'))6 7 8def welcome():9    return "Welcome to my app"10 11 12def main():13    st.title("Detect Toxic Comments App")14    st.write(15        "This app employs NLP to assess whether online comments are toxic or not, providing users with valuable insights")16    html_temp = """17    <div style="background-color:tomato;padding:10px">18    <h2 style="color:white;text-align:center;">Toxic Comment Detector </h2>19    </div>20    """21    st.markdown(html_temp, unsafe_allow_html=True)22 23    text = st.text_input("Enter your comments")24 25 26    if st.button("Predict"):27        pred_prob = new_model.predict([text])28        st.subheader("AI thinks that ...")29 30        if pred_prob == 0:31 32            st.success(33                f"Online comment is not toxic, you can trust it.",icon="✅")34        else:35            st.warning(36                f"Beware!! Online comment is toxic.", icon="⚠️")37 38    if st.button("About"):39 40        st.text("Built with Streamlit")41 42 43if __name__ == '__main__':44    main()45