File size: 1,087 Bytes
7b32243 d0f54e7 7b32243 0afacc9 d0f54e7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
---
license: unknown
datasets:
- The-Adnan-Syed/Reddit-Stress-Classification
pipeline_tag: text-classification
---
## How to Use
Here is an example of how to use this model to get predictions and convert them back to labels:
```python
import tensorflow as tf
from transformers import TFAutoModelForSequenceClassification, AutoTokenizer
import joblib
# Load the model and tokenizer
model = TFAutoModelForSequenceClassification.from_pretrained("NeuEraAI/Stress_Classifier_BERT")
tokenizer = AutoTokenizer.from_pretrained("NeuEraAI/Stress_Classifier_BERT")
# Load your label encoder
label_encoder = joblib.load("label_encoder.joblib")
def decode_predictions(predictions):
# Extract predicted indices (assuming predictions is a list of dicts with 'label' keys)
predicted_indices = [int(pred['label'].split('_')[-1]) for pred in predictions]
# Decode the indices to original labels
decoded_labels = label_encoder.inverse_transform(predicted_indices)
return decoded_labels
# Example usage
text = "Your example input text here."
decode_predictions(model.predict(text)) |