genelify commited on
Commit
feb80ee
1 Parent(s): 39402b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -6,9 +6,8 @@ model_name = 'facebook/bart-large-cnn'
6
  tokenizer = BartTokenizer.from_pretrained(model_name)
7
  model = BartForConditionalGeneration.from_pretrained(model_name)
8
 
9
- def summarize(inp):
10
- inp = inp.replace('\n','')
11
- inp = tokenizer.encode(inp, return_tensors='pt', max_length=1024)
12
  summary_ids = model.generate(inp, num_beams=4, max_length=150, early_stopping=True)
13
  summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
14
  return summary
 
6
  tokenizer = BartTokenizer.from_pretrained(model_name)
7
  model = BartForConditionalGeneration.from_pretrained(model_name)
8
 
9
+ def summarize(input_text):
10
+ inp = tokenizer.encode("summarize: " + input_text.replace('\n',''), return_tensors="pt", max_length=1024, truncation=True)
 
11
  summary_ids = model.generate(inp, num_beams=4, max_length=150, early_stopping=True)
12
  summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
13
  return summary