Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,22 +10,25 @@ bert_tokenizer = BertTokenizer.from_pretrained('BinaryTokenizer_ep5') #path +
|
|
| 10 |
bert_model = TFBertForSequenceClassification.from_pretrained('BinaryModel_ep5')
|
| 11 |
|
| 12 |
|
| 13 |
-
def send_results_to_api(data, result_url):
|
| 14 |
-
|
| 15 |
-
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
|
| 22 |
|
| 23 |
def predict_text(params):
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
| 26 |
texts = params.get("texts", [])
|
| 27 |
-
api = params.get("api", "")
|
| 28 |
-
job_id = params.get("job_id", "")
|
| 29 |
|
| 30 |
solutions = []
|
| 31 |
|
|
|
|
| 10 |
bert_model = TFBertForSequenceClassification.from_pretrained('BinaryModel_ep5')
|
| 11 |
|
| 12 |
|
| 13 |
+
# def send_results_to_api(data, result_url):
|
| 14 |
+
# headers = {"Content-Type":"application/json"}
|
| 15 |
+
# response = requests.post(result_url, json=data, headers=headers)
|
| 16 |
|
| 17 |
+
# if response.status_code == 200:
|
| 18 |
+
# return response.json()
|
| 19 |
+
# else:
|
| 20 |
+
# return {"error": f"Failed to send results to API: {response.status_code}"}
|
| 21 |
|
| 22 |
|
| 23 |
def predict_text(params):
|
| 24 |
+
try:
|
| 25 |
+
params = json.loads(params)
|
| 26 |
+
except JSONDecodeError as e:
|
| 27 |
+
return {"error": f"Invalid JSON input: {e.msg} at line {e.lineno} column {e.colno}"}
|
| 28 |
+
|
| 29 |
texts = params.get("texts", [])
|
| 30 |
+
# api = params.get("api", "")
|
| 31 |
+
# job_id = params.get("job_id", "")
|
| 32 |
|
| 33 |
solutions = []
|
| 34 |
|