Update test_model.py
Browse files- test_model.py +11 -7
test_model.py
CHANGED
|
@@ -1,12 +1,16 @@
|
|
| 1 |
-
from transformers import pipeline
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
classifier = pipeline("text-classification", model=model_name)
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
result = classifier(sample_text)
|
| 10 |
|
| 11 |
-
# Print the output
|
| 12 |
print(result)
|
|
|
|
| 1 |
+
from transformers import pipeline, AutoTokenizer
|
| 2 |
|
| 3 |
+
model_name = "DilipKY/my-text-classifier"
|
| 4 |
+
tokenizer_name = "bert-base-uncased" # Use "bert-base-cased" if your model is case-sensitive
|
|
|
|
| 5 |
|
| 6 |
+
# Load the correct tokenizer
|
| 7 |
+
tokenizer = AutoTokenizer.from_pretrained(tokenizer_name)
|
| 8 |
+
|
| 9 |
+
# Load the model with the tokenizer
|
| 10 |
+
classifier = pipeline("text-classification", model=model_name, tokenizer=tokenizer)
|
| 11 |
+
|
| 12 |
+
# Test the model
|
| 13 |
+
sample_text = "I love this product! It's amazing."
|
| 14 |
result = classifier(sample_text)
|
| 15 |
|
|
|
|
| 16 |
print(result)
|