import gradio as gr
from transformers import pipeline


model_path = "cardiffnlp/twitter-roberta-base-sentiment-latest"
sentiment_task = pipeline("sentiment-analysis", model=model_path, tokenizer=model_path)

def sentiment_analysis(text):
    results = sentiment_task(text)

    return results 
    
demo = gr.Interface(fn=sentiment_analysis, 
                    inputs='text', 
                    outputs='text',
                    title = "文本情感分析"
                    )


if __name__ == "__main__":
    demo.queue(concurrency_count=3)
    demo.launch(server_name = "0.0.0.0", server_port = 7028)
