Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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('
|
8 |
except OSError:
|
9 |
# Fallback to PyTorch model if TensorFlow fails
|
10 |
-
model = TFBertForSequenceClassification.from_pretrained(model_name, use_auth_token=os.getenv('
|
11 |
return model
|
12 |
|
13 |
def load_tokenizer(model_name):
|
14 |
-
tokenizer = BertTokenizerFast.from_pretrained(model_name, use_auth_token=os.getenv('
|
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('
|
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 |
|