Views
No views yet
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4# Load model and tokenizer
5tokenizer = AutoTokenizer.from_pretrained("j2damax/serendip-travel-classifier")
6model = AutoModelForSequenceClassification.from_pretrained("j2damax/serendip-travel-classifier")
7
8# Example text
9text = "The organic tea plantation tour was amazing! We learned about sustainable farming practices."
10
11# Tokenize and predict
12inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
13with torch.no_grad():
14 outputs = model(**inputs)
15 predictions = torch.sigmoid(outputs.logits)
16
17# Get predicted labels
18labels = ["Regenerative & Eco-Tourism", "Integrated Wellness", "Immersive Culinary", "Off-the-Beaten-Path Adventure"]
19predicted_labels = [labels[i] for i, score in enumerate(predictions[0]) if score > 0.5]
20print(f"Predicted labels: predicted_labels")1@misc{serendip-travel-classifier,
2 title={Serendip Travel Experiential Classifier},
3 author={Jayampathy Balasuriya},
4 year={2025},
5 publisher={Hugging Face},
6 url={https://huggingface.co/j2damax/serendip-travel-classifier}
7}