ZeeAI1's picture
Update app.py
0129c4f verified
raw
history blame
708 Bytes
from transformers import pipeline
import streamlit as st
# Load grammar correction model
@st.cache_resource
def load_model():
return pipeline("text2text-generation", model="vennify/t5-base-grammar-correction")
corrector = load_model()
# Streamlit UI
st.title("Grammar Correction Assistant")
user_input = st.text_area("Enter a sentence to correct:", "She don't like going to the gym because it make her tired.")
if st.button("Correct Sentence"):
with st.spinner("Correcting..."):
result = corrector(user_input, max_length=100, clean_up_tokenization_spaces=True)
corrected_sentence = result[0]['generated_text']
st.markdown(f"**Corrected Sentence:** {corrected_sentence}")