Modfiededition commited on
Commit
5c6eae7
β€’
1 Parent(s): a8d72ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -12
app.py CHANGED
@@ -9,27 +9,24 @@ model_checkpoint = "Modfiededition/t5-base-fine-tuned-on-jfleg"
9
 
10
  tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
11
 
12
- @st.cache
13
- def load_model(model_name):
14
- model = TFAutoModelForSeq2SeqLM.from_pretrained(model_name)
15
- return model
16
-
17
- model= load_model(model_checkpoint)
18
 
19
  def infer(input_ids):
20
  output_sequences = model.generate(inputs["input_ids"]).numpy()[0][1:-1]
21
  return output_sequences
22
 
23
- default_value = "Write your text here!"
24
  #prompts
25
  st.title("Writing Assistant for you πŸ¦„")
26
 
27
- sent = st.text_area("Text", default_value, height = 275)
28
 
29
- inputs = tokenizer("Grammar: "+sent,return_tensors="tf")
30
 
31
- output_sequences = infer(inputs)
32
 
33
- generated_sequences = tokenizer.decode(output_ids)
34
 
35
- st.write(generated_sequences)
 
9
 
10
  tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
11
 
12
+ @st.cache(allow_output_mutation=True, suppress_st_warning=True)
13
+ def load_model():
14
+ return pipeline("text2text- generation", model=model_checkpoint)
15
+ model = load_model()
 
 
16
 
17
  def infer(input_ids):
18
  output_sequences = model.generate(inputs["input_ids"]).numpy()[0][1:-1]
19
  return output_sequences
20
 
 
21
  #prompts
22
  st.title("Writing Assistant for you πŸ¦„")
23
 
24
+ textbox = st.text_area('Write your text:', '', height=200, max_chars=1000)
25
 
26
+ #inputs = tokenizer("Grammar: "+sent,return_tensors="tf")
27
 
28
+ #output_sequences = infer(inputs)
29
 
30
+ #generated_sequences = tokenizer.decode(output_ids)
31
 
32
+ #st.write(generated_sequences)