wanshiiii commited on
Commit
c7de626
Β·
verified Β·
1 Parent(s): 56dde82

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +31 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ st.set_page_config(page_title="AI Grammar Assistant", page_icon="πŸ“")
5
+
6
+ st.title("πŸ“ AI Grammar Assistant")
7
+ st.write("Enter your text below and get instant grammar corrections!")
8
+
9
+ # Load Hugging Face model
10
+ @st.cache_resource
11
+ def load_model():
12
+ return pipeline("text2text-generation", model="vennify/t5-base-grammar-correction")
13
+
14
+ corrector = load_model()
15
+
16
+ user_input = st.text_area("Your text", height=200)
17
+
18
+ if st.button("Correct Grammar"):
19
+ if user_input.strip() == "":
20
+ st.warning("⚠️ Please enter some text to correct.")
21
+ else:
22
+ with st.spinner("Correcting grammar..."):
23
+ try:
24
+ result = corrector(user_input, max_length=128)[0]['generated_text']
25
+ st.success("βœ… Corrected Text:")
26
+ st.write(result)
27
+ except Exception as e:
28
+ st.error(f"Something went wrong: {e}")
29
+
30
+ st.markdown("---")
31
+ st.markdown("Made by [Wanshika Patro](https://github.com/wanshika)")
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ streamlit
2
+ transformers
3
+ torch