Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,10 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Load the image to text model pipeline
|
5 |
-
image_to_text = pipeline("image-to-text", model="microsoft/trocr-base-handwritten")
|
6 |
|
7 |
# Load the text classification model pipeline
|
8 |
classifier = pipeline("text-classification", model='lguoao123/model2', return_all_scores=True)
|
9 |
-
|
10 |
|
11 |
# Streamlit application title
|
12 |
st.title("Financial News Sentiment Classification")
|
@@ -17,8 +15,9 @@ text = st.text_area("Enter the financial news to classify", "")
|
|
17 |
|
18 |
# Perform text classification when the user clicks the "Classify" button
|
19 |
if st.button("Classify"):
|
|
|
20 |
# Perform text classification on the input text
|
21 |
-
results = classifier(
|
22 |
|
23 |
# Display the classification result
|
24 |
max_score = float('-inf')
|
@@ -33,6 +32,3 @@ if st.button("Classify"):
|
|
33 |
st.write("Label:", max_label)
|
34 |
st.write("Score:", max_score)
|
35 |
|
36 |
-
# Perform image to text conversion
|
37 |
-
image_result = image_to_text(text)
|
38 |
-
st.write("Image to Text Result:", image_result)
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
|
|
|
|
4 |
|
5 |
# Load the text classification model pipeline
|
6 |
classifier = pipeline("text-classification", model='lguoao123/model2', return_all_scores=True)
|
7 |
+
translate = pipe = pipeline("text2text-generation", model="jieshenai/zh_en_translation")
|
8 |
|
9 |
# Streamlit application title
|
10 |
st.title("Financial News Sentiment Classification")
|
|
|
15 |
|
16 |
# Perform text classification when the user clicks the "Classify" button
|
17 |
if st.button("Classify"):
|
18 |
+
translate_text = translate(text)[0]['generated_text']
|
19 |
# Perform text classification on the input text
|
20 |
+
results = classifier(translate_text)[0]
|
21 |
|
22 |
# Display the classification result
|
23 |
max_score = float('-inf')
|
|
|
32 |
st.write("Label:", max_label)
|
33 |
st.write("Score:", max_score)
|
34 |
|
|
|
|
|
|