service-internal commited on
Commit
58ca4fd
·
verified ·
1 Parent(s): 3683686

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +6 -1
main.py CHANGED
@@ -50,10 +50,15 @@ async def analyze(request: Request):
50
  probs_chunk = softmax(output[0][0].detach().numpy())
51
  all_probs.append(probs_chunk)
52
  probs = np.mean(all_probs, axis=0)
 
 
 
53
 
 
54
  result = [
55
  {"label": config.id2label[i], "score": round(float(probs[i]), 4)}
56
- for i in probs.argsort()[::-1]
57
  ]
 
58
  return {"result": result}
59
 
 
50
  probs_chunk = softmax(output[0][0].detach().numpy())
51
  all_probs.append(probs_chunk)
52
  probs = np.mean(all_probs, axis=0)
53
+
54
+ # Define the fixed order
55
+ fixed_order = ["Negative", "Neutral", "Positive"]
56
 
57
+ # Build the result using fixed order
58
  result = [
59
  {"label": config.id2label[i], "score": round(float(probs[i]), 4)}
60
+ for label in fixed_order
61
  ]
62
+
63
  return {"result": result}
64