DeeeTeeee01 commited on
Commit
585c098
·
1 Parent(s): 3b89cb9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -149,16 +149,15 @@ import tokenizers # Import tokenizers explicitly
149
  model = transformers.AutoModelForSequenceClassification.from_pretrained("DeeeTeeee01/mytest_trainer_roberta-base")
150
  tokenizer = transformers.AutoTokenizer.from_pretrained("DeeeTeeee01/mytest_trainer_roberta-base")
151
 
152
- # Define the custom hash function for tokenizers.Tokenizer
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_data(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)
@@ -215,4 +214,4 @@ h1 {
215
  </style>
216
  """,
217
  unsafe_allow_html=True
218
- )
 
149
  model = transformers.AutoModelForSequenceClassification.from_pretrained("DeeeTeeee01/mytest_trainer_roberta-base")
150
  tokenizer = transformers.AutoTokenizer.from_pretrained("DeeeTeeee01/mytest_trainer_roberta-base")
151
 
152
+ # Define the custom hash function for tokenizers.Tokenizer (Unused in this version)
153
  def tokenizer_hash_func(tokenizer):
154
  return tokenizer.__str__()
155
 
156
+ # Define the custom hash function for tokenizers.AddedToken (Unused in this version)
157
  def added_token_hash_func(token):
158
  return token.__str__()
159
 
160
+ # Define the function for sentiment analysis without caching
 
161
  def predict_sentiment(text):
162
  # Load the pipeline
163
  pipeline = transformers.pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
 
214
  </style>
215
  """,
216
  unsafe_allow_html=True
217
+ )