gsmayuresh commited on
Commit
17dee13
·
verified ·
1 Parent(s): 8e98e7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -4,8 +4,12 @@ import gradio as gr
4
  # Use a pipeline as a high-level helper
5
  from transformers import pipeline
6
 
7
- text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)
8
-
 
 
 
 
9
  # model_path = ("../Models/models--sshleifer--distilbart-cnn-12-6/snapshots"
10
  # "/a4f8f3ea906ed274767e9906dbaede7531d660ff")
11
  # text_summary = pipeline("summarization", model=model_path,
@@ -21,9 +25,9 @@ text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6",
21
  # Forbes estimates his net worth to be $178 billion.[4]'''
22
  # print(text_summary(text));
23
 
24
- def summary (input):
25
- output = text_summary(input)
26
- return output[0]['summary_text']
27
 
28
  gr.close_all()
29
 
 
4
  # Use a pipeline as a high-level helper
5
  from transformers import pipeline
6
 
7
+ # text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)
8
+ text_summary = pipeline(
9
+ "text2text-generation",
10
+ model="sshleifer/distilbart-cnn-12-6",
11
+ torch_dtype=torch.float32, # safer on CPU
12
+ )
13
  # model_path = ("../Models/models--sshleifer--distilbart-cnn-12-6/snapshots"
14
  # "/a4f8f3ea906ed274767e9906dbaede7531d660ff")
15
  # text_summary = pipeline("summarization", model=model_path,
 
25
  # Forbes estimates his net worth to be $178 billion.[4]'''
26
  # print(text_summary(text));
27
 
28
+ def summary(input_text):
29
+ out = text_summary(input_text)
30
+ return out[0]["generated_text"]
31
 
32
  gr.close_all()
33