ResNet18 gains +1.93 pp top-1 at 4.5× the size. Whether that trade-off is worth it depends heavily
on the deployment target.
1wget https://zenodo.org/records/5645731/files/plantnet_300K_images.tar.gz
2tar -xzf plantnet_300K_images.tar.gz
1# Edit DATA_DIR and set model = models.resnet18(...) in train.py
2python train.py
1import torch
2from torchvision import models, transforms
3from huggingface_hub import hf_hub_download
4from PIL import Image
5
6model = models.resnet18(weights=None, num_classes=1081)
7path = hf_hub_download("cpoisson/plantnet300k-resnet18", "plantnet_resnet18.pth")
8model.load_state_dict(torch.load(path, map_location="cpu", weights_only=True))
9model.eval()
10
11transform = transforms.Compose([
12 transforms.Resize(256),
13 transforms.CenterCrop(224),
14 transforms.ToTensor(),
15 transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
16])
17
18img = Image.open("your_plant.jpg").convert("RGB")
19with torch.no_grad():
20 logits = model(transform(img).unsqueeze(0))
21 probs = torch.softmax(logits, dim=1)[0]
22 top5 = probs.topk(5)
1@inproceedings{plantnet-300k,
2 author = {Garcin, Camille and Joly, Alexis and Bonnet, Pierre and Lombardo, Jean-Christophe
3 and Affouard, Antoine and Chouet, Mathias and Servajean, Maximilien
4 and Lorieul, Titouan and Salmon, Joseph},
5 booktitle = {NeurIPS Datasets and Benchmarks 2021},
6 title = {{Pl@ntNet-300K}: a plant image dataset with high label ambiguity and a long-tailed distribution},
7 year = {2021},
8}