BotRejectTest / app.py
ChavinloSocialRise's picture
Create app.py
5eed20c verified
raw
history blame
817 Bytes
import gradio as gr
from transformers import pipeline
# Load a pre-trained sentiment-analysis model
classifier = pipeline('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()