parasmech's picture
Create app.py
1bef306 verified
raw
history blame
591 Bytes
import gradio as gr
from transformers import pipeline
model = pipeline("text-classification", model="distilbert-base-uncased-finetuned-sst-2-english")
def input_text_fn(text):
result = model(text)
label = result[0]['label']
confidence = result[0]['score']
return f"Label: {label}, Confidence: {confidence:.2f}"
interface = gr.Interface(
fn=input_text_fn,
inputs="text",
outputs="text",
title="Text Classification or Sentiment Analysis",
description="Enter text to classify it as positive or negative sentiment."
)
# Launch the app
interface.launch()