Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 25 |
-
|
| 26 |
-
return
|
| 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 |
|