Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: id
|
| 3 |
+
license: mit
|
| 4 |
+
tags:
|
| 5 |
+
- image-classification
|
| 6 |
+
- plant-identification
|
| 7 |
+
- pytorch
|
| 8 |
+
- cnn
|
| 9 |
+
- vision-transformer
|
| 10 |
+
- efficientnet
|
| 11 |
+
- vit
|
| 12 |
+
datasets:
|
| 13 |
+
- gumi-banten
|
| 14 |
+
metrics:
|
| 15 |
+
- accuracy
|
| 16 |
+
model-index:
|
| 17 |
+
- name: CNN EfficientNet-B4 — Gumi Banten
|
| 18 |
+
results:
|
| 19 |
+
- task:
|
| 20 |
+
type: image-classification
|
| 21 |
+
metrics:
|
| 22 |
+
- type: accuracy
|
| 23 |
+
value: 0.9851
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
# 🌿 Gumi Banten Plant Identification — CNN EfficientNet-B4
|
| 27 |
+
|
| 28 |
+
Model identifikasi tanaman Gumi Banten menggunakan arsitektur hybrid **CNN (EfficientNet-B4) + Vision Transformer (ViT)**.
|
| 29 |
+
|
| 30 |
+
## 📊 Performa Model
|
| 31 |
+
| Metrik | Nilai |
|
| 32 |
+
|--------|-------|
|
| 33 |
+
| **Test Accuracy** | 0.9851 (98.51%) |
|
| 34 |
+
| **Best Val Accuracy** | 0.9876 (98.76%) |
|
| 35 |
+
| **Jumlah Kelas** | 10 |
|
| 36 |
+
|
| 37 |
+
## 🏗️ Arsitektur
|
| 38 |
+
- **CNN Backbone**: EfficientNet-B4 (pretrained, global_pool=avg)
|
| 39 |
+
- **Classifier Head**: Dropout → Linear(1792→512) → GELU → Dropout → Linear(512→N)
|
| 40 |
+
- **Input Size**: 224×224 px
|
| 41 |
+
- **Framework**: PyTorch (weights disimpan sebagai HDF5/.h5)
|
| 42 |
+
|
| 43 |
+
## 📦 File dalam Repo
|
| 44 |
+
| File | Deskripsi |
|
| 45 |
+
|------|-----------|
|
| 46 |
+
| `gumi_banten_cnn_vit.h5` | Model weights dalam format HDF5 |
|
| 47 |
+
| `best_model.pth` | Checkpoint PyTorch lengkap |
|
| 48 |
+
| `config.json` | Konfigurasi model |
|
| 49 |
+
| `class_names.txt` | Daftar nama kelas |
|
| 50 |
+
|
| 51 |
+
## 🚀 Cara Menggunakan
|
| 52 |
+
|
| 53 |
+
### Load dari .pth (PyTorch — Direkomendasikan)
|
| 54 |
+
```python
|
| 55 |
+
import torch
|
| 56 |
+
from huggingface_hub import hf_hub_download
|
| 57 |
+
|
| 58 |
+
pth_path = hf_hub_download(repo_id="Wisnu1354/CNN-GumiBanten", filename="best_model.pth")
|
| 59 |
+
ckpt = torch.load(pth_path, map_location='cpu')
|
| 60 |
+
model.load_state_dict(ckpt['model_state'])
|
| 61 |
+
model.eval()
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
### Load dari .h5
|
| 65 |
+
```python
|
| 66 |
+
import h5py, torch, numpy as np
|
| 67 |
+
from huggingface_hub import hf_hub_download
|
| 68 |
+
|
| 69 |
+
def load_from_h5(h5_path, model_class, cfg):
|
| 70 |
+
with h5py.File(h5_path, 'r') as hf:
|
| 71 |
+
class_names = list(hf['metadata/class_names'][:])
|
| 72 |
+
state_dict = {}
|
| 73 |
+
def _load(name, obj):
|
| 74 |
+
if isinstance(obj, h5py.Dataset):
|
| 75 |
+
state_dict[name.replace('/', '.')] = torch.tensor(obj[()])
|
| 76 |
+
hf['model_weights'].visititems(_load)
|
| 77 |
+
model = model_class(cfg)
|
| 78 |
+
model.load_state_dict(state_dict)
|
| 79 |
+
model.eval()
|
| 80 |
+
return model, class_names
|
| 81 |
+
|
| 82 |
+
h5_path = hf_hub_download(repo_id="Wisnu1354/CNN-GumiBanten", filename="gumi_banten_cnn_vit.h5")
|
| 83 |
+
model, class_names = load_from_h5(h5_path, EfficientNetB4, CFG)
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
## 📋 Kelas yang Didukung
|
| 87 |
+
- Daun Ancak
|
| 88 |
+
- Daun Base
|
| 89 |
+
- Daun Bila
|
| 90 |
+
- Daun Bingin
|
| 91 |
+
- Daun Dapdap
|
| 92 |
+
- Daun Intaran
|
| 93 |
+
- Daun Kayu Tulak
|
| 94 |
+
- Daun Kelor
|
| 95 |
+
- Daun Nagasari
|
| 96 |
+
- Daun Pucuk Rejuna
|
| 97 |
+
|
| 98 |
+
## 🧑💻 Training
|
| 99 |
+
Dilatih di Google Colab menggunakan GPU A100/V100/T4.
|
| 100 |
+
|
| 101 |
+
---
|
| 102 |
+
*Dibuat oleh: Gumi Banten Research | 2026-04-28*
|