Spaces:
Runtime error
Runtime error
| 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() | |