|
import streamlit as st |
|
from transformers import AutoModelForSequenceClassification, AutoTokenizer |
|
import torch |
|
import numpy as np |
|
|
|
|
|
model_name = "KevSun/Engessay_grading_ML" |
|
model = AutoModelForSequenceClassification.from_pretrained(model_name) |
|
tokenizer = AutoTokenizer.from_pretrained(model_name) |
|
|
|
|
|
st.title("Automated Scoring App") |
|
st.write("Enter your English essay below to predict scores from multiple dimensions:") |
|
|
|
|
|
user_input = st.text_area("Your text here:") |
|
|
|
if st.button("Predict"): |
|
if user_input: |
|
|
|
inputs = tokenizer(user_input, return_tensors="pt") |
|
|
|
|
|
with torch.no_grad(): |
|
outputs = model(**inputs) |
|
|
|
|
|
predictions = outputs.logits.squeeze() |
|
|
|
|
|
predicted_scores = predictions.numpy() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scaled_scores = 2.25 * predicted_scores - 1.25 |
|
rounded_scores = [round(score * 2) / 2 for score in scaled_scores] |
|
|
|
|
|
labels = ["cohesion", "syntax", "vocabulary", "phraseology", "grammar", "conventions"] |
|
for label, score in zip(labels, rounded_scores): |
|
st.write(f"{label}: {score:}") |
|
else: |
|
st.write("Please enter some text to get scores.") |
|
|