DeeeTeeee01 commited on
Commit
1367a06
·
1 Parent(s): 3a55b6a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -153,8 +153,12 @@ tokenizer = transformers.AutoTokenizer.from_pretrained("DeeeTeeee01/mytest_train
153
  def tokenizer_hash_func(tokenizer):
154
  return tokenizer.__str__()
155
 
 
 
 
 
156
  # Define the function for sentiment analysis
157
- @st.cache(hash_funcs={tokenizers.Tokenizer: tokenizer_hash_func}) # Specify the custom hash function
158
  def predict_sentiment(text):
159
  # Load the pipeline
160
  pipeline = transformers.pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
@@ -166,6 +170,7 @@ def predict_sentiment(text):
166
 
167
  return sentiment, score
168
 
 
169
  # Setting the page configurations
170
  st.set_page_config(
171
  page_title="Sentiment Analysis App",
 
153
  def tokenizer_hash_func(tokenizer):
154
  return tokenizer.__str__()
155
 
156
+ # Define the custom hash function for tokenizers.AddedToken
157
+ def added_token_hash_func(token):
158
+ return token.__str__()
159
+
160
  # Define the function for sentiment analysis
161
+ @st.cache(hash_funcs={tokenizers.Tokenizer: tokenizer_hash_func, tokenizers.AddedToken: added_token_hash_func})
162
  def predict_sentiment(text):
163
  # Load the pipeline
164
  pipeline = transformers.pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
 
170
 
171
  return sentiment, score
172
 
173
+
174
  # Setting the page configurations
175
  st.set_page_config(
176
  page_title="Sentiment Analysis App",