fixes]
Browse files
app.py
CHANGED
@@ -16,6 +16,7 @@ from sentence_transformers import SentenceTransformer
|
|
16 |
import plotly.express as px
|
17 |
import pandas as pd
|
18 |
from sklearn.decomposition import PCA
|
|
|
19 |
|
20 |
st.set_page_config(page_title="Mental disorder by description", page_icon="🤖")
|
21 |
|
@@ -27,10 +28,10 @@ def convert_string_to_numpy_array(s):
|
|
27 |
#load the model
|
28 |
@st.cache_resource
|
29 |
def get_models():
|
30 |
-
st.write('Loading the model
|
31 |
name = "stsb-bert-large"
|
32 |
model = SentenceTransformer(name)
|
33 |
-
st.write("The app is loaded and ready to use
|
34 |
lemmatizer = WordNetLemmatizer()
|
35 |
return model, lemmatizer
|
36 |
|
@@ -134,33 +135,29 @@ def vis_results_3d(input_embed):
|
|
134 |
# creating an interactive 3D scatter plot
|
135 |
fig = px.scatter_3d(combined_3d, x='PC1', y='PC2', z='PC3', text='Name', color='Type', symbol='Type', width=800, height=800)
|
136 |
fig.show()
|
137 |
-
|
138 |
-
# with st.spinner("Please wait while your Tweet is being generated..."):
|
139 |
-
# mood_prompt = f"{mood} " if mood else ""
|
140 |
-
# if style:
|
141 |
-
# twitter = twe.Tweets(account=style)
|
142 |
-
# tweets = twitter.fetch_tweets()
|
143 |
-
# tweets_prompt = "\n\n".join(tweets)
|
144 |
-
# prompt = (
|
145 |
-
# f"Write a {mood_prompt}Tweet about {topic} in less than 120 characters "
|
146 |
-
# f"and in the style of the following Tweets:\n\n{tweets_prompt}\n\n"
|
147 |
-
|
148 |
# Configure Streamlit page and state
|
149 |
st.title("Detect your character's mental disorder!")
|
150 |
st.markdown(
|
151 |
-
"This mini-app predicts top-5 most likely mental disorder based on your description. The more information you provide, the more informative the results will be.
|
152 |
-
Note that this app can't be used for diagnostic purposes."
|
153 |
)
|
154 |
-
|
155 |
input = st.text_input(label="Your description", placeholder="Insert a description of your character")
|
156 |
if input:
|
157 |
input_embed = model.encode(input)
|
158 |
sim_score = similarity_top(input_embed, icd_embeddings)
|
159 |
-
|
160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
vis_results_2d(input_embed)
|
162 |
vis_results_3d(input_embed)
|
163 |
|
164 |
|
165 |
|
166 |
-
|
|
|
16 |
import plotly.express as px
|
17 |
import pandas as pd
|
18 |
from sklearn.decomposition import PCA
|
19 |
+
import time
|
20 |
|
21 |
st.set_page_config(page_title="Mental disorder by description", page_icon="🤖")
|
22 |
|
|
|
28 |
#load the model
|
29 |
@st.cache_resource
|
30 |
def get_models():
|
31 |
+
st.write('*Loading the model...*')
|
32 |
name = "stsb-bert-large"
|
33 |
model = SentenceTransformer(name)
|
34 |
+
st.write("*The app is loaded and ready to use!*")
|
35 |
lemmatizer = WordNetLemmatizer()
|
36 |
return model, lemmatizer
|
37 |
|
|
|
135 |
# creating an interactive 3D scatter plot
|
136 |
fig = px.scatter_3d(combined_3d, x='PC1', y='PC2', z='PC3', text='Name', color='Type', symbol='Type', width=800, height=800)
|
137 |
fig.show()
|
138 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
# Configure Streamlit page and state
|
140 |
st.title("Detect your character's mental disorder!")
|
141 |
st.markdown(
|
142 |
+
"This mini-app predicts top-5 most likely mental disorder based on your description. The more information you provide, the more informative the results will be."
|
|
|
143 |
)
|
144 |
+
st.caption("Note that this app can't be used for diagnostic purposes.")
|
145 |
input = st.text_input(label="Your description", placeholder="Insert a description of your character")
|
146 |
if input:
|
147 |
input_embed = model.encode(input)
|
148 |
sim_score = similarity_top(input_embed, icd_embeddings)
|
149 |
+
i = 1
|
150 |
+
for dis, value in sim_score:
|
151 |
+
st.write(f":green[Prediction number] {i}:")
|
152 |
+
st.write(f"{dis} (similarity score:", value, ")")
|
153 |
+
i+= 1
|
154 |
+
|
155 |
+
text_spinner_placeholder = st.empty()
|
156 |
+
with st.spinner("Please wait while your visualizations are being generated..."):
|
157 |
+
time.sleep(5)
|
158 |
vis_results_2d(input_embed)
|
159 |
vis_results_3d(input_embed)
|
160 |
|
161 |
|
162 |
|
163 |
+
|