aslan-ng/cheese-image
Viewer • Updated • 510 • 6
Model Creator: Rumi Loghmani (@rlogh)
Original Dataset: aslan-ng/cheese-image (by Aslan Noorghasemi)
This model performs 4-class texture classification on cheese images using AutoML-optimized transfer learning. The model was developed by Rumi Loghmani using the cheese image dataset created by Aslan Noorghasemi.
{
"model_name": "resnet34",
"dropout_rate": 0.4682019316470914,
"learning_rate": 0.00027817005315620047,
"weight_decay": 1.4677013775851028e-05,
"batch_size": 2
}
import torch
import torch.nn as nn
from PIL import Image
import torchvision.transforms as transforms
import torchvision.models as models
# Load model (define TransferLearningModel class first)
model = TransferLearningModel(num_classes=4, dropout_rate=0.4682019316470914, model_name='resnet34')
model.load_state_dict(torch.load('pytorch_model.bin'))
model.eval()
# Preprocess image
transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])
# Load and preprocess image
image = Image.open('cheese_image.jpg').convert('RGB')
input_tensor = transform(image).unsqueeze(0)
# Make prediction
with torch.no_grad():
output = model(input_tensor)
probabilities = torch.softmax(output, dim=1)
predicted_class = torch.argmax(probabilities, dim=1).item()
class_names = ["Low Texture", "Medium-Low Texture", "Medium-High Texture", "High Texture"]
print(f"Predicted class: {class_names[predicted_class]}")
This notebook was developed with the assistance of AI as a coding co-pilot. AI tools were used to:
The AI served as a valuable partner throughout the development process, accelerating coding and improving code quality.
If you use this model, please cite both the model and the original dataset:
Model Citation:
@model{rlogh/cheese-texture-classifier-automl,
title={Cheese Texture Classifier (AutoML)},
author={Rumi Loghmani},
year={2024},
url={https://huggingface.co/rlogh/cheese-texture-classifier-automl}
}
Dataset Citation:
@dataset{aslan-ng/cheese-image,
title={Cheese Image Dataset},
author={Aslan Noorghasemi},
year={2024},
url={https://huggingface.co/datasets/aslan-ng/cheese-image}
}