aseifert commited on
Commit
72d34c7
β€’
1 Parent(s): d4288df

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -25,16 +25,20 @@ def download_spacy_model(model="en"):
25
  return True
26
 
27
 
28
- @st.cache(suppress_st_warning=True, allow_output_mutation=True)
29
  def get_model(model_name):
30
  return HappyTextToText("T5", model_name)
31
 
32
 
33
- @st.cache(suppress_st_warning=True, allow_output_mutation=True)
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.generate_text(prefixed_input_text, args=args).text
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)