Erfan11 commited on
Commit
e1fff91
1 Parent(s): 01cf15b

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -32
main.py CHANGED
@@ -1,33 +1,4 @@
1
- import os
2
- from dotenv import load_dotenv
3
- from transformers import TFBertForSequenceClassification, BertTokenizerFast
4
- import tensorflow as tf
5
 
6
- # Load environment variables from .env file
7
- load_dotenv()
8
-
9
- def load_model(model_name):
10
- # Load the TensorFlow model from Hugging Face Hub
11
- model = TFBertForSequenceClassification.from_pretrained(model_name, use_auth_token=os.getenv('API_KEY'))
12
- return model
13
-
14
- def load_tokenizer(model_name):
15
- tokenizer = BertTokenizerFast.from_pretrained(model_name, use_auth_token=os.getenv('API_KEY'))
16
- return tokenizer
17
-
18
- def predict(text, model, tokenizer):
19
- inputs = tokenizer(text, return_tensors="tf")
20
- outputs = model(**inputs)
21
- return outputs
22
-
23
- def main():
24
- model_name = os.getenv('MODEL_PATH')
25
- model = load_model(model_name)
26
- tokenizer = load_tokenizer(model_name)
27
- # Example usage
28
- text = "Sample input text"
29
- result = predict(text, model, tokenizer)
30
- print(result)
31
-
32
- if __name__ == "__main__":
33
- main()
 
1
+ from app import app
 
 
 
2
 
3
+ if __name__ == '__main__':
4
+ app.run(debug=True)