openvinotoolkit / openvinotoolkit/nncf

Quantization hangs, even for 100 imges

Open
#3,584 3 comments 0 reactions 1 assignee View on GitHub

@andrey-churkin is already working on this.

Since Jul 16, 2025.

Dominant language
Python
Stars
1.2k
Forks
305
Avg merge
1d 9h
Merged PRs (30d)
27

Description

Hardware:
GPU: Intel(R) UHD Graphics 620
Processor: Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz, 1800 Mhz, 4 Core(s), 8 Logical Processor(s)
OS:
Windows 10
Software:
Python 3.10.0
nncf 2.17.0
openvino 2025.2.0

I am trying to quantize codeformer, a float32, opset 13, onnx model to INT8 format for performance gain.
Model Inputs:
Name: x, Shape: [0, 3, 512, 512], Data Type: FLOAT
Name: w, Shape: [], Data Type: DOUBLE

A collection of 200 images (512x512) has been created. Here is the script

import numpy as np
from PIL import Image
import os
import nncf
from nncf import Dataset
import onnx

# Load your ONNX model
onnx_model = onnx.load("codeformer_opset13.onnx")

def preload_calibration_dataset(images_dir):
    data = []
    for filename in os.listdir(images_dir):
        if filename.lower().endswith((".png", ".jpg", ".jpeg")):
            img_path = os.path.join(images_dir, filename)
            img = Image.open(img_path).convert("RGB").resize((512, 512))
            img_np = np.array(img).astype(np.float32) / 255.0
            img_np = img_np.transpose(2, 0, 1)
            img_np = np.expand_dims(img_np, axis=0)
            data.append({
                "x": img_np,
                "w": np.array(1.0, dtype=np.float64)
            })
    print(f"Loaded {len(data)} images for calibration.")
    return data

# Wrap with nncf.Dataset
dataset = Dataset(preload_calibration_dataset("faces/class1"))

# Run quantization
quantized_model = nncf.quantize(onnx_model, dataset)

# Save the quantized ONNX model
onnx.save(quantized_model, "codeformer_int8.onnx")

The process starts and immediately hangs my laptop as soon as statistical collection starts processing the first image . Here is the captured image:

Image

I am getting my hands on NNCF for the very first time. Am I missing something here or it's just the hardware limitation causing the issue?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.