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