laqey2050's picture
Update app.py
10ceaea verified
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)
#text_summary = pipeline("summarization", model=model_path,
# torch_dtype=torch.bfloat16)
#model_path = ("../Model/models--sshleifer--distilbart-cnn-12-6/snapshots/a4f8f3ea906ed274767e9906dbaede7531d660ff")
#text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)
#text='''Quantum mechanics is a fundamental theory in physics that describes the behavior of nature at and below the scale of atoms.[2]:β€Š1.1β€Š It is the foundation of all quantum physics, which includes quantum chemistry, quantum field theory, quantum technology, and quantum information science.
#Quantum mechanics can describe many systems that classical physics cannot. Classical physics can describe many aspects of nature at an ordinary (macroscopic and (optical) microscopic) scale, but is not sufficient for describing them at very small submicroscopic (atomic and subatomic) scales. Most theories in classical physics can be derived from quantum mechanics as an approximation valid at large (macroscopic/microscopic) scale.[3] '''
#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="@LaqeyInc Project 1: Text Summarizer",
description="THIS APPLICATION WILL BE USED TO SUMMARIZE THE TEXT")
demo.launch()