Erfan11 commited on
Commit
dd3e152
1 Parent(s): 59071e6

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +12 -6
utils.py CHANGED
@@ -1,7 +1,13 @@
1
- import tensorflow as tf
2
- from load_model import load_model
 
3
 
4
- def predict(text):
5
- model = load_model()
6
- prediction = model.predict([text])
7
- return prediction
 
 
 
 
 
 
1
+ import requests
2
+ from dotenv import load_dotenv
3
+ import os
4
 
5
+ load_dotenv()
6
+ api_key = os.getenv('HF_API_KEY')
7
+ model_path = os.getenv('MODEL_PATH')
8
+
9
+ def get_model_predictions(text):
10
+ headers = {"Authorization": f"Bearer {api_key}"}
11
+ payload = {"inputs": text}
12
+ response = requests.post(f"https://api.huggingface.co/models/{model_path}", headers=headers, json=payload)
13
+ return response.json()