Spaces:
Build error
Build error
Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
access = "hf_"
|
| 5 |
+
token = "hhbFNpjKohezoexWMlyPUpvJQLWlaFhJaa"
|
| 6 |
+
|
| 7 |
+
# Load the text classification model pipeline
|
| 8 |
+
analysis = pipeline("text-classification", model='ZephyruSalsify/FinNews_SentimentAnalysis_Test')
|
| 9 |
+
classification = pipeline("text-classification", model="nickmuchi/finbert-tone-finetuned-finance-topic-classification", token=access+token)
|
| 10 |
+
|
| 11 |
+
st.set_page_config(page_title="Financial News Analysis", page_icon="♕")
|
| 12 |
+
|
| 13 |
+
# Streamlit application layout
|
| 14 |
+
st.title("Financial News Analysis")
|
| 15 |
+
st.write("Analyze corresponding Topic and Trend for Financial News!")
|
| 16 |
+
st.image("./Fin.jpg", use_column_width = True)
|
| 17 |
+
|
| 18 |
+
# Text input for user to enter the text
|
| 19 |
+
text = st.text_area("Enter the Financial News", "")
|
| 20 |
+
|
| 21 |
+
# Perform text classification when the user clicks the "Classify" button
|
| 22 |
+
if st.button("Analyze"):
|
| 23 |
+
|
| 24 |
+
# Perform text analysis on the input text
|
| 25 |
+
results_1 = analysis(text)[0]
|
| 26 |
+
results_2 = classification(text)[0]
|
| 27 |
+
|
| 28 |
+
# Display the analysis result
|
| 29 |
+
#max_score_1 = float('-inf')
|
| 30 |
+
#max_label_1 = ''
|
| 31 |
+
|
| 32 |
+
#for result_1 in results_1:
|
| 33 |
+
# if result_1['score'] > max_score_1:
|
| 34 |
+
# max_score_1 = result_1['score']
|
| 35 |
+
# max_label_1 = result_1['label']
|
| 36 |
+
|
| 37 |
+
# Display the classification result
|
| 38 |
+
#max_score_2 = float('-inf')
|
| 39 |
+
#max_label_2 = ''
|
| 40 |
+
|
| 41 |
+
#for result_2 in results_2:
|
| 42 |
+
# if result_2['score'] > max_score_2:
|
| 43 |
+
# max_score_2 = result_2['score']
|
| 44 |
+
# max_label_2 = result_2['label']
|
| 45 |
+
|
| 46 |
+
st.write("Financial Text:", text)
|
| 47 |
+
st.write("Trend:", results_1["label"])
|
| 48 |
+
st.write("Trend_Score:", results_1["score"])
|
| 49 |
+
|
| 50 |
+
st.write("Finance Topic:", results_2["label"])
|
| 51 |
+
st.write("Topic_Score:", results_2["score"])
|