g
gyccc/timm-swin_small_patch4_window7_224.ms_in22k-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

timm/swin_small_patch4_window7_224.ms_in22k - Ascend NPU

Swin Transformer Small pretrained on ImageNet-22k (21841 classes), adapted for single-card Huawei Ascend NPU inference via PyTorch + torch_npu.

ItemValue
Modeltimm/swin_small_patch4_window7_224.ms_in22k
ArchitectureSwin Transformer Small
PretrainImageNet-22k (Microsoft)
Input Resolution224x224
num_classes21841
HardwareHuawei Ascend NPU

Inference

pip install -r requirements.txt
python3 inference.py

Top-5 predictions from assets/test.jpg:

RankClass IDScore
Top-195350.0041
Top-275850.0030
Top-392690.0028
Top-450600.0027
Top-570020.0026

Accuracy

python3 eval_accuracy.py

CPU vs NPU consistency check on a single test image:

MetricValue
max_abs_error0.008706
mean_abs_error0.001523
relative_error0.1555%
cosine_similarity0.999999
top1_matchTrue
top5_matchTrue
CPU Top-5[9535, 7585, 9269, 5060, 7002]
NPU Top-5[9535, 7585, 9269, 5060, 7002]
ResultPASS

Benchmark

python3 benchmark.py

Single-image latency on Ascend NPU (10 runs, batch=1):

MetricValue
Input shape[1, 3, 224, 224]
avg_latency17.33 ms
min_latency16.83 ms
max_latency17.72 ms
p50_latency17.61 ms
p90_latency17.66 ms
p95_latency17.69 ms
images_per_sec57.70

Self-Verification

Self-Verification

#NPU