KevSun commited on
Commit
af7d153
·
verified ·
1 Parent(s): 0a8afbb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -25,19 +25,23 @@ if st.button("Predict"):
25
  outputs = model(**inputs)
26
 
27
  # Extract the predictions
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, predictions):
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.")