dejanseo commited on
Commit
b9c9f51
Β·
verified Β·
1 Parent(s): 3b51041

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +6 -6
src/streamlit_app.py CHANGED
@@ -10,11 +10,16 @@ st.title("Gemini Token Probabilities")
10
  # --- Load the SentencePiece tokenizer once ---
11
  @st.cache_resource
12
  def load_tokenizer():
13
- model_dir = "gemini-1.5-pro-002"
 
 
 
14
  model_path = os.path.join(model_dir, "gemini-1.5-pro-002.spm.model")
 
15
  if not os.path.isfile(model_path):
16
  st.error(f"Cannot find model at:\n{model_path}")
17
  st.stop()
 
18
  sp = spm.SentencePieceProcessor()
19
  sp.Load(model_path)
20
  return sp
@@ -57,11 +62,6 @@ if st.button("Tokenize"):
57
  })
58
 
59
  # 5) Display with progress bars (as percentages)
60
- #
61
- # - format="percent" tells Streamlit to multiply the 0–1 value by 100 internally
62
- # and append β€œ%” to the label.
63
- # - min_value=0 and max_value=1 anchor the range.
64
- #st.markdown("### Tokenization Result (Global 0–100 %)")
65
  st.dataframe(
66
  df,
67
  use_container_width=True,
 
10
  # --- Load the SentencePiece tokenizer once ---
11
  @st.cache_resource
12
  def load_tokenizer():
13
+ # Determine the directory that this script lives in (i.e. src/)
14
+ here = os.path.dirname(__file__)
15
+ # Build the absolute path to the gemini-1.5-pro-002 folder inside src/
16
+ model_dir = os.path.join(here, "gemini-1.5-pro-002")
17
  model_path = os.path.join(model_dir, "gemini-1.5-pro-002.spm.model")
18
+
19
  if not os.path.isfile(model_path):
20
  st.error(f"Cannot find model at:\n{model_path}")
21
  st.stop()
22
+
23
  sp = spm.SentencePieceProcessor()
24
  sp.Load(model_path)
25
  return sp
 
62
  })
63
 
64
  # 5) Display with progress bars (as percentages)
 
 
 
 
 
65
  st.dataframe(
66
  df,
67
  use_container_width=True,