Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
|
@@ -25,16 +25,20 @@ def download_spacy_model(model="en"):
|
|
| 25 |
return True
|
| 26 |
|
| 27 |
|
| 28 |
-
@st.cache(
|
| 29 |
def get_model(model_name):
|
| 30 |
return HappyTextToText("T5", model_name)
|
| 31 |
|
| 32 |
|
| 33 |
-
@st.cache(
|
| 34 |
def get_annotator(lang: str):
|
| 35 |
return errant.load(lang)
|
| 36 |
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
def main():
|
| 39 |
st.title("π€ Writing Assistant")
|
| 40 |
st.markdown(
|
|
@@ -59,7 +63,7 @@ def main():
|
|
| 59 |
start = time.time()
|
| 60 |
with st.spinner("Checking for errors π"):
|
| 61 |
prefixed_input_text = "Grammar: " + input_text
|
| 62 |
-
result = model
|
| 63 |
|
| 64 |
try:
|
| 65 |
show_highlights(annotator, input_text, result)
|
|
|
|
| 25 |
return True
|
| 26 |
|
| 27 |
|
| 28 |
+
@st.cache(allow_output_mutation=True)
|
| 29 |
def get_model(model_name):
|
| 30 |
return HappyTextToText("T5", model_name)
|
| 31 |
|
| 32 |
|
| 33 |
+
@st.cache(allow_output_mutation=True)
|
| 34 |
def get_annotator(lang: str):
|
| 35 |
return errant.load(lang)
|
| 36 |
|
| 37 |
|
| 38 |
+
def predict(model, args, text: str):
|
| 39 |
+
return model.generate_text(text, args=args).text
|
| 40 |
+
|
| 41 |
+
|
| 42 |
def main():
|
| 43 |
st.title("π€ Writing Assistant")
|
| 44 |
st.markdown(
|
|
|
|
| 63 |
start = time.time()
|
| 64 |
with st.spinner("Checking for errors π"):
|
| 65 |
prefixed_input_text = "Grammar: " + input_text
|
| 66 |
+
result = predict(model, args, prefixed_input_text)
|
| 67 |
|
| 68 |
try:
|
| 69 |
show_highlights(annotator, input_text, result)
|