Some checks failed
deploy / build-n-publish (push) Has been cancelled
lint / lint (push) Has been cancelled
build / build_cpu (3.7, 1.5.1, torch1.5, 0.6.1) (push) Has been cancelled
build / build_cpu (3.7, 1.6.0, torch1.6, 0.7.0) (push) Has been cancelled
build / build_cpu (3.7, 1.7.0, torch1.7, 0.8.1) (push) Has been cancelled
build / build_cpu (3.7, 1.8.0, torch1.8, 0.9.0) (push) Has been cancelled
build / build_cpu (3.7, 1.9.0, torch1.9, 0.10.0) (push) Has been cancelled
build / build_cuda101 (3.7, 1.5.1+cu101, torch1.5, 0.6.1+cu101) (push) Has been cancelled
build / build_cuda101 (3.7, 1.6.0+cu101, torch1.6, 0.7.0+cu101) (push) Has been cancelled
build / build_cuda101 (3.7, 1.7.0+cu101, torch1.7, 0.8.1+cu101) (push) Has been cancelled
build / build_cuda101 (3.7, 1.8.0+cu101, torch1.8, 0.9.0+cu101) (push) Has been cancelled
build / build_cuda102 (3.6, 1.9.0+cu102, torch1.9, 0.10.0+cu102) (push) Has been cancelled
build / build_cuda102 (3.7, 1.9.0+cu102, torch1.9, 0.10.0+cu102) (push) Has been cancelled
build / build_cuda102 (3.8, 1.9.0+cu102, torch1.9, 0.10.0+cu102) (push) Has been cancelled
build / build_cuda102 (3.9, 1.9.0+cu102, torch1.9, 0.10.0+cu102) (push) Has been cancelled
build / test_windows (windows-2022, cpu, 3.8) (push) Has been cancelled
build / test_windows (windows-2022, cu111, 3.8) (push) Has been cancelled
- Add golf1/2/4/7/8 dataset classes for semantic segmentation - Add kneron-specific configs (meconfig series, kn_stdc1_golf4class) - Organize scripts into tools/check/ and tools/kneron/ - Add kneron_preprocessing module - Update README with quick-start guide - Update .gitignore to exclude data dirs, onnx, nef outputs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
30 lines
943 B
Python
30 lines
943 B
Python
import torch
|
|
|
|
def check_num_classes_from_pth(pth_path):
|
|
checkpoint = torch.load(pth_path, map_location='cpu')
|
|
|
|
if 'state_dict' not in checkpoint:
|
|
print("❌ 找不到 state_dict")
|
|
return
|
|
|
|
state_dict = checkpoint['state_dict']
|
|
weight_key = 'decode_head.conv_seg.weight'
|
|
|
|
if weight_key in state_dict:
|
|
weight = state_dict[weight_key]
|
|
num_classes = weight.shape[0]
|
|
print(f"✅ 類別數: {num_classes}")
|
|
|
|
if num_classes == 19:
|
|
print("⚠️ 這是 Cityscapes 模型 (19 類)")
|
|
elif num_classes == 4:
|
|
print("✅ 這是 GolfDataset 模型 (4 類)")
|
|
else:
|
|
print("❓ 非常規類別數,請自行確認資料與 config")
|
|
else:
|
|
print(f"❌ 找不到分類層: {weight_key}")
|
|
|
|
if __name__ == '__main__':
|
|
pth_path = r'C:\Users\rd_de\kneronstdc\work_dirs\meconfig\latest.pth'
|
|
check_num_classes_from_pth(pth_path)
|