| import gradio as gr | |
| from text_classifier import TextClassifier | |
| classifier = TextClassifier() | |
| def predict_sentiment(text): | |
| result = classifier.predict(text) | |
| return result['label'], result['confidence'] | |
| demo = gr.Interface( | |
| fn=predict_sentiment, | |
| inputs=gr.Textbox(label="Enter text for sentiment analysis", lines=3), | |
| outputs=[ | |
| gr.Textbox(label="Sentiment"), | |
| gr.Number(label="Confidence Score") | |
| ], | |
| title="📝 Text Classification Model", | |
| description="This model performs sentiment analysis using a pre-trained transformer model.", | |
| examples=[ | |
| ["I love this product! It's amazing."], | |
| ["This is terrible. I hate it."], | |
| ["It's okay, nothing special."] | |
| ] | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() |