smart-ai / app.py
PopeJohn's picture
Update app.py
b54edec verified
raw
history blame contribute delete
670 Bytes
import gradio as gr
from transformers import pipeline
# Load your uploaded model
model_path = "PopeJohn/distilbert-imdb-johnbusg"
classifier = pipeline("text-classification", model=model_path)
def classify_review(review):
result = classifier(review)[0]
label = "Positive 😊" if result["label"] == "LABEL_1" else "Negative 😞"
confidence = round(result["score"] * 100, 2)
return f"{label} (Confidence: {confidence}%)"
interface = gr.Interface(
fn=classify_review,
inputs="text",
outputs="text",
title="Sentiment Classifier (IMDb)",
description="Enter a movie review to classify it as Positive or Negative."
)
interface.launch()