Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,35 @@
|
|
1 |
import streamlit as st
|
2 |
-
|
|
|
3 |
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
@st.cache_resource
|
6 |
def load_model():
|
7 |
return pipeline("text-classification", model="KevSun/Personality_LM")
|
8 |
|
9 |
model = load_model()
|
10 |
|
11 |
-
st.title("Personality Prediction App")
|
12 |
-
|
13 |
st.write("Enter your text below to predict personality traits:")
|
14 |
|
15 |
user_input = st.text_area("Your text here:")
|
16 |
|
17 |
if st.button("Predict"):
|
18 |
if user_input:
|
19 |
-
# Process the input and get predictions
|
20 |
with st.spinner("Analyzing..."):
|
21 |
result = model(user_input)
|
22 |
|
23 |
-
# Display results
|
24 |
st.subheader("Predicted personality traits:")
|
25 |
for trait in result:
|
26 |
st.write(f"- {trait['label']}: {trait['score']:.2f}")
|
|
|
1 |
import streamlit as st
|
2 |
+
import sys
|
3 |
+
import subprocess
|
4 |
|
5 |
+
def install(package):
|
6 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
|
7 |
+
|
8 |
+
st.title("Personality Prediction App")
|
9 |
+
|
10 |
+
try:
|
11 |
+
from transformers import pipeline
|
12 |
+
except ImportError:
|
13 |
+
st.warning("The transformers library is not installed. Attempting to install it now...")
|
14 |
+
install('transformers')
|
15 |
+
st.experimental_rerun()
|
16 |
+
|
17 |
+
# Rest of your code here...
|
18 |
@st.cache_resource
|
19 |
def load_model():
|
20 |
return pipeline("text-classification", model="KevSun/Personality_LM")
|
21 |
|
22 |
model = load_model()
|
23 |
|
|
|
|
|
24 |
st.write("Enter your text below to predict personality traits:")
|
25 |
|
26 |
user_input = st.text_area("Your text here:")
|
27 |
|
28 |
if st.button("Predict"):
|
29 |
if user_input:
|
|
|
30 |
with st.spinner("Analyzing..."):
|
31 |
result = model(user_input)
|
32 |
|
|
|
33 |
st.subheader("Predicted personality traits:")
|
34 |
for trait in result:
|
35 |
st.write(f"- {trait['label']}: {trait['score']:.2f}")
|