KevSun commited on
Commit
7e9aed2
·
verified ·
1 Parent(s): 741ea16

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -2,7 +2,11 @@ import streamlit as st
2
  from transformers import pipeline
3
 
4
  # Load your model
5
- model = pipeline("text-classification", model="KevSun/Personality_LM")
 
 
 
 
6
 
7
  st.title("Personality Prediction App")
8
 
@@ -13,10 +17,14 @@ user_input = st.text_area("Your text here:")
13
  if st.button("Predict"):
14
  if user_input:
15
  # Process the input and get predictions
16
- result = model(user_input)
 
17
 
18
  # Display results
19
- st.write("Predicted personality traits:")
20
- st.write(result)
 
21
  else:
22
- st.write("Please enter some text to analyze.")
 
 
 
2
  from transformers import pipeline
3
 
4
  # Load your model
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
 
 
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}")
27
  else:
28
+ st.warning("Please enter some text to analyze.")
29
+
30
+ st.info("Note: This is a demonstration and predictions may not be entirely accurate.")