1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4repo_id = 'sakibalfahim/CrisisPulse'
5token = 'hf_xxx' # use secure token or Hugging Face login
6tokenizer = AutoTokenizer.from_pretrained(repo_id, token=token)
7model = AutoModelForSequenceClassification.from_pretrained(repo_id, token=token)
8model.eval()
9
10inputs = tokenizer('Massive flood reported in downtown area', return_tensors='pt', truncation=True)
11with torch.no_grad():
12 logits = model(**inputs).logits
13 pred = int(logits.argmax(-1)[0].item())
14print('Prediction:', {0: 'Not Disaster', 1: 'Disaster'}[pred])
Intended for research/demo use. Validate on your domain before any high-stakes use. Be cautious with domain shift, sarcasm, or non-English text.
Check the
notebook for exact preprocessing, hyperparameters, and seed.
Apache-2.0 License.
Author: sakibalfahim — via Hugging Face profile.