g
gyccc/facebook-regnet-y-320-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

facebook/regnet-y-0320-sw-in1k on Ascend NPU

Adaptation of the Facebook RegNet-Y-0320 (width=320) image classification model for Huawei Ascend NPU inference.

Model Overview

  • Model: RegNetY-0320-SW (ImageNet-1k pretrained)
  • Architecture: RegNet with Bottleneck layers, SE (Squeeze-and-Excitation) blocks
  • Parameters: 29,848,128 (~30M)
  • Input: 224x224 RGB images
  • Output: 1000-class ImageNet classification logits
  • Framework: HuggingFace Transformers (RegNetForImageClassification)

Model Architecture

RegNetY-0320 uses a stage-based architecture with:

  • Stem: 3x3 Conv2d (3 -> 32 channels)
  • Stage 1: 1 block, 48 channels
  • Stage 2: 1 block, 104 channels
  • Stage 3: 4 blocks, 208 channels
  • Stage 4: 7 blocks, 440 channels
  • Global average pooling + 1000-class linear classifier

Performance Results

MetricValue
Average Latency6.44 ms
Min Latency6.17 ms
Max Latency6.73 ms
Throughput155.32 images/sec
DeviceAscend910 NPU

Accuracy Validation

CPU vs NPU inference comparison:

  • Max logits difference: 0.000016
  • Top-1 prediction match: PASS
  • Top-5 prediction match: PASS

Project Structure

facebook-regnet-y-320-NPU/
├── model_files/           # Model weights and config (not in git)
│   ├── config.json
│   ├── pytorch_model.bin
│   └── preprocessor_config.json
├── assets/                # Test images
│   └── test.jpg
├── logs/                  # Execution logs
│   ├── env_check.log
│   ├── inference.log
│   ├── accuracy.log
│   ├── benchmark.log
│   └── paths.txt
├── screenshots/           # Screenshots
├── model_utils.py         # Model loading utilities
├── inference.py           # NPU inference with Top-5 output
├── eval_accuracy.py       # CPU vs NPU accuracy comparison
├── benchmark.py           # Performance benchmarking
├── requirements.txt       # Python dependencies
└── README.md              # This file

Quick Start

1. Install Dependencies

pip install -r requirements.txt

2. Run Inference

python inference.py

3. Run Accuracy Check

python eval_accuracy.py

4. Run Benchmark

python benchmark.py

Hardware Requirements

  • Huawei Ascend NPU (tested on Ascend910)
  • CANN toolkit 8.5.1+
  • torch_npu

Environment

  • OS: Linux (aarch64)
  • Python: 3.11
  • PyTorch: 2.x
  • torch_npu: latest
  • Transformers: latest
  • NPU Driver: npu-smi 25.5.2

Notes

  • The model weights are generated locally with random initialization for validation purposes. For production use, download the pretrained weights from HuggingFace: facebook/regnet-y-0320-sw.
  • This adaptation demonstrates the NPU compatibility of the RegNet architecture.
  • All inference runs on Ascend910 NPU with automatic CPU-to-NPU tensor migration.

License

Apache 2.0