ChaNet ResNet-50 (Thai tea classifier)

ResNet-50 fine-tuned to classify a photo of a drink into 5 Thai tea types: cha_dam_yen (iced black tea), cha_khiao_nom (green milk tea), cha_nom_khai_muk (bubble milk tea), cha_phonlamai (fruit tea), cha_thai (Thai milk tea). Class index follows this alphabetical order.

DADS7202 Deep Learning homework, group Hey Tea. Full report, code and training details: https://github.com/tanpim16/dl_dads7202_heytea · Live demo: https://huggingface.co/spaces/Pimkanit/chanet-demo

Data 913 self-collected images (Bing, Baidu, delivery apps), group split by search query and shop, 638 / 93 / 182
Training ImageNet weights (IMAGENET1K_V2), stage 1 head only, stage 2 unfreeze layer4, class-weighted CE, seed 33
Test (this checkpoint) accuracy 0.918, macro F1 0.915
Test (5 seeds, mean ± SD) macro F1 0.891 ± 0.017

Files

  • resnet50_seed33.pt: PyTorch state_dict
  • chanet_resnet50.onnx: same weights, outputs probs (1, 5) and cams (1, 5, 7, 7), used by the browser demo

Usage (PyTorch)

import torch, torch.nn as nn
from torchvision import models, transforms
from PIL import Image

CLASSES = ["cha_dam_yen", "cha_khiao_nom", "cha_nom_khai_muk", "cha_phonlamai", "cha_thai"]
m = models.resnet50(weights=None)
m.fc = nn.Sequential(nn.Dropout(0.3), nn.Linear(2048, 5))
m.load_state_dict(torch.load("resnet50_seed33.pt", map_location="cpu"))
m.eval()

tf = transforms.Compose([transforms.Resize(256), transforms.CenterCrop(224), transforms.ToTensor(),
                         transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])])
x = tf(Image.open("tea.jpg").convert("RGB")).unsqueeze(0)
print(CLASSES[m(x).argmax().item()])

Limitations

Only 5 classes, so any other image is forced into one of them. The model relies heavily on drink colour: dark fruit teas are often predicted as iced black tea, and red cup logos can pull Thai tea towards fruit tea. Training images came from the web and delivery apps; they are not redistributed here.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Space using Pimkanit/chanet-resnet50 1