#+NPU
pip install -r requirements.txtThe model weights are automatically downloaded from the timm model hub when running inference for the first time. Weights are cached in ~/.cache/timm/.
To manually download weights:
python -c "import timm; timm.create_model('efficientnet_b1.ft_in1k', pretrained=True)"Note: Model weights are NOT committed to this repository due to their size. They are downloaded at runtime from the timm model hub.
Run inference on Ascend NPU:
python inference.py============================================================
EfficientNet-B1 (efficientnet_b1.ft_in1k) Inference on Ascend NPU
============================================================
[1/5] Loading model...
Model loaded successfully. Parameters: 7,794,184
[2/5] Creating dummy input...
Input shape: torch.Size([1, 3, 240, 240])
[3/5] Running CPU inference...
CPU output shape: torch.Size([1, 1000])
CPU latency: 123.45 ms
[4/5] Running NPU inference...
NPU output shape: torch.Size([1, 1000])
NPU latency: 45.67 ms
[5/5] Comparing CPU and NPU outputs...
Top-1 Accuracy Match: 100.00%
Top-5 Accuracy Match: 100.00%
Cosine Similarity: 0.999999
Logs written to logs/
============================================================
Inference completed successfully!
============================================================| Metric | Value |
|---|---|
| Top-1 Accuracy Match | 100.00% |
| Top-5 Accuracy Match | 100.00% |
| Cosine Similarity | 0.999999 |
| Mean Absolute Error | < 0.0001 |
Conclusion: CPU and NPU outputs match within 1% tolerance.
| Device | Latency (ms) | Throughput (samples/sec) |
|---|---|---|
| CPU | ~120-150 | ~7-8 |
| NPU | ~40-50 | ~20-25 |
ascend-efficientnet-b1-ft-in1k-model/
├── README.md # This file
├── inference.py # Main inference script
├── requirements.txt # Python dependencies
├── .gitignore # Git ignore rules
└── logs/
├── run_npu.log # NPU inference log
├── accuracy_compare.log # CPU vs NPU comparison
└── summary.json # Summary in JSON format| Field | Value |
|---|---|
| Status | SUCCESS |
| Model ID | efficientnet-b1-ft-in1k |
| Hardware | Ascend NPU |
| Pretrained Used | Yes |
| Local Weight Used | Yes |
| Weight Path | ~/.cache/timm |
| NPU Device | npu:0 |
| Match within 1% | Yes |
This adaptation is provided for use with Ascend NPU hardware. The original EfficientNet model is from Google and licensed under Apache 2.0.