Downloads · 30 days
0
AlexKoff88/mobilenet_v2_food101
mobilenet_v2_food101 is a machine learning model from AlexKoff88. 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 apache-2.0.
MobileNet V2 model from Torchvision fine-tuned for FOOD101 dataset. Checkpoint trained for 30 epoches using https://github.com/AlexKoff88/mobilenetv2food101.
Downloads · 30 days
0
Access
Public
Updated Nov 18, 2022
Repo size
29 MB
Likes
0
Public
Click a slice to open those files.
.bin19.1 MB · 66%
From the Hugging Face model README
MobileNet V2 model from Torchvision fine-tuned for FOOD101 dataset. Checkpoint trained for 30 epoches using https://github.com/AlexKoff88/mobilenetv2_food101.
Top-1 accuracy is 76.3% but one can do better.
The main intend is to use it in samples and demos for model optimization. Here is the advantages:
Here is the code to load the checkpoint in PyTorch:
import sys
import os
import torch
import torch.nn as nn
import torchvision.models as models
FOOD101_CLASSES = 101
def fix_names(state_dict):
state_dict = {key.replace('module.', ''): value for (key, value) in state_dict.items()}
return state_dict
model = models.mobilenet_v2(num_classes=FOOD101_CLASSES)
if len(sys.argv) > 1:
checkpoint_path = sys.argv[1]
if os.path.isfile(checkpoint_path):
print("=> loading checkpoint '{}'".format(checkpoint_path))
checkpoint = torch.load(checkpoint_path)
weights = fix_names(checkpoint['state_dict'])
model.load_state_dict(weights)
print("=> loaded checkpoint '{}' (epoch {})"
.format(checkpoint_path, checkpoint['epoch']))