wanshiiii's picture
Upload 2 files
c7de626 verified
import streamlit as st
from transformers import pipeline
st.set_page_config(page_title="AI Grammar Assistant", page_icon="πŸ“")
st.title("πŸ“ AI Grammar Assistant")
st.write("Enter your text below and get instant grammar corrections!")
# Load Hugging Face model
@st.cache_resource
def load_model():
return pipeline("text2text-generation", model="vennify/t5-base-grammar-correction")
corrector = load_model()
user_input = st.text_area("Your text", height=200)
if st.button("Correct Grammar"):
if user_input.strip() == "":
st.warning("⚠️ Please enter some text to correct.")
else:
with st.spinner("Correcting grammar..."):
try:
result = corrector(user_input, max_length=128)[0]['generated_text']
st.success("βœ… Corrected Text:")
st.write(result)
except Exception as e:
st.error(f"Something went wrong: {e}")
st.markdown("---")
st.markdown("Made by [Wanshika Patro](https://github.com/wanshika)")