|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
classifier = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english") |
|
|
|
def classify_text(text): |
|
|
|
result = classifier(text) |
|
return result[0]['label'] |
|
|
|
|
|
iface = gr.Interface( |
|
fn=classify_text, |
|
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."), |
|
outputs=gr.Textbox(), |
|
title="Text Classification", |
|
description="Classify text into positive or negative sentiment using Hugging Face Transformers." |
|
) |
|
|
|
|
|
if __name__ == "__main__": |
|
iface.launch() |
|
|