Views
No views yet
| File | Architecture | Pretrain | Patch Size | Train:Test | Train Acc | Test Acc | Prediction Acc |
|---|---|---|---|---|---|---|---|
vit-imgt-16(7030).pth ⭐ | ViT-B/16 | ImageNet | 16×16 px | 70:30 | 97.02% | 84.72% | 91.67% |
vit-imgt-16(8020).pth | ViT-B/16 | ImageNet | 16×16 px | 80:20 | 96.98% | 86.25% | 88.34% |
vit-imgt-16(5050).pth | ViT-B/16 | ImageNet | 16×16 px | 50:50 | 98.50% | 83.50% | 86.67% |
vit-imgt-16(4060).pth | ViT-B/16 | ImageNet | 16×16 px | 40:60 | 99.80% | 79.72% | 83.34% |
vit-imgt-32(7030).pth | ViT-B/32 | ImageNet | 32×32 px | 70:30 | 97.50% | 81.67% | 76.67% |
vit-imgt-32(8020).pth | ViT-B/32 | ImageNet | 32×32 px | 80:20 | 97.29% | 81.67% | 76.67% |
vit-imgt-32(5050).pth | ViT-B/32 | ImageNet | 32×32 px | 50:50 | 98.50% | 79.67% | 76.67% |
vit-imgt-32(4060).pth | ViT-B/32 | ImageNet | 32×32 px | 40:60 | 99.58% | 77.22% | 61.67% |
vit-hgfc-16(8020).pth | ViT-B/16 | HuggingFace | 16×16 px | 80:20 | 81.11% | 80.83% | 90.00% |
vit-hgfc-16(7030).pth | ViT-B/16 | HuggingFace | 16×16 px | 70:30 | 81.31% | 78.05% | 90.00% |
vit-hgfc-16(5050).pth | ViT-B/16 | HuggingFace | 16×16 px | 50:50 | 79.83% | 75.00% | 85.00% |
vit-hgfc-16(4060).pth | ViT-B/16 | HuggingFace | 16×16 px | 40:60 | 79.58% | 71.53% | 83.34% |
vit-hgfc-32(8020).pth | ViT-B/32 | HuggingFace | 32×32 px | 80:20 | 82.71% | 81.67% | 78.34% |
vit-hgfc-32(7030).pth | ViT-B/32 | HuggingFace | 32×32 px | 70:30 | 82.26% | 79.17% | 78.34% |
vit-hgfc-32(5050).pth | ViT-B/32 | HuggingFace | 32×32 px | 50:50 | 81.33% | 77.67% | 80.00% |
vit-hgfc-32(4060).pth | ViT-B/32 | HuggingFace | 32×32 px | 40:60 | 79.58% | 76.94% | 78.34% |
mobilenetv2(7030)weight.pth | MobileNetV2 | ImageNet | — | 70:30 | 79.29% | 78.33% | 86.67% |
mobilenetv2(8020)weight.pth | MobileNetV2 | ImageNet | — | 80:20 | 79.79% | 78.33% | 75.00% |
mobilenetv2(5050)weight.pth | MobileNetV2 | ImageNet | — | 50:50 | 80.00% | 76.17% | 81.67% |
mobilenetv2(4060)weight.pth | MobileNetV2 | ImageNet | — | 40:60 | 79.79% | 74.17% | 86.67% |
coffeebean_vit_best.onnx + .onnx.data | ViT-B/16 (best) | ImageNet | 16×16 px | 70:30 | — | — | 91.67% |
| Label | Grade |
|---|---|
mutu1 | Specialty — 0 defects per 300g |
mutu2 | Grade 1 — max 11 defect values |
mutu3 | Grade 2 — 12–25 defect values |
mutu4 | Grade 3 — 26–44 defect values |
mutu5 | Grade 4a — 45–60 defect values |
mutu6 | Grade 4b — 61–80 defect values |
1import torch
2import torchvision.models as models
3from torchvision import transforms
4from PIL import Image
5
6# 1. Setup model
7class_names = ['mutu1', 'mutu2', 'mutu3', 'mutu4', 'mutu5', 'mutu6']
8model = models.vit_b_16(weights=None)
9model.heads = torch.nn.Sequential(
10 torch.nn.Dropout(0.1),
11 torch.nn.Linear(768, len(class_names))
12)
13
14# 2. Load weights (download from this repo first)
15checkpoint = torch.load('vit-imgt-16(7030).pth', map_location='cpu')
16model.load_state_dict(checkpoint)
17model.eval()
18
19# 3. Preprocessing (ImageNet standard)
20transform = transforms.Compose([
21 transforms.Resize((224, 224)),
22 transforms.ToTensor(),
23 transforms.Normalize(
24 mean=[0.485, 0.456, 0.406],
25 std=[0.229, 0.224, 0.225]
26 )
27])
28
29# 4. Predict
30image = Image.open('your_coffee_image.jpg')
31input_tensor = transform(image).unsqueeze(0)
32
33with torch.no_grad():
34 outputs = model(input_tensor)
35 probabilities = torch.softmax(outputs, dim=1)
36 predicted_idx = torch.argmax(probabilities).item()
37
38print(f"Predicted: {class_names[predicted_idx]}")
39print(f"Confidence: {probabilities[0, predicted_idx].item():.4f}")1import torchvision.models as models
2
3class_names = ['mutu1', 'mutu2', 'mutu3', 'mutu4', 'mutu5', 'mutu6']
4model = models.mobilenet_v2(weights=None)
5model.classifier[1] = torch.nn.Linear(model.last_channel, len(class_names))
6
7checkpoint = torch.load('mobilenetv2(7030)weight.pth', map_location='cpu')
8model.load_state_dict(checkpoint)
9model.eval()| Parameter | Value |
|---|---|
| Framework | PyTorch + torchvision |
| Optimizer | AdamW (lr=1e-3, weight_decay=3e-2) |
| Loss | CrossEntropyLoss |
| Epochs | 90 |
| Batch size | 10 |
| Input size | 224×224 px |
| Dropout | 0.1 (classifier head) |
| Normalization | ImageNet mean/std ([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]) |
1@thesis{zaafirrahman2024vit,
2 author = {Aulya Az Zaafirrahman},
3 title = {Klasifikasi Mutu Biji Kopi Arabika Berbasis Image Processing Menggunakan Metode Vision Transformer (ViT)},
4 school = {Universitas Brawijaya},
5 type = {Teknik Industri Pertanian},
6 year = {2024}
7}