Spaces:
Sleeping
Sleeping
File size: 1,767 Bytes
ddf9d5b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
import torch
import gradio as gr
# Use a pipeline as a high-level helper
from transformers import pipeline
text_summary = pipeline("summarization", model="sshleifer/distilbart-xsum-9-6",
torch_dtype=torch.bfloat16)
#model_path =("../models/models--sshleifer--distilbart-xsum-9-6/snapshots"
# "/28dfbe915f475094642bf8c7dba2ba8a8e85b432")
#text_summary = pipeline("summarization", model=model_path,
# torch_dtype=torch.bfloat16)
#text=("India, officially the Republic of India,[j][20] is a country in South Asia. "
# "It is the seventh-largest country by area; the most populous country since 2023;[21]"
# " and, since its independence in 1947, the world's most populous democracy.[22][23][24] Bounded by "
# "the Indian Ocean on the south, "
#"the Arabian Sea on the southwest, and the Bay of Bengal on the southeast, it shares land borders"
#" with Pakistan to the west;"
#"[k] China, Nepal, and Bhutan to the north; and Bangladesh and Myanmar to the east. In the Indian Ocean, "
#"India is near Sri Lanka and the Maldives; "
#"its Andaman and Nicobar Islands share a maritime border with Thailand, Myanmar, and Indonesia.")
#print(text_summary(text));
def summary(input):
output = text_summary(input)
return output[0]['summary_text']
gr.close_all()
#demo=gr.Interface(fn=summary,inputs="text",outputs="text")
demo = gr.Interface(fn=summary,
inputs=[gr.Textbox(label="Input Text to Summarize",lines=6)],
outputs=[gr.Textbox(label="summarized text",lines=4)],
title="AMRITA TEXT SUMMARIZER",
description="THIS APPLICATION IS USED TO SUMMARIZE THE TEXT")
demo.launch(share=True)
|