Code Lab
OpenVINO Explained: From an Image Array to Model Inference
CODE LAB · PROJECT SPOTLIGHT
OpenVINO Python · Apache-2.0
Where an image becomes a model input.
Project preview · openvinotoolkit/openvino
An image can have the correct width and height and still produce a surprising classification. Its channels may sit on the wrong axis, or its pixel values may have the wrong type. OpenVINO’s Python classification sample makes these assumptions visible before the model is compiled for a device.
On November 24, 2026, GitHub Trending showed 183 stars gained today. GitHub Trending
Where an image becomes a model input

The project’s preprocessing illustration follows image data toward a model. Each boundary raises a question about the array that crosses it, including where its channel dimension sits and which numeric type the pixels use.
Inside hello_classification.py
The sample declares the shape from the actual input tensor. It marks that tensor as unsigned eight-bit data and specifies NHWC, which puts channels last. It then asks the preprocessing pipeline for a linear resize. A few lines later the sample declares the model side as NCHW and builds the preprocessing graph before compiling it. Input layout and model layout describe different ends of the same path.
Source credit · openvinotoolkit/openvino contributors. Apache-2.0 license and notices.
Debug a plausible but incorrect result
Write down the shape of one image before and after adding its batch dimension. An image with shape (480, 640, 3) becomes (1, 480, 640, 3). Passing that array to code that treats the second axis as channels changes its meaning. Also verify channel order and any normalization expected by your model. A layout conversion alone cannot resolve RGB versus BGR.
Start with the linked single-input, single-output sample and a compatible classification model. Compare the top predicted labels for one known image before timing anything. When comparing devices, record compilation time separately from repeated inference. The sample describes a processing path. Performance on your hardware needs a measurement.
Prepare the image used in the official classifier demo

The classification sample above delegates resizing to its preprocessing graph. Intel’s Hello World notebook takes another concrete route for its MobileNet example: it prepares an RGB array before inference. To reproduce that input step, save the notebook’s original coco.jpg in the working directory and run this snippet with OpenCV and NumPy installed. Apply resizing in one place when adapting either example.
Python · worked example
import cv2
import numpy as np
image = cv2.imread("coco.jpg")
if image is None:
raise FileNotFoundError("coco.jpg")
rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
batch = np.expand_dims(cv2.resize(rgb, (224, 224)), axis=0)
print("Source:", image.shape)
print("Batch:", batch.shape, batch.dtype)
print("BGR:", image[0, 0].tolist(), "RGB:", rgb[0, 0].tolist())Output from our run
Source: (577, 800, 3) Batch: (1, 224, 224, 3) uint8 BGR: [105, 89, 82] RGB: [82, 89, 105]
The first dimension of the final array is the batch size. The two 224s are the new spatial dimensions, and the final 3 counts the color channels. Look at the sampled pixel: converting from BGR to RGB swaps the outer values while the green value stays at 89. A shape check alone would miss that difference. We ran these input checks on the linked JPEG. The label in the screenshot comes from the published notebook, which also runs the compiled model and maps the highest-scoring output to a class name.
