Spaces:
Sleeping
Sleeping
Update main.py
Browse files
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
|
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 |
|