Commit
•
0afacc9
1
Parent(s):
c5f4573
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,29 @@
|
|
1 |
---
|
2 |
license: unknown
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: unknown
|
3 |
---
|
4 |
+
## How to Use
|
5 |
+
|
6 |
+
Here is an example of how to use this model to get predictions and convert them back to labels:
|
7 |
+
|
8 |
+
```python
|
9 |
+
import tensorflow as tf
|
10 |
+
from transformers import TFAutoModelForSequenceClassification, AutoTokenizer
|
11 |
+
import joblib
|
12 |
+
|
13 |
+
# Load the model and tokenizer
|
14 |
+
model = TFAutoModelForSequenceClassification.from_pretrained("NeuEraAI/Stress_Classifier_BERT")
|
15 |
+
tokenizer = AutoTokenizer.from_pretrained("NeuEraAI/Stress_Classifier_BERT")
|
16 |
+
|
17 |
+
# Load your label encoder
|
18 |
+
label_encoder = joblib.load("label_encoder.joblib")
|
19 |
+
|
20 |
+
def decode_predictions(predictions):
|
21 |
+
# Extract predicted indices (assuming predictions is a list of dicts with 'label' keys)
|
22 |
+
predicted_indices = [int(pred['label'].split('_')[-1]) for pred in predictions]
|
23 |
+
# Decode the indices to original labels
|
24 |
+
decoded_labels = label_encoder.inverse_transform(predicted_indices)
|
25 |
+
return decoded_labels
|
26 |
+
|
27 |
+
# Example usage
|
28 |
+
text = "Your example input text here."
|
29 |
+
decode_predictions(model.predict(text))
|