Downloads · 30 days
9
4% of all-time downloads
hilmiatha/resnet18-flower-classifier
resnet18-flower-classifier is a image classification model from hilmiatha. Use it when you need a label for an image. It is set up for transformers.
metrics: - name: Accuracy type: Accuracy value: 0.8980
Downloads · 30 days
9
4% of all-time downloads
All-time downloads
235
Public
Repo size
89.6 MB
Likes
0
Public
Click a slice to open those files.
.bin44.8 MB · 100%
From the Hugging Face model README
metrics: - name: Accuracy type: Accuracy value: 0.8980
This model classifies images into one of five flower types.
from torchvision import transforms
from PIL import Image
import torch
from torchvision.models import resnet18
model = resnet18(weights=None)
model.load_state_dict(torch.load('path_to_model/pytorch_model.bin'))
model.eval()
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])
])
image = Image.open('path_to_image.jpg')
image = transform(image).unsqueeze(0)
with torch.no_grad():
output = model(image)
_, predicted = torch.max(output.data, 1)
print(predicted.item())