TextSummarizer / app.py
sashfaq911's picture
Create app.py
a1ed663 verified
raw
history blame contribute delete
No virus
1.73 kB
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-cnn-12-6",
torch_dtype=torch.bfloat16)
# model_path = ("../Models/models--sshleifer--distilbart-cnn-12-6/snapshots"
# "/a4f8f3ea906ed274767e9906dbaede7531d660ff")
# text_summary = pipeline("summarization", model= model_path,
# torch_dtype=torch.bfloat16)
# text='''Glaucoma is a group of eye diseases that lead to damage of the optic nerve, which transmits visual information from the eye to the brain. Glaucoma may cause vision loss if left untreated. It has been called the "silent thief of sight" because the loss of vision usually occurs slowly over a long period of time.[5] A major risk factor for glaucoma is increased pressure within the eye, known as intraocular pressure (IOP).[1] It is associated with old age, a family history of glaucoma, and certain medical conditions or medications.[6] The word glaucoma comes from the Ancient Greek word 纬位伪蠀魏蠈蟼 (glauk贸s), meaning 'gleaming, blue-green, gray'.'''
# 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="Enter the text needed to be summarized",lines=10)],
outputs=[gr.Textbox(label="Summarized text",lines=4)],
title="Summarize ANY Text To Just 4 Lines!",
description="THIS APPLICATION WILL BE USED TO SUMMARIZE A GIVEN TEXT")
demo.launch()