Spaces:
Sleeping
Sleeping
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) | |