/ Модель

Характеристики

Лицензия
BSD 3-Clause
Библиотека
litert
Опубликована
8 мая 2026

densenet121

Классификация изображенийИзображение → label4 профессии
240скачиваний за 30 дней2лайкавеса обновлены15 ноя 2026

Описание модели

Составлено на русском по карточке модели и метаданным Hugging Face

Перенос TorchVision DenseNet121 в LiteRT/TFLite для классификации RGB-изображений по 1 000 классам ImageNet-1k на CPU и совместимых мобильных NPU.

Это перенос моделей TorchVision DenseNet121 в формат LiteRT/TFLite, подготовленный сообществом LiteRT. Модель классифицирует RGB-изображения по 1 000 классам ImageNet-1k; вход имеет фиксированную форму NCHW [1, 3, 224, 224], а предварительная обработка выполняется отдельно от графа. Репозиторий содержит варианты FP32, динамической квантизации весов INT8 с интерфейсом FP32 и статической полностью целочисленной квантизации INT8.

Модели предназначены для классификации изображений на CPU и для развертывания на мобильных NPU после компиляции под целевую SoC и установки соответствующего runtime производителя. На подмножестве из 5 000 изображений ImageNet-1k вариант FP32 показал 75,70% top-1, а статический INT8 — 75,34% на CPU с XNNPACK; результаты NPU зависят от устройства. Статический INT8 требует калибровки, динамический вариант сохраняет интерфейс FP32. GPU/NPU-поведение динамического варианта в описанном исследовании не оценивалось. Лицензия — BSD 3-Clause.

Сценарии применения

  • классификация изображений по классам ImageNet-1k
  • определение объектов и сцен на изображении по меткам ImageNet
  • встраивание классификатора в мобильное приложение с LiteRT
  • запуск классификации на CPU с XNNPACK
  • развертывание целочисленного INT8-классификатора на совместимом мобильном NPU

Ограничения

Вход ограничен RGB-изображениями фиксированного размера 224×224, а предварительную обработку нужно выполнять отдельно. Для NPU требуется компиляция под конкретную SoC и runtime производителя; динамический вариант не оценивался на GPU и NPU.

Публичные бенчмарки

Результаты из открытых лидербордов в сравнении с лидерами каталога

Публичных оценок пока нет

В подключённых источниках результатов этой модели не нашлось. Отсутствие оценки не значит, что модель хуже: её могли просто не проверять.

Источники: Hugging Face Leaderboards, Hugging Face Eval Results, Open LLM v2, MTEB, timm, Open ASR, EvalPlus

Для каких профессий подходит4

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

TorchVision DenseNet121 — LiteRT

LiteRT/TFLite versions of TorchVision's densenet121, using DenseNet121_Weights.IMAGENET1K_V1. The model classifies RGB images into 1,000 ImageNet classes. The input has a fixed NCHW shape of [1, 3, 224, 224]; preprocessing is external to the graph.

The .tflite files are portable source models. NPU deployment requires compilation for the target SoC and a matching vendor dispatch runtime. Device-specific compiled NPU programs are not included.

Files and choosing a variant

FileDescriptionInput / output
densenet121.tfliteFP32 weights and activations; floating-point reference and example default.FP32 / FP32
densenet121_dynamic_wi8_afp32.tfliteDynamic-range quantization with INT8 stored weights and FP32 graph activations. Hybrid kernels may quantize activations internally at runtime.FP32 / FP32
densenet121_int8_channelwise.tfliteStatic A8W8: per-channel INT8 weights, per-tensor INT8 activations and INT32 biases. Fully integer execution.INT8 / INT8
run_image.pyCPU example with TorchVision preprocessing and class labels.—
requirements.txtPackage versions used to check the CPU example.—
validation/Calibration/evaluation image identifiers and machine-readable results. Images are not included.—

