| --- |
| license: cc-by-4.0 |
| tags: |
| - food |
| - nutrition |
| - calorie-estimation |
| - regression |
| - pytorch |
| --- |
| |
| # NutriConsistNet (V2) |
|
|
| Predicts total calories, mass, fat, carb and protein of a plate from ONE overhead RGB photo. |
|
|
| - Backbone: ResNet-50 (ImageNet pretrained) |
| - Structure: mass x per-gram density decomposition (totals = density * mass) |
| - Trained with an Atwater energy-consistency loss: |
| calories = 4*protein + 4*carb + 9*fat (soft penalty, lambda = 0.1) |
| - V2 additionally supervises the density head and anchors mass more strongly |
| - Dataset: Nutrition5k, overhead RGB subset, official train/test split |
| - Input: one 320x320 RGB overhead photo, ImageNet normalization (no depth needed) |
| - Output order: [calories(kcal), mass(g), fat(g), carb(g), protein(g)] |
| |
| ## Test results (official Nutrition5k test split, single-frame protocol) |
| Calories MAE: 44.7 kcal (17.5%) |
| Mass MAE: 26.2 g (13.2%) |
| Fat MAE: 3.4 g (26.5%) |
| Carb MAE: 5.0 g (25.2%) |
| Protein MAE: 4.3 g (24.6%) |
| Atwater violation of final predictions: 8.3 kcal |
| |
| ## How to load |
| ```python |
| import numpy as np, torch, torch.nn as nn, torchvision.models as tvm |
| # paste the model class from the training notebook, then: |
| means = np.load("train_means.npy") |
| model = NutriConsistNetV2(means) # for the v2 file |
| # model = NutriConsistNet() # for the e2 file |
| model.load_state_dict(torch.load("nutriconsistnet_v2.pt", map_location="cpu")) |
| model.eval() |
| ``` |
| |