Spaces:
Runtime error
Runtime error
JoanParanoid
commited on
Commit
•
0ef5346
1
Parent(s):
e784382
Update app.py
Browse files
app.py
CHANGED
@@ -4,40 +4,44 @@ from transformers import pipeline
|
|
4 |
access = "hf_"
|
5 |
token = "hhbFNpjKohezoexWMlyPUpvJQLWlaFhJaa"
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
st.
|
16 |
-
st.
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
st.write("
|
40 |
-
st.write("
|
41 |
-
|
42 |
-
|
43 |
-
st.write("
|
|
|
|
|
|
|
|
|
|
4 |
access = "hf_"
|
5 |
token = "hhbFNpjKohezoexWMlyPUpvJQLWlaFhJaa"
|
6 |
|
7 |
+
def main():
|
8 |
+
# Load the text classification model pipeline
|
9 |
+
analysis = pipeline("text-classification", model='ZephyruSalsify/FinNews_SentimentAnalysis')
|
10 |
+
classification = pipeline("text-classification", model="nickmuchi/finbert-tone-finetuned-finance-topic-classification", token=access+token)
|
11 |
+
|
12 |
+
st.set_page_config(page_title="Financial News Analysis", page_icon="♕")
|
13 |
+
|
14 |
+
# Streamlit application layout
|
15 |
+
st.title("Financial News Analysis")
|
16 |
+
st.write("Analyze corresponding Topic and Trend for Financial News!")
|
17 |
+
st.image("./Fin.jpg", use_column_width = True)
|
18 |
+
|
19 |
+
# Text input for user to enter the text
|
20 |
+
text = st.text_area("Enter the Financial News", "")
|
21 |
+
|
22 |
+
# Perform text classification when the user clicks the "Classify" button
|
23 |
+
if st.button("Analyze"):
|
24 |
+
|
25 |
+
label_1 = ""
|
26 |
+
score_1 = 0.0
|
27 |
+
label_2 = ""
|
28 |
+
score_2 = 0.0
|
29 |
+
|
30 |
+
# Perform text analysis on the input text
|
31 |
+
results_1 = analysis(text)[0]
|
32 |
+
results_2 = classification(text)[0]
|
33 |
+
|
34 |
+
label_1 = results_1["label"]
|
35 |
+
score_1 = results_1["score"]
|
36 |
+
label_2 = results_2["label"]
|
37 |
+
score_2 = results_2["score"]
|
38 |
+
|
39 |
+
st.write("Financial Text:", text)
|
40 |
+
st.write("Trend:", label_1)
|
41 |
+
st.write("Trend_Score:", score_1)
|
42 |
+
|
43 |
+
st.write("Finance Topic:", label_2)
|
44 |
+
st.write("Topic_Score:", score_2)
|
45 |
+
|
46 |
+
if_name_== "_main_":
|
47 |
+
main()
|