import gradio as gr from transformers import pipeline # Load the models model1 = pipeline("sentiment-analysis", model="mrm8488/distilroberta-finetuned-financial-news-sentiment-analysis") model2 = pipeline("sentiment-analysis", model="mr8488/distilroberta-finetuned-financial-news-sentiment-analysis") # Define the function to generate responses def analyze_sentiment(input_text): result1 = model1(input_text)[0] result2 = model2(input_text)[0] return {"mrm8488": f"{result1['label']} ({result1['score']:.2f})", "mr8488": f"{result2['label']} ({result2['score']:.2f})"} # Create the Gradio interface iface = gr.Interface(fn=analyze_sentiment, inputs="text", outputs="text", title="Financial Sentiment Analysis", description="Enter a sentence to analyze its sentiment using two different models.") # Launch the interface iface.launch()