wldmr commited on
Commit
46babe5
1 Parent(s): e76946d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -11,11 +11,11 @@ summarizer = pipeline("text2text-generation", model=model_id)
11
 
12
  def summarize(text):
13
  text = str(text)
14
- if text == "showdata":
15
- lines = "(lines)"
16
- with open('input.csv',"r") as f:
17
- lines = f.readlines()
18
- return str(lines)
19
 
20
 
21
  #generated_summary_short = summarizer(text, max_length=40, min_length=10)[0]['summary_text']
@@ -23,14 +23,16 @@ def summarize(text):
23
  #generated_summary = summarizer(text, max_length=200, min_length=40)[0]['summary_text']
24
  generated_summary = summarizer(text, max_length=200, min_length=40)[0]['generated_text']
25
 
26
- fields = [str(text), str(generated_summary)]
27
- with open('input.csv','a', newline='') as f:
28
- writer = csv.writer(f)
29
- writer.writerow(fields)
30
 
31
  #return "Summary: " + str(generated_summary) + "\n\n" + "shorter: " + str(generated_summary_short)+ "\n\n" + "Longer: " + str(generated_summary_long)
32
  return str(generated_summary)
33
 
34
 
35
- iface = gr.Interface(fn=summarize, inputs="text", outputs="text")
36
- iface.launch()
 
 
 
11
 
12
  def summarize(text):
13
  text = str(text)
14
+ #if text == "showdata":
15
+ # lines = "(lines)"
16
+ # with open('input.csv',"r") as f:
17
+ # lines = f.readlines()
18
+ # return str(lines)
19
 
20
 
21
  #generated_summary_short = summarizer(text, max_length=40, min_length=10)[0]['summary_text']
 
23
  #generated_summary = summarizer(text, max_length=200, min_length=40)[0]['summary_text']
24
  generated_summary = summarizer(text, max_length=200, min_length=40)[0]['generated_text']
25
 
26
+ #fields = [str(text), str(generated_summary)]
27
+ #with open('input.csv','a', newline='') as f:
28
+ # writer = csv.writer(f)
29
+ # writer.writerow(fields)
30
 
31
  #return "Summary: " + str(generated_summary) + "\n\n" + "shorter: " + str(generated_summary_short)+ "\n\n" + "Longer: " + str(generated_summary_long)
32
  return str(generated_summary)
33
 
34
 
35
+ iface = gr.Interface(fn=summarize, inputs="text", outputs="text", allow_flagging="never", queue = True)
36
+
37
+ if __name__ == "__main__":
38
+ iface.launch()