D3V1L1810 commited on
Commit
a426081
·
verified ·
1 Parent(s): 3dfac77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -26,6 +26,7 @@ def predict_text(params):
26
  return {"error": f"Invalid JSON input: {e.msg} at line {e.lineno} column {e.colno}"}
27
 
28
  texts = params.get("urls",[])
 
29
  # api = params.get("api", "")
30
  # job_id = params.get("job_id","")
31
 
@@ -34,7 +35,7 @@ def predict_text(params):
34
 
35
  solutions = []
36
 
37
- for text in texts:
38
  encoding = bert_tokenizer.encode_plus(
39
  text,
40
  add_special_tokens=True,
@@ -54,7 +55,7 @@ def predict_text(params):
54
  pred_label = tf.argmax(logits, axis=1).numpy()[0]
55
 
56
  label = {0: 'BUSINESS', 1: 'COMEDY', 2: 'CRIME', 3: 'FOOD & DRINK', 4: 'POLITICS', 5: 'SPORTS', 6: 'TRAVEL'}
57
- result = {'text':text, 'label':[label[pred_label]]}
58
  solutions.append(result)
59
 
60
  # result_url = f"{api}/{job_id}"
 
26
  return {"error": f"Invalid JSON input: {e.msg} at line {e.lineno} column {e.colno}"}
27
 
28
  texts = params.get("urls",[])
29
+ file_id = params.get("normalfileID",[])
30
  # api = params.get("api", "")
31
  # job_id = params.get("job_id","")
32
 
 
35
 
36
  solutions = []
37
 
38
+ for text,file_id in zip(texts,file_ids):
39
  encoding = bert_tokenizer.encode_plus(
40
  text,
41
  add_special_tokens=True,
 
55
  pred_label = tf.argmax(logits, axis=1).numpy()[0]
56
 
57
  label = {0: 'BUSINESS', 1: 'COMEDY', 2: 'CRIME', 3: 'FOOD & DRINK', 4: 'POLITICS', 5: 'SPORTS', 6: 'TRAVEL'}
58
+ result = {'text':text, 'label':[label[pred_label]], "qcUser" : None,"normalfileID":file_id}
59
  solutions.append(result)
60
 
61
  # result_url = f"{api}/{job_id}"