polite / app.py
mber's picture
Add application file
511e57c
raw
history blame contribute delete
608 Bytes
import streamlit as st
from transformers import pipeline
if "classifier" not in st.session_state:
st.session_state["classifier"] = pipeline("text-classification", "Intel/polite-guard")
st.text_input("Your text here:", key="name")
# st.session_state.name
if "result" not in st.session_state:
st.session_state["result"] = "No result yet"
def click_button():
output = st.session_state["classifier"](st.session_state.name)
print(output)
st.session_state["result"] = output[0]["label"]
st.button('Run', on_click=click_button)
text1 = st.text_area('Result: ', st.session_state["result"])