peter2000 commited on
Commit
1f50356
1 Parent(s): f2c5498

Update apps/intro.py

Browse files
Files changed (1) hide show
  1. apps/intro.py +5 -3
apps/intro.py CHANGED
@@ -8,7 +8,7 @@ import os
8
  import joblib
9
 
10
  def app():
11
- word_to_embed_list = ["first"]
12
  with st.container():
13
  word_to_embed= st.text_input("Please enter your text here and we will embed it for you.",
14
  value="Woman",)
@@ -22,6 +22,8 @@ def app():
22
  umap_model= joblib.load(cached_download(hf_hub_url(REPO_ID, FILENAME)))
23
 
24
  word_to_embed_list.append(word_to_embed)
 
 
25
  examples_embeddings = model.encode(word_to_embed_list)
26
 
27
  examples_umap = umap_model.transform(examples_embeddings)
@@ -30,9 +32,9 @@ def app():
30
 
31
  with st.spinner("👑 create visualisation"):
32
  fig = px.scatter_3d(
33
- examples_umap , x=0, y=1, z=2,
34
  # color='labels',
35
- opacity = .5, hover_data=[word_to_embed_list])
36
  fig.update_scenes(xaxis_visible=False, yaxis_visible=False,zaxis_visible=False )
37
  fig.update_traces(marker_size=4)
38
  st.plotly_chart(fig)
 
8
  import joblib
9
 
10
  def app():
11
+ word_to_embed_list = st.session_state['embed_list']
12
  with st.container():
13
  word_to_embed= st.text_input("Please enter your text here and we will embed it for you.",
14
  value="Woman",)
 
22
  umap_model= joblib.load(cached_download(hf_hub_url(REPO_ID, FILENAME)))
23
 
24
  word_to_embed_list.append(word_to_embed)
25
+ st.session_state['embed_list'] = word_to_embed_list
26
+
27
  examples_embeddings = model.encode(word_to_embed_list)
28
 
29
  examples_umap = umap_model.transform(examples_embeddings)
 
32
 
33
  with st.spinner("👑 create visualisation"):
34
  fig = px.scatter_3d(
35
+ examples_umap[1:] , x=0, y=1, z=2,
36
  # color='labels',
37
+ opacity = .7, hover_data=[word_to_embed_list[1:]])
38
  fig.update_scenes(xaxis_visible=False, yaxis_visible=False,zaxis_visible=False )
39
  fig.update_traces(marker_size=4)
40
  st.plotly_chart(fig)