Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
3 |
import torch
|
|
|
4 |
|
5 |
# Load the model and tokenizer from Hugging Face
|
6 |
model_name = "KevSun/Engessay_grading_ML"
|
@@ -27,13 +28,15 @@ if st.button("Predict"):
|
|
27 |
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
|
28 |
predictions = predictions[0].tolist()
|
29 |
|
30 |
-
#
|
31 |
-
|
32 |
-
|
|
|
|
|
33 |
rounded_scores = [round(score * 2) / 2 for score in scaled_scores] # Round to nearest 0.5
|
34 |
|
35 |
-
#
|
36 |
-
|
37 |
for label, score in zip(labels, rounded_scores):
|
38 |
st.write(f"{label}: {score:.4f}")
|
39 |
else:
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
3 |
import torch
|
4 |
+
import numpy as np # Add this import for NumPy
|
5 |
|
6 |
# Load the model and tokenizer from Hugging Face
|
7 |
model_name = "KevSun/Engessay_grading_ML"
|
|
|
28 |
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
|
29 |
predictions = predictions[0].tolist()
|
30 |
|
31 |
+
# Convert predictions to a NumPy array for the calculations
|
32 |
+
predictions_np = np.array(predictions)
|
33 |
+
|
34 |
+
# Scale the predictions
|
35 |
+
scaled_scores = 2.25 * predictions_np - 1.25
|
36 |
rounded_scores = [round(score * 2) / 2 for score in scaled_scores] # Round to nearest 0.5
|
37 |
|
38 |
+
# Display the predictions
|
39 |
+
labels = ["cohesion", "syntax", "vocabulary", "phraseology", "grammar", "conventions"]
|
40 |
for label, score in zip(labels, rounded_scores):
|
41 |
st.write(f"{label}: {score:.4f}")
|
42 |
else:
|