Spaces:
Sleeping
Sleeping
File size: 845 Bytes
5eed20c ab054e6 5eed20c |
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 26 |
import gradio as gr
from transformers import pipeline
# Load a pre-trained sentiment-analysis model
classifier = pipeline("sentiment-analysis", model="ChavinloSocialRise/bot_rejection_model")
# Define a function to classify the input text
def classify_text(text):
result = classifier(text)[0] # Get the first result
label = result['label'] # The label (e.g., POSITIVE, NEGATIVE)
score = result['score'] # The confidence score
return f"Label: {label}, Confidence: {score:.4f}"
# Create a Gradio interface
iface = gr.Interface(
fn=classify_text, # Function to call
inputs="text", # Input: a text box
outputs="text", # Output: text
title="Text Classifier",
description="Enter some text and see the classification result."
)
# Launch the app
if __name__ == "__main__":
iface.launch()
|