Spaces:
Runtime error
Runtime error
import streamlit as st | |
import sys | |
import subprocess | |
def install(package): | |
subprocess.check_call([sys.executable, "-m", "pip", "install", package]) | |
st.title("Personality Prediction App") | |
try: | |
from transformers import pipeline | |
except ImportError: | |
st.warning("The transformers library is not installed. Attempting to install it now...") | |
install('transformers') | |
st.experimental_rerun() | |
# Rest of your code here... | |
def load_model(): | |
return pipeline("text-classification", model="KevSun/Personality_LM") | |
model = load_model() | |
st.write("Enter your text below to predict personality traits:") | |
user_input = st.text_area("Your text here:") | |
if st.button("Predict"): | |
if user_input: | |
with st.spinner("Analyzing..."): | |
result = model(user_input) | |
st.subheader("Predicted personality traits:") | |
for trait in result: | |
st.write(f"- {trait['label']}: {trait['score']:.2f}") | |
else: | |
st.warning("Please enter some text to analyze.") | |
st.info("Note: This is a demonstration and predictions may not be entirely accurate.") |