Spaces:
Runtime error
Runtime error
File size: 674 Bytes
a07d11d 95b93ce a07d11d 95b93ce 62d7af7 95b93ce |
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 |
import gradio as gr
from transformers import pipeline
# Load text classification model from Hugging Face
model = pipeline("text-classification", model="distilbert-base-uncased-finetuned-sst-2-english")
def classify_text(text):
# Classify text using the loaded model
result = model(text)[0]
label = result['label']
score = result['score']
return f"Label: {label}, Score: {score}"
# Create Gradio interface
iface = gr.Interface(
fn=classify_text,
inputs=gr.inputs.Textbox(label="Enter text to classify"),
outputs="text",
title="Text Classification",
description="Testing classificaton model"
)
# Launch the interface
iface.launch()
|