Downloads · 30 days
0
benvened/nutrilens-resnet18
nutrilens-resnet18 is a machine learning model from benvened. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
--- license: mit tags: - food-classification - computer-vision - resnet18 - food-101 libraryname: pytorch ---
Downloads · 30 days
0
Access
Public
Updated May 30, 2026
Repo size
44.8 MB
Likes
0
Public
Click a slice to open those files.
.pt44.8 MB · 100%
From the Hugging Face model README
license: mit tags:
ResNet18 fine-tuned auf einem 30-Klassen-Subset von Food-101.
Performance: 62% Top-1 Accuracy (Test-Set, 2400 Bilder)
Hinweis: Dieses Modell wurde im Rahmen des Projekts NutriLens als Baseline-Vergleich trainiert. In der finalen App wird stattdessen CLIP ViT-B/32 Zero-Shot eingesetzt (89% Accuracy). Siehe Projekt-Doku für Details.
Pizza, Hamburger, Hot Dog, French Fries, Donuts, Pancakes, Waffles, Cheesecake, Apple Pie, Steak, Spaghetti Bolognese, Lasagna, Tiramisu, Bruschetta, Ravioli, Risotto, Sushi, Ramen, Pad Thai, Dumplings, Fried Rice, Spring Rolls, Tacos, Guacamole, Caesar Salad, Greek Salad, Hummus, Falafel, Omelette, Ice Cream
import torch
import torch.nn as nn
from torchvision import models, transforms
from huggingface_hub import hf_hub_download
# Modell laden
ckpt_path = hf_hub_download("benvened/nutrilens-resnet18", "cv_model.pt")
model = models.resnet18(weights=None)
model.fc = nn.Linear(model.fc.in_features, 30)
model.load_state_dict(torch.load(ckpt_path, map_location="cpu"))
model.eval()
# Inferenz
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]),
])
from PIL import Image
img = transform(Image.open("food.jpg")).unsqueeze(0)
with torch.no_grad():
pred = model(img).argmax(dim=1).item()
Trained as part of the AI Applications course project at ZHAW (Zurich University of Applied Sciences).