Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use a pipeline as a high-level helper
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
import torch
|
| 4 |
+
import gradio as gr
|
| 5 |
+
|
| 6 |
+
# pipe = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)
|
| 7 |
+
|
| 8 |
+
model_path = "Model/models--sshleifer--distilbart-cnn-12-6/snapshots/a4f8f3ea906ed274767e9906dbaede7531d660ff"
|
| 9 |
+
|
| 10 |
+
text_summary = pipeline("summarization", model=model_path, torch_dtype=torch.bfloat16)
|
| 11 |
+
|
| 12 |
+
# text="Why You Can Trust Forbes Advisor Small Business \
|
| 13 |
+
# The Forbes Advisor Small Business team is committed to bringing you unbiased \
|
| 14 |
+
# rankings and information with full editorial independence. We use product data, \
|
| 15 |
+
# strategic methodologies and expert insights to inform all of our content and guide \
|
| 16 |
+
# you in making the best decisions for your business journey.\
|
| 17 |
+
# We reviewed 11 systems to help you find the best blogging platform for your blog or \
|
| 18 |
+
# small business. Our ratings looked at factors that included the platform’s starting \
|
| 19 |
+
# price (including whether it offered a free trial or free version); useful general features,\
|
| 20 |
+
# such as drag-and-drop functionality and search engine optimization (SEO) tools; unique features, \
|
| 21 |
+
# how well the blogging platform fared on third-party review sites and a final review by our experts.\
|
| 22 |
+
# All ratings are determined solely by our editorial team."
|
| 23 |
+
|
| 24 |
+
# print(text_summary(text)[0])
|
| 25 |
+
|
| 26 |
+
def summary(input):
|
| 27 |
+
output = text_summary(input)
|
| 28 |
+
return output[0]['summary_text']
|
| 29 |
+
|
| 30 |
+
gr.close_all()
|
| 31 |
+
|
| 32 |
+
# demo = gr.Interface(fn=summary,inputs="text",outputs='text',title='Text Summarization Gradio Huggingface')
|
| 33 |
+
demo = gr.Interface(fn=summary,
|
| 34 |
+
inputs=[gr.Textbox(label="Input text to summarization", lines=6)],
|
| 35 |
+
outputs=[gr.Textbox(label="Summarized text", lines=4)],
|
| 36 |
+
title='Text Summarization',
|
| 37 |
+
description='This application will be used to summarize the text',
|
| 38 |
+
concurrency_limit=16)
|
| 39 |
+
|
| 40 |
+
demo.launch(share=True)
|