All three model files were evaluated on CPU with XNNPACK enabled. The FP32 and static INT8 files were also evaluated with full NPU delegation on the Qualcomm and MediaTek devices below. The dynamic-range model's GPU and NPU behavior was not evaluated in this study.

Use the FP32 model as the reference when checking a new backend. Static INT8 is the integer deployment option; confirm accuracy on representative data and verify delegation on the target device. Dynamic-range quantization keeps the FP32 interface and requires no static activation calibration.

Static INT8 quantization

The static model uses post-training quantization with LiteRT Quantizer's static_wi8_ai8() recipe, without quantization-aware training or fine-tuning:

  • Calibrate the FP32 model on 500 ImageNet-1k validation images, batch size one, using the source TorchVision/PIL preprocessing. The calibration list is disjoint from the evaluation list.
  • Store convolution and fully connected weights as symmetric, per-output-channel INT8 values with zero point zero. Their biases use INT32 with scales derived from the input and weight scales.
  • Use asymmetric, per-tensor INT8 activations. Internal ranges use an exponential moving average with smoothing factor 0.95. Public input and output ranges use the full observed minimum and maximum across calibration images. This mixed range-selection policy is an explicit calibration choice.
  • Retain separately calibrated activation ranges. INT8-to-INT8 requantization aligns scales and zero points where required for concatenation. These nodes do not introduce floating-point computation.

Why the model uses separate activation scales

Sharing activation scales across DenseNet blocks reduces the portable graph's operator count by 49.8% (628 → 315), principally by reducing explicit requantization operators from 317 to 4. We retain separate scales because the large reduction in operator count produced only small, backend-dependent latency gains while imposing a common quantization range on features with different distributions.

In the latest paired NPU measurements, the shared-scale control reduced latency by approximately 3.9% on Samsung/Qualcomm and 2.0% on TECNO/MediaTek. An earlier session on a tested MediaTek NPU showed no meaningful speedup; the effect was small and varied between sessions. Earlier CPU measurements also showed modest latency gains.

The shared-scale control used the same calibration images, INT8 weight quantization and public input/output encodings as the published static model. Its 5,000-image top-1 results were:

BackendSeparate scales, published (%)Shared-scale control (%)
CPU / XNNPACK75.3475.14
Samsung / Qualcomm NPU75.4275.24
TECNO / MediaTek NPU74.9875.18

These small accuracy differences do not establish a universal winner. The default preserves independently calibrated activation ranges; sharing scales remains a target-specific optimization when a larger measured benefit warrants the tradeoff. The shared-scale control is not a published model file. Operator counts above describe the portable graph before vendor compilation, not the number of NPU kernels.

Accuracy evaluation

Results were collected on 5,000 ImageNet-1k validation images using the exact same preprocessed inputs for each backend. The evaluation list identifies the images and their zero-based class labels; filenames use the original ImageNet validation naming convention. This is a fixed subset, not a full 50,000-image evaluation or a class-balanced sample.

The source PyTorch FP32 model scored 75.70% top-1 and 92.62% top-5, with autocast and TF32 disabled. Its top-1 predictions matched the TFLite FP32 model on all 5,000 images. Preprocessing/reference packages were TorchVision 0.29.1, PyTorch 2.14.1 and Pillow 13.0.0.

CPU: XNNPACK enabled, eight threads

Model fileTop-1 (%)Top-5 (%)
densenet121.tflite75.7092.62
densenet121_dynamic_wi8_afp32.tflite75.7292.52
densenet121_int8_channelwise.tflite75.3492.26

The CPU evaluation used LiteRT's native vision evaluator, with single-rounding builtin fallback kernels. It is separate from the phone NPU measurements.

NPU: AOT compiled, fully delegated

Model fileSamsung top-1 (%)Samsung top-5 (%)TECNO top-1 (%)TECNO top-5 (%)
densenet121.tflite75.7492.6075.7092.64
densenet121_int8_channelwise.tflite75.4292.3474.9892.20

