File size: 1,116 Bytes
741ea16
a7cd630
 
741ea16
a7cd630
 
 
 
 
 
 
 
 
 
 
 
 
7e9aed2
 
 
 
 
741ea16
 
 
 
 
 
 
7e9aed2
 
741ea16
7e9aed2
 
 
741ea16
7e9aed2
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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...
@st.cache_resource
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.")