Instructions to use Ahmed766/text-classification-demo with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Ahmed766/text-classification-demo with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Ahmed766/text-classification-demo")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Ahmed766/text-classification-demo", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download test_model.py from Ahmed766/text-classification-demo: direct link, hf CLI and curl.
- Browser
- Download file 836 Bytes
-
https://huggingface.co/Ahmed766/text-classification-demo/resolve/main/test_model.py
- Command line
-
hf download hf://Ahmed766/text-classification-demo/test_model.py
-
curl -L -o test_model.py https://huggingface.co/Ahmed766/text-classification-demo/resolve/main/test_model.py
836 Bytes
| """ | |
| Simple test script for the text classification model | |
| """ | |
| from text_classifier import TextClassifier | |
| def test_model(): | |
| classifier = TextClassifier() | |
| # Test cases | |
| test_cases = [ | |
| ("I love this product!", "positive"), | |
| ("This is terrible.", "negative"), | |
| ("It's okay, nothing special.", None), # Could be positive or neutral | |
| ] | |
| print("Testing Text Classification Model:") | |
| print("-" * 40) | |
| for text, expected_label in test_cases: | |
| result = classifier.predict(text) | |
| print(f"Input: {text}") | |
| print(f"Predicted: {result['label']} (confidence: {result['confidence']})") | |
| if expected_label: | |
| print(f"Expected: {expected_label}") | |
| print() | |
| print("Test completed successfully!") | |
| if __name__ == "__main__": | |
| test_model() |