Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,20 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
from transformers import pipeline
|
4 |
-
except ModuleNotFoundError:
|
5 |
-
import subprocess
|
6 |
-
subprocess.check_call(["pip", "install", "transformers"])
|
7 |
-
from transformers import pipeline
|
8 |
|
9 |
-
#
|
10 |
-
|
|
|
|
|
11 |
|
12 |
-
|
13 |
-
sentence = "She don't like going to the gym because it make her tired."
|
14 |
|
15 |
-
#
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
+
# Load grammar correction pipeline
|
5 |
+
@st.cache_resource
|
6 |
+
def load_model():
|
7 |
+
return pipeline("text2text-generation", model="vennify/t5-base-grammar-correction")
|
8 |
|
9 |
+
corrector = load_model()
|
|
|
10 |
|
11 |
+
# Streamlit UI
|
12 |
+
st.title("Grammar Correction Assistant")
|
13 |
+
|
14 |
+
user_input = st.text_area("Enter a sentence to correct:", "She don't like going to the gym because it make her tired.")
|
15 |
+
|
16 |
+
if st.button("Correct Sentence"):
|
17 |
+
with st.spinner("Correcting..."):
|
18 |
+
result = corrector(user_input, max_length=100, clean_up_tokenization_spaces=True)
|
19 |
+
corrected_sentence = result[0]['generated_text']
|
20 |
+
st.markdown(f"**Corrected Sentence:** {corrected_sentence}")
|