Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
# Use a pipeline as a high-level helper
|
| 5 |
+
from transformers import pipeline
|
| 6 |
+
|
| 7 |
+
# model_path = ("../model/models--sshleifer--distilbart-cnn-12-6/"
|
| 8 |
+
# "snapshots/a4f8f3ea906ed274767e9906dbaede7531d660ff")
|
| 9 |
+
|
| 10 |
+
text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6"
|
| 11 |
+
, torch_dtype=torch.bfloat16)
|
| 12 |
+
#
|
| 13 |
+
# text = """
|
| 14 |
+
# Ratan Naval Tata[a] (28 December 1937 – 9 October 2024)
|
| 15 |
+
# was an Indian industrialist and philanthropist. He served as
|
| 16 |
+
# the chairman of Tata Group and Tata Sons from 1991 to 2012 and he held
|
| 17 |
+
# the position of interim chairman from October 2016 to February 2017.[3][4] In 2000,
|
| 18 |
+
# he received the Padma Bhushan, the third highest civilian honour in India,
|
| 19 |
+
# followed by the Padma Vibhushan, the country's second highest civilian honour, in 2008.[5]
|
| 20 |
+
# """
|
| 21 |
+
# print(text_summary(text))
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def summary(input):
|
| 25 |
+
output = text_summary(input)
|
| 26 |
+
return output[0]["summary_text"]
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
gr.close_all()
|
| 30 |
+
# demo = gr.Interface(fn=summary, inputs="text", outputs="text")
|
| 31 |
+
demo = gr.Interface(fn=summary,
|
| 32 |
+
inputs=[gr.Textbox(label = "Input to summarize",lines = 6 )],
|
| 33 |
+
outputs= [gr.Textbox(label = "Summarized text",lines = 6)],
|
| 34 |
+
title="GenerativeAI Project 1 : Text summarize",
|
| 35 |
+
description="THIS APPLICATION WILL BE USE TO SUMMARIZE THE TEXT")
|
| 36 |
+
demo.launch()
|