MobileNetV3-Large-075 是 MobileNetV3-Large 的宽度缩减版本,采用 0.75 倍宽度乘数来减少通道数,同时保持 Large 系列网络的深度。该模型在 ImageNet-1K 数据集上进行训练,输入尺寸为 224x224。
原始模型:timm/tf_mobilenetv3_large_075.in1k
| 组件 | 版本 |
|---|---|
| NPU | Ascend910 |
| CANN | 25.5.2 |
| PyTorch | 2.9.0 |
| torch_npu | 2.9.0 |
| timm | 1.0.27 |
| Python | 3.11.14 |
| 操作系统 | Linux (aarch64) |
pip install torch torchvision timm Pillow numpy modelscope safetensors
export MODELSCOPE_CACHE=/tmp/modelscope# CPU inference
python3 inference.py --model_name tf_mobilenetv3_large_075.in1k --device cpu --output_dir ./tf_mobilenetv3_large_075.in1k
# NPU inference
python3 inference.py --model_name tf_mobilenetv3_large_075.in1k --device npu --output_dir ./tf_mobilenetv3_large_075.in1k| 指标 | CPU | NPU (Ascend910) |
|---|---|---|
| 输入尺寸 | 224x224 | 224x224 |
| 平均推理时间 | 24.18 ms | 5.83 ms |
| Top-1 类别 | class 549 | class 549 |
| Top-1 概率 | 7.4729% | 7.4055% |
NPU 加速比:4.1 倍(对比 CPU)。
| 指标 | 数值 |
|---|---|
| 最大 logits 差异 | 0.01664400 |
| 平均 logits 差异 | 0.00292952 |
| 余弦相似度 | 0.999994 |
| 最大概率差异 | 0.067369% |
| 平均概率差异 | 0.000392% |
| 相对 L2 误差 | 0.335626% |
| Top-1 匹配 | 是 |
| Top-5 重叠率 | 5/5 |
Top-5 预测结果:
| 排名 | CPU 类别 | CPU 概率 | NPU 类别 | NPU 概率 |
|---|---|---|---|---|
| 1 | class 549 | 7.4729% | class 549 | 7.4055% |
| 2 | class 902 | 4.7883% | class 902 | 4.7955% |
| 3 | class 916 | 3.7425% | class 916 | 3.7318% |
| 4 | class 446 | 2.7991% | class 446 | 2.7828% |
| 5 | class 409 | 2.7624% | class 409 | 2.7593% |
NPU 与 CPU 误差 < 1%。所有指标均表明 NPU 结果与 CPU 匹配:

import torch
import timm
from PIL import Image
from timm.data import create_transform, resolve_data_config
model = timm.create_model('tf_mobilenetv3_large_075.in1k', pretrained=True)
model.eval()
if torch.npu.is_available():
model = model.npu()
transform = create_transform(**resolve_data_config(model.pretrained_cfg, model=model))
img = Image.open('image.jpg').convert('RGB')
input_tensor = transform(img).unsqueeze(0)
if torch.npu.is_available():
input_tensor = input_tensor.npu()
with torch.no_grad():
logits = model(input_tensor)
probs = torch.nn.functional.softmax(logits, dim=-1)
top5 = torch.topk(probs, k=5)
for i in range(5):
print(f"class {top5.indices[0][i].item()}: {top5.values[0][i].item()*100:.2f}%")