|
import streamlit as st |
|
from transformers import pipeline |
|
|
|
|
|
|
|
classifier = pipeline("text-classification", model='lguoao123/model2', return_all_scores=True) |
|
translate = pipe = pipeline("text2text-generation", model="jieshenai/zh_en_translation") |
|
|
|
|
|
st.title("Financial News Sentiment Classification") |
|
st.write("Classification") |
|
|
|
|
|
text = st.text_area("Enter the financial news to classify", "") |
|
|
|
|
|
if st.button("Classify"): |
|
translate_text = translate(text)[0]['generated_text'] |
|
|
|
results = classifier(translate_text)[0] |
|
|
|
|
|
max_score = float('-inf') |
|
max_label = '' |
|
|
|
for result in results: |
|
if result['score'] > max_score: |
|
max_score = result['score'] |
|
max_label = result['label'] |
|
|
|
st.write("Text:", translate_text) |
|
st.write("Label:", max_label) |
|
st.write("Score:", max_score) |
|
|
|
|