Spaces:
Runtime error
Runtime error
File size: 1,116 Bytes
7a6ac38 2080251 7a6ac38 2080251 2204b7f 7a6ac38 dff2789 7a6ac38 dff2789 7a6ac38 2204b7f 7a6ac38 2204b7f 7a6ac38 3292bb0 7a6ac38 2080251 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import streamlit as st
from transformers import pipeline
# Load the text classification model pipeline
classifier = pipeline("text-classification", model='lguoao123/model2', return_all_scores=True)
translate = pipe = pipeline("text2text-generation", model="jieshenai/zh_en_translation")
# Streamlit application title
st.title("Financial News Sentiment Classification")
st.write("Classification")
# Text input for user to enter the text to classify
text = st.text_area("Enter the financial news to classify", "")
# Perform text classification when the user clicks the "Classify" button
if st.button("Classify"):
translate_text = translate(text)[0]['generated_text']
# Perform text classification on the input text
results = classifier(translate_text)[0]
# Display the classification result
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)
|