aslan-ng/cheese-text
Viewer • Updated • 1.1k • 6
How to use rlogh/cheese-texture-classifier-distilbert with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="rlogh/cheese-texture-classifier-distilbert") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("rlogh/cheese-texture-classifier-distilbert")
model = AutoModelForSequenceClassification.from_pretrained("rlogh/cheese-texture-classifier-distilbert")Model Creator: Rumi Loghmani (@rlogh)
Original Dataset: aslan-ng/cheese-text (by Aslan Noorghasemi)
This model performs 4-class texture classification on cheese descriptions using fine-tuned DistilBERT.
precision recall f1-score support
hard 0.50 0.33 0.40 3
semi-hard 0.29 0.50 0.36 4 semi-soft 0.40 0.50 0.44 4 soft 1.00 0.25 0.40 4
accuracy 0.40 15
macro avg 0.55 0.40 0.40 15 weighted avg 0.55 0.40 0.40 15
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model and tokenizer
model_name = "rlogh/cheese-texture-classifier-distilbert"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
# Example prediction
text = "Feta is a crumbly, tangy Greek cheese with a salty bite and creamy undertones."
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=512)
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
predicted_class = torch.argmax(predictions, dim=-1).item()
class_names = ["hard", "semi-hard", "semi-soft", "soft"]
print(f"Predicted texture: {class_names[predicted_class]}")
This model was developed using:
Model Citation:
@model{rlogh/cheese-texture-classifier-distilbert,
title={Cheese Texture Classifier (DistilBERT)},
author={Rumi Loghmani},
year={2024},
url={https://huggingface.co/rlogh/cheese-texture-classifier-distilbert}
}
Dataset Citation:
@dataset{aslan-ng/cheese-text,
title={Cheese Text Dataset},
author={Aslan Noorghasemi},
year={2024},
url={https://huggingface.co/datasets/aslan-ng/cheese-text}
}
MIT License - See LICENSE file for details.