Update app.py
Browse files
app.py
CHANGED
@@ -25,19 +25,23 @@ if st.button("Predict"):
|
|
25 |
outputs = model(**inputs)
|
26 |
|
27 |
# Extract the predictions
|
28 |
-
predictions =
|
29 |
-
|
|
|
|
|
|
|
|
|
30 |
|
31 |
# Convert predictions to a NumPy array for the calculations
|
32 |
-
|
33 |
|
34 |
# Scale the predictions
|
35 |
-
|
36 |
-
|
37 |
|
38 |
# Display the predictions
|
39 |
labels = ["cohesion", "syntax", "vocabulary", "phraseology", "grammar", "conventions"]
|
40 |
-
for label, score in zip(labels,
|
41 |
st.write(f"{label}: {score:.4f}")
|
42 |
else:
|
43 |
st.write("Please enter some text to get scores.")
|
|
|
25 |
outputs = model(**inputs)
|
26 |
|
27 |
# Extract the predictions
|
28 |
+
predictions = outputs.logits.squeeze()
|
29 |
+
|
30 |
+
# Convert to numpy array if necessary
|
31 |
+
predicted_scores = predictions.numpy()
|
32 |
+
#predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
|
33 |
+
#predictions = predictions[0].tolist()
|
34 |
|
35 |
# Convert predictions to a NumPy array for the calculations
|
36 |
+
#predictions_np = np.array(predictions)
|
37 |
|
38 |
# Scale the predictions
|
39 |
+
scaled_scores = 2.25 * predictions_scores - 1.25
|
40 |
+
rounded_scores = [round(score * 2) / 2 for score in scaled_scores] # Round to nearest 0.5
|
41 |
|
42 |
# Display the predictions
|
43 |
labels = ["cohesion", "syntax", "vocabulary", "phraseology", "grammar", "conventions"]
|
44 |
+
for label, score in zip(labels, rounded_scores):
|
45 |
st.write(f"{label}: {score:.4f}")
|
46 |
else:
|
47 |
st.write("Please enter some text to get scores.")
|