Views
No views yet
| Metrik | Nilai |
|---|---|
| Test Accuracy | 0.9012 (90.12%) |
| Best Val Accuracy | 0.9202 (92.02%) |
| Jumlah Kelas | 10 |
| File | Deskripsi |
|---|---|
gumi_banten_cnn_vit.h5 | Model weights dalam format HDF5 |
best_model.pth | Checkpoint PyTorch lengkap |
config.json | Konfigurasi model |
class_names.txt | Daftar nama kelas |
1import torch
2from huggingface_hub import hf_hub_download
3
4pth_path = hf_hub_download(repo_id="Wisnu1354/Gumi-Banten", filename="best_model.pth")
5ckpt = torch.load(pth_path, map_location='cpu')
6model.load_state_dict(ckpt['model_state'])
7model.eval()1import h5py, torch, numpy as np
2from huggingface_hub import hf_hub_download
3
4def load_from_h5(h5_path, model_class, cfg):
5 with h5py.File(h5_path, 'r') as hf:
6 class_names = list(hf['metadata/class_names'][:])
7 state_dict = {}
8 def _load(name, obj):
9 if isinstance(obj, h5py.Dataset):
10 state_dict[name.replace('/', '.')] = torch.tensor(obj[()])
11 hf['model_weights'].visititems(_load)
12 model = model_class(cfg)
13 model.load_state_dict(state_dict)
14 model.eval()
15 return model, class_names
16
17h5_path = hf_hub_download(repo_id="Wisnu1354/Gumi-Banten", filename="gumi_banten_cnn_vit.h5")
18model, class_names = load_from_h5(h5_path, CNNViTHybrid, CFG)