Spaces:
Runtime error
Runtime error
import streamlit as st | |
from transformers import pipeline | |
st.title("Sentiment Analysis And Translation App") | |
text = st.text_input("Enter a sentence:") | |
sentiment_analyzer = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english") | |
translation = pipeline("translation_en_to_ar", model="anibahug/marian-finetuned-kde4-en-to-ar") | |
if text: | |
results = sentiment_analyzer(text) | |
sentiment = results[0]['label'] | |
confidence = results[0]['score'] | |
st.write(f"Sentiment: {sentiment}") | |
st.write(f"Confidence: {confidence:.2f}") | |
# if text: | |
# result = sentiment_analysis(text) | |
# st.json(result) | |
if text: | |
result = translation(text)[0] | |
st.write(f"Translated text: {result['translation_text']}") |