Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import pipeline | |
# Load the pre-trained sentiment-analysis pipeline | |
classifier = pipeline('sentiment-analysis') | |
# Function to classify sentiment | |
def classify_text(text): | |
result = classifier(text)[0] | |
return f"{result['label']} with score {result['score']}" | |
# Check if GRADIO_SERVER_PORT is set, otherwise use a different port | |
import os | |
port = int(os.getenv('GRADIO_SERVER_PORT', 7861)) | |
# Launch the Gradio interface on the specified port | |
iface.launch(server_port=port) | |
# Streamlit code | |
st.title('IMDb Sentiment Analysis') | |
st.write('This project performs sentiment analysis on IMDb movie reviews using Streamlit.') |