Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Tencent Ncnn Calibration Image List

From Leeroopedia


Knowledge Sources
Domains Quantization, Model_Optimization
Last Updated 2026-02-09 00:00 GMT

Overview

Pattern for preparing calibration data files consumed by the ncnn2table calibration tool.

Description

This is a Pattern Doc documenting the calibration dataset preparation format expected by ncnn2table. The tool accepts a text file containing newline-delimited paths to calibration images, or comma-separated list files for multi-input models. Non-image calibration data can be provided as .npy files (NumPy format), parsed by the built-in npy.hpp reader.

Usage

Create an imagelist.txt file listing paths to 100-1000 representative images. For multi-input models, create separate list files and pass them comma-separated. For non-image data, generate .npy files with the correct input tensor shape and dtype.

Code Reference

Source Location

  • Repository: ncnn
  • File: tools/quantize/ncnn2table.cpp
  • Lines: L1661-1674 (show_usage documenting expected formats)
  • Also: tools/quantize/npy.hpp (NumPy file reader for non-image data)

Signature

# Generate image list file
find images/ -type f > imagelist.txt

# For multi-input models (comma-separated lists)
# input1_list.txt,input2_list.txt

Import

# No import needed — this is a file format specification
# The imagelist.txt is consumed by ncnn2table CLI tool

I/O Contract

Inputs

Name Type Required Description
image files JPEG/PNG files Yes Representative calibration images (100-1000)
.npy files NumPy binary No Alternative for non-image model inputs

Outputs

Name Type Description
imagelist.txt Text file Newline-delimited list of image paths for ncnn2table

Usage Examples

Create Image List

# Collect calibration images (subset of validation set)
mkdir calibration_images/
cp val_images/img_{001..500}.jpg calibration_images/

# Generate image list
find calibration_images/ -name "*.jpg" -type f > imagelist.txt

# Verify
wc -l imagelist.txt
# 500 imagelist.txt

Multi-Input Model

# For models with two inputs
find rgb_images/ -type f > input1_list.txt
find depth_images/ -type f > input2_list.txt

# Pass both to ncnn2table
ncnn2table model.param model.bin input1_list.txt,input2_list.txt table.txt ...

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment