Spaces:
Running
Running
Upload 2 files
Browse files- app.py +31 -0
- 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
|