IMDB / app.py
sm3455's picture
Create app.py
206370b verified
Raw
History Blame Contribute Delete
595 Bytes
import gradio as gr
from transformers import pipeline
# Load your fine-tuned model from local path or Hugging Face Hub
classifier = pipeline("text-classification", model="sm3455/bert-mlm-ft")
def classify_text(text):
result = classifier(text)
label = result[0]['label']
score = result[0]['score']
return f"{label} ({score:.2f})"
iface = gr.Interface(
fn=classify_text,
inputs=gr.Textbox(lines=2, placeholder="Enter your text here..."),
outputs="text",
title="My Text Classifier",
description="A demo for my fine-tuned model using Gradio"
)
iface.launch()