import gradio as gr from transformers import pipeline summarizer = pipeline("summarization", model="knkarthick/bart-large-xsum-samsum") def sentiment_analysis(text): result = summarizer(text) return result[0].get('summary_text') demo = gr.Interface(fn=sentiment_analysis, inputs='text', outputs='text', examples=[['''Hannah: Hey, do you have Betty's number? Amanda: Lemme check Amanda: Sorry, can't find it. Amanda: Ask Larry Amanda: He called her last time we were at the park together Hannah: I don't know him well Amanda: Don't be shy, he's very nice Hannah: If you say so.. Hannah: I'd rather you texted him Amanda: Just text him 🙂 Hannah: Urgh.. Alright Hannah: Bye Amanda: Bye bye ''']], title = "摘要" ) if __name__ == "__main__": demo.queue(concurrency_count=3) demo.launch(server_name = "0.0.0.0", server_port = 7028)