Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,6 +27,7 @@ def predict_text(params):
|
|
| 27 |
return {"error": f"Invalid JSON input: {e.msg} at line {e.lineno} column {e.colno}"}
|
| 28 |
|
| 29 |
texts = params.get("urls", [])
|
|
|
|
| 30 |
# api = params.get("api", "")
|
| 31 |
# job_id = params.get("job_id", "")
|
| 32 |
print("JSON : \n",params)
|
|
@@ -35,7 +36,7 @@ def predict_text(params):
|
|
| 35 |
|
| 36 |
solutions = []
|
| 37 |
|
| 38 |
-
for text in texts:
|
| 39 |
encoding = bert_tokenizer.encode_plus(
|
| 40 |
text,
|
| 41 |
add_special_tokens=True,
|
|
@@ -55,7 +56,7 @@ def predict_text(params):
|
|
| 55 |
pred_label = tf.argmax(logits, axis=1).numpy()[0]
|
| 56 |
|
| 57 |
label = {1: 'positive', 0: 'negative'}
|
| 58 |
-
result = {'text': text, 'label': [label[pred_label]]}
|
| 59 |
solutions.append(result)
|
| 60 |
|
| 61 |
# result_url = f"{api}/{job_id}"
|
|
|
|
| 27 |
return {"error": f"Invalid JSON input: {e.msg} at line {e.lineno} column {e.colno}"}
|
| 28 |
|
| 29 |
texts = params.get("urls", [])
|
| 30 |
+
file_ids = params.get("normalfileID", [])
|
| 31 |
# api = params.get("api", "")
|
| 32 |
# job_id = params.get("job_id", "")
|
| 33 |
print("JSON : \n",params)
|
|
|
|
| 36 |
|
| 37 |
solutions = []
|
| 38 |
|
| 39 |
+
for text, file_id in zip(texts,file_ids):
|
| 40 |
encoding = bert_tokenizer.encode_plus(
|
| 41 |
text,
|
| 42 |
add_special_tokens=True,
|
|
|
|
| 56 |
pred_label = tf.argmax(logits, axis=1).numpy()[0]
|
| 57 |
|
| 58 |
label = {1: 'positive', 0: 'negative'}
|
| 59 |
+
result = {'text': text, 'label': [label[pred_label]], "qcUser" : None, "file_id": file_id}
|
| 60 |
solutions.append(result)
|
| 61 |
|
| 62 |
# result_url = f"{api}/{job_id}"
|