import streamlit as st from transformers import pipeline # Load the text classification model pipeline analysis = pipeline("text-analysis", model='ZephyruSalsify/FinNews_SentimentAnalysis_Test') classification = pipeline("text-classification", model="nickmuchi/finbert-tone-finetuned-finance-topic-classification") st.set_page_config(page_title="Financial News Analysis", page_icon="♕") st.header("Make Analysis for Financial News") # Streamlit application layout st.title("Financial News Analysis") st.write("Classify corresponding Topic and Trend for Financial News") st.image("./Fin.jpg", use_column_width = True) # Text input for user to enter the text text = st.text_area("Enter the Financial News", "") # Perform text classification when the user clicks the "Classify" button if st.button("Analyze"): # Perform text analysis on the input text results_1 = analysis(text)[0] results_2 = classification(text)[0] # Display the analysis result max_score_1 = float('-inf') max_label_1 = '' for result in results_1: if result['score'] > max_score_1: max_score_1 = result['score'] max_label_1 = result['label'] # Display the classification result max_score_2 = float('-inf') max_label_2 = '' for result in results_2: if result['score'] > max_score_2: max_score_2 = result['score'] max_label_2 = result['label'] st.write("Financial Text:", text) st.write("Trend:", max_label_1) st.write("Trend_Score:", max_score_1) st.write("Finance Topic:", max_label_2) st.write("Topic_Score:", max_score_2)