File size: 1,064 Bytes
9cbb56b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
"""

Gradio frontend for DistilBERT sentiment analysis

File: app.py

"""

import gradio as gr
from infer import predict

def sentiment_analyzer(text):
    """Wrapper function for Gradio interface"""
    if not text.strip():
        return "Please enter some text"
    
    result = predict(text)
    return result.capitalize()

# Create Gradio interface
interface = gr.Interface(
    fn=sentiment_analyzer,
    inputs=gr.Textbox(
        label="Movie Review",
        placeholder="Enter your movie review here...",
        lines=3
    ),
    outputs=gr.Label(label="Sentiment Prediction"),
    title="🎬 Movie Review Sentiment Analysis",
    description="Fine-tuned DistilBERT model for movie review sentiment classification",
    examples=[
        "This movie was absolutely fantastic! Great acting and storyline.",
        "Terrible film, worst movie I've ever seen. Complete waste of time.",
        "The movie was okay, not great but not terrible either."
    ]
)

if __name__ == "__main__":
    interface.launch(share=True)