Team Ai
Apppublic

prithivi96/OpenSourceTextSummarizer

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes
app.py37 linesDownload Raw Back to root
1import torch2import gradio as gr3 4# Use a pipeline as a high-level helper5from transformers import pipeline6 7# model_path = "../Models/models--sshleifer--distilbart-cnn-12-6/snapshots/a4f8f3ea906ed274767e9906dbaede7531d660ff"8 9text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6",10                torch_dtype=torch.bfloat16)11 12# text = """Elon Reeve Musk (/ˈiːlɒn/ EE-lon; born June 28, 1971)13#  is a businessman and investor. He is the founder,14#  chairman, CEO, and CTO of SpaceX; angel investor, CEO, product architect, and15#   former chairman of Tesla, Inc.; owner, executive chairman, and CTO of X Corp.; founder of the Boring Company and xAI;16#    co-founder of Neuralink and OpenAI; and president of the Musk Foundation. He is one of the wealthiest people in the world; as of April 2024,17#    Forbes estimates his net worth to be $178 billion.[4]"""18 19def summary(input):20 21    output = text_summary(input)22    return output[0]['summary_text']23 24gr.close_all()25 26demo = gr.Interface(fn=summary,27                    inputs=[gr.Textbox(label="Input text to Summarize", lines=6)],28                    outputs=[gr.Textbox(label="Summarized Text", lines=4)],29                    title="@GenerativeAISummarizerApp",30                    description="THIS APPLICATION WILL BE USED TO SUMMARIZE THE TEXT")31 32demo.launch()33 34# print(text_summary(text))35 36 37