Spaces:
Runtime error
Runtime error
Update app.py
Browse files12345620 unmodified lines27282930313233343536373839import streamlit as stfrom transformers import AutoModelForSequenceClassification, AutoTokenizerimport torch# Load the model and tokenizer from Hugging Facemodel_name = "KevSun/Engessay_grading_ML"20 unmodified linespredictions = torch.nn.functional.softmax(outputs.logits, dim=-1)predictions = predictions[0].tolist()# Display the predictionslabels = ["cohesion", "syntax", "vocabulary", "phraseology", "grammar", "conventions"]scaled_scores = 2.25 * predictions - 1.25rounded_scores = [round(score * 2) / 2 for score in scaled_scores] # Round to nearest 0.5#for item, score in zip(item_names, rounded_scores):# print(f"{item}: {score:.1f}")for label, score in zip(labels, rounded_scores):st.write(f"{label}: {score:.4f}")else:123456720 unmodified lines282930313233343536373839404142import streamlit as stfrom transformers import AutoModelForSequenceClassification, AutoTokenizerimport torchimport numpy as np # Add this import for NumPy# Load the model and tokenizer from Hugging Facemodel_name = "KevSun/Engessay_grading_ML"20 unmodified linespredictions = torch.nn.functional.softmax(outputs.logits, dim=-1)predictions = predictions[0].tolist()# Convert predictions to a NumPy array for the calculationspredictions_np = np.array(predictions)# Scale the predictionsscaled_scores = 2.25 * predictions_np - 1.25rounded_scores = [round(score * 2) / 2 for score in scaled_scores] # Round to nearest 0.5# Display the predictionslabels = ["cohesion", "syntax", "vocabulary", "phraseology", "grammar", "conventions"]for label, score in zip(labels, rounded_scores):st.write(f"{label}: {score:.4f}")else:
app.py+8-5