DilipKY commited on
Commit
12d3b66
·
verified ·
1 Parent(s): 41501ce

Update test_model.py

Browse files
Files changed (1) hide show
  1. test_model.py +11 -7
test_model.py CHANGED
@@ -1,12 +1,16 @@
1
- from transformers import pipeline
2
 
3
- # Load the model from Hugging Face
4
- model_name = "DilipKY/my-text-classifier" # Ensure this matches your model name
5
- classifier = pipeline("text-classification", model=model_name)
6
 
7
- # Test with a sample text
8
- sample_text = "This movie was amazing! The plot was so engaging and the acting was superb."
 
 
 
 
 
 
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)