Views
No views yet
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4# Load the model
5model_name = "SrothJr/banglamentalBERT-mBERT-dapt"
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForSequenceClassification.from_pretrained(model_name)
8
9# Inference
10text = "আপনার বাংলা টেক্সট এখানে (Your Bengali text here)"
11inputs = tokenizer(text, return_tensors="pt")
12
13with torch.no_grad():
14 outputs = model(**inputs)
15
16predictions = torch.argmax(outputs.logits, dim=-1)
17labels = ["Minimum", "Mild", "Moderate", "Severe"]
18print(f"Prediction: {labels[predictions.item()]}")