abdulmatinomotoso commited on
Commit
e96727a
1 Parent(s): 9c1fc3a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -13,8 +13,8 @@ def read_in_text(url):
13
  return article
14
 
15
  #Doing some text preprocessing, more will still be needed later
16
- def clean_text(url):
17
- text = read_in_text(url)
18
  text = text.encode("ascii", errors="ignore").decode(
19
  "ascii"
20
  ) # remove non-ascii, Chinese characters
@@ -41,7 +41,7 @@ model_2 = AutoModelForSeq2SeqLM.from_pretrained(model_type_2)
41
 
42
  #Defining a function to generate the headlines
43
  def headline_generator_2(file):
44
- input_text = clean_text(file.name)
45
  input_text = sent_tokenize(input_text)
46
  text = ''.join(input_text[:6])
47
 
@@ -55,10 +55,11 @@ def headline_generator_2(file):
55
  return summary_2[0]
56
 
57
  #creating an interface for the headline generator using gradio
58
- demo = gr.Interface(headline_generator_2, inputs=[gr.inputs.File(label="Drop your .txt file here", optional=False)],
59
  title = "HEADLINE GENERATOR",
60
  outputs=[gr.outputs.Textbox(label="Headline")],
61
  theme= "darkhuggingface")
 
62
 
63
  #launching the app
64
  if __name__ == "__main__":
 
13
  return article
14
 
15
  #Doing some text preprocessing, more will still be needed later
16
+ def clean_text(text):
17
+ #text = read_in_text(url)
18
  text = text.encode("ascii", errors="ignore").decode(
19
  "ascii"
20
  ) # remove non-ascii, Chinese characters
 
41
 
42
  #Defining a function to generate the headlines
43
  def headline_generator_2(file):
44
+ input_text = clean_text(file)
45
  input_text = sent_tokenize(input_text)
46
  text = ''.join(input_text[:6])
47
 
 
55
  return summary_2[0]
56
 
57
  #creating an interface for the headline generator using gradio
58
+ demo = gr.Interface(headline_generator_2, inputs=[gr.inputs.Textbox(label="Drop your .txt file here", optional=False)],
59
  title = "HEADLINE GENERATOR",
60
  outputs=[gr.outputs.Textbox(label="Headline")],
61
  theme= "darkhuggingface")
62
+
63
 
64
  #launching the app
65
  if __name__ == "__main__":