Spaces:
Runtime error
Runtime error
File size: 1,563 Bytes
36269f6 | 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 | import torch
import gradio
# 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"
#"/a4f8f3ea90ed274767e9906dbaede7531d660ff")
#text_summary= pipeline(task: "summerization", model=model_path,
#torch_dtype=torch.bfloat16)
# text=("Elon Reeve Musk (/ΛiΛlΙn/ EE-lon; born June 28, 1971) is a businessman and investor. He is the founder, chairman, "
#"CEO, and CTO of SpaceX; angel investor, CEO, product architect, and former chairman of Tesla, Inc.; owner, executive "
#"chairman, and CTO of X Corp.; founder of the Boring Company and xAI; 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, Forbes estimates his net worth"
#" to be $178 billion.[4]")
#print(text_summary(text));
def summary (input):
output = text_summary(input)
return output[0] ["summary_text"]
gradio.close_all()
#demo = gradio.Interface(inputs="text", fn=summary, outputs="text")
demo = gradio.Interface(fn=summary, inputs=[gradio.Textbox(label="input text to summarise", lines=6)],
outputs=[gradio.Textbox(label="Summarised text", lines=4)],
title="Jason's text summariser Project 1",
description= "This application will be used to summarise the text")
demo.launch()
|