STDC/tools/check/checklatest.py
charlie880624 7716a0060f
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
feat: add golf dataset, kneron configs, and tools
- 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>
2026-03-18 13:14:30 +08:00

34 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import torch
def check_pth_num_classes(pth_path):
checkpoint = torch.load(pth_path, map_location='cpu')
if 'state_dict' not in checkpoint:
print("❌ 找不到 state_dict這可能不是 MMSegmentation 的模型檔")
return
state_dict = checkpoint['state_dict']
# 找出 decode head 最後一層分類器的 weight tensor
num_classes = None
for k in state_dict.keys():
if 'decode_head' in k and 'weight' in k and 'decode_head.classifier' in k:
weight_tensor = state_dict[k]
num_classes = weight_tensor.shape[0]
print(f"✅ 檢查到類別數: {num_classes}")
break
if num_classes is None:
print("⚠️ 無法判斷類別數,可能模型架構非標準格式")
else:
if num_classes == 19:
print("⚠️ 這是 Cityscapes 預設模型 (19 類)")
elif num_classes == 4:
print("✅ 這是 GolfDataset 自訂模型 (4 類)")
else:
print("❓ 類別數異常,請確認訓練資料與 config 設定是否一致")
if __name__ == '__main__':
pth_path = r'C:\Users\rd_de\kneronstdc\work_dirs\meconfig\latest.pth'
check_pth_num_classes(pth_path)