File size: 662 Bytes
bc4e787
 
 
 
 
 
 
 
 
 
 
6179462
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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.')