Erfan11 commited on
Commit
3e04185
1 Parent(s): 043a657

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -4,14 +4,14 @@ from transformers import TFBertForSequenceClassification, BertTokenizerFast
4
  def load_model(model_name):
5
  try:
6
  # Load TensorFlow model from Hugging Face
7
- model = TFBertForSequenceClassification.from_pretrained(model_name, use_auth_token=os.getenv('API_KEY'))
8
  except OSError:
9
  # Fallback to PyTorch model if TensorFlow fails
10
- model = TFBertForSequenceClassification.from_pretrained(model_name, use_auth_token=os.getenv('API_KEY'), from_pt=True)
11
  return model
12
 
13
  def load_tokenizer(model_name):
14
- tokenizer = BertTokenizerFast.from_pretrained(model_name, use_auth_token=os.getenv('API_KEY'))
15
  return tokenizer
16
 
17
  def predict(text, model, tokenizer):
@@ -20,7 +20,7 @@ def predict(text, model, tokenizer):
20
  return outputs
21
 
22
  def main():
23
- model_name = os.getenv('MODEL_PATH')
24
  if model_name is None:
25
  raise ValueError("MODEL_PATH environment variable not set or is None")
26
 
 
4
  def load_model(model_name):
5
  try:
6
  # Load TensorFlow model from Hugging Face
7
+ model = TFBertForSequenceClassification.from_pretrained(model_name, use_auth_token=os.getenv('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'))
8
  except OSError:
9
  # Fallback to PyTorch model if TensorFlow fails
10
+ model = TFBertForSequenceClassification.from_pretrained(model_name, use_auth_token=os.getenv('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'), from_pt=True)
11
  return model
12
 
13
  def load_tokenizer(model_name):
14
+ tokenizer = BertTokenizerFast.from_pretrained(model_name, use_auth_token=os.getenv('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'))
15
  return tokenizer
16
 
17
  def predict(text, model, tokenizer):
 
20
  return outputs
21
 
22
  def main():
23
+ model_name = os.getenv('Erfan11/Neuracraft')
24
  if model_name is None:
25
  raise ValueError("MODEL_PATH environment variable not set or is None")
26