Both model variants compiled to one NPU dispatch per device, with no residual LiteRT CPU operators. All 5,000 outputs were finite. FP32 identifies the source model; NPU compilation permits FP16 execution and does not imply FP32 arithmetic throughout the compiled program.

This subset was reused while comparing calibration and scale-sharing policies. It is disjoint from calibration but is not an independent final test set. Small differences should not be interpreted as general improvements over the source checkpoint. Accuracy and numerical behavior can differ across backends.

NPU performance

Warm batch-one inference latency in milliseconds, measured on 2026-11-14:

Model fileSamsung SM-S937U1 / SM8750TECNO LJ9 / MT6897
densenet121.tflite0.74711.178
densenet121_int8_channelwise.tflite0.3377.027

Each value is the median of six process means, with 200 warmup and 1,000 measured invocations per process. Model order alternated through all six permutations of the FP32, separate-scale INT8 and shared-scale INT8 models. Inputs were fixed real-image tensors with persistent buffers. Measurements use LiteRT run_model through adb shell and time synchronous CompiledModel.Run; they exclude initialization, preprocessing, file I/O and explicit host input/output buffer transfers. They are not end-to-end Android application timings.

  • Samsung SM-S937U1: SM8750, Android 17, Qualcomm QAIRT/QNN 2.51.1, burst performance mode. AOT compilation used the public LiteRT 2.3.0 Qualcomm compiler plugin.
  • TECNO LJ9: MT6897, Android 15, MediaTek Neuron 8.2.10 device runtime and 8.2.30 compiled bytecode, sustained-speed mode.
  • Device execution and MediaTek compilation used locally built LiteRT tools. CPU host affinity was 0xf0 on both phones. Binary hashes, per-trial timings and source-model hashes are recorded in validation/results.json.

These measurements describe the listed device/software combinations. Power settings were not normalized between phones, energy consumption was not measured, and the figures are not a controlled comparison of NPU hardware. Results depend on the model, compiler, runtime, OS, thermal state and power settings. These are our measurements, not vendor-endorsed benchmark results.

Input and output

Preprocessing matches the TorchVision weights: convert to RGB, resize the shorter edge to 256 using PIL bilinear interpolation with antialiasing, center crop to 224 × 224, scale pixels to [0, 1], and normalize with mean [0.485, 0.456, 0.406] and standard deviation [0.229, 0.224, 0.225]. Use NCHW input [1, 3, 224, 224]. Output [1, 1000] contains logits in the TorchVision ImageNet class order; softmax is not included.

For the static INT8 file, quantize the normalized input and dequantize output logits using the tensor metadata:

TensorScaleZero point
Input0.01865844801068306-14
Output0.1969466656446457-77

The relationship is real_value = scale * (int8_value - zero_point). The included example reads these parameters from the model.

Run a local image on CPU

Download run_image.py and requirements.txt, then run:

uv venv --python 3.13
source .venv/bin/activate
uv pip install -r requirements.txt

python run_image.py image.jpg
python run_image.py image.jpg --model densenet121_dynamic_wi8_afp32.tflite
python run_image.py image.jpg --model densenet121_int8_channelwise.tflite

The example downloads the selected model if it is not present locally, applies the source preprocessing, and prints the top five classes and logits. It was checked on Linux with XNNPACK enabled for all three files. Use --num-threads to set the CPU thread count; the default is four.

For NPU execution, compile the portable model with the matching LiteRT vendor plugin, load the resulting model with the device dispatch runtime, select NPU acceleration, and inspect delegation. The CPU example does not invoke the NPU.

Source and attribution

The source weights are TorchVision's ImageNet-1k V1 checkpoint, ported from LuaTorch. Refer to the source documentation for training details and the original full-validation metrics; those metrics use a different evaluation set from the subset reported here.

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · litert

Нельзя запустить

Библиотека «litert» рантаймом не поддерживается.

Ревизия весов
ff65deb

0 моделей