| 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") |
| |
|
|
| 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"]) |
|
|