File size: 1,024 Bytes
c7de626
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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)")