Spaces:
Sleeping
Sleeping
import streamlit as st | |
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer, pipeline | |
# Load grammar correction model | |
model_name = "vennify/t5-base-grammar-correction" | |
tokenizer = AutoTokenizer.from_pretrained(model_name) | |
model = AutoModelForSeq2SeqLM.from_pretrained(model_name) | |
pipe = pipeline("text2text-generation", model=model, tokenizer=tokenizer) | |
st.title("✍️ English Grammar & Writing Assistant") | |
text = st.text_area("Enter your sentence or paragraph:") | |
if st.button("Correct Text"): | |
if not text.strip(): | |
st.warning("Please enter some text.") | |
else: | |
input_text = "gec: " + text | |
result = pipe(input_text, max_length=512) | |
corrected = result[0]['generated_text'] | |
st.subheader("✅ Corrected Text:") | |
st.write(corrected) | |