Create the FVP output

The FVP runner accepts a preprocessed input tensor rather than a JPEG image. On the Linux host, convert the sample image into the normalized MobileNetV2 tensor expected by the model:

    

        
        
python module-4-ethos-npu-accelerated-inference/scripts/fvp/create_mobilenetv2_input.py \
  --spec module-4-ethos-npu-accelerated-inference/artifacts/mobilenetv2/model_spec.json \
  --image module-4-ethos-npu-accelerated-inference/artifacts/mobilenetv2/sample.jpg \
  --out module-4-ethos-npu-accelerated-inference/artifacts/fvp_runs/mobilenetv2_int8/i0.bin

    

The script reads the resize, crop, mean, and standard-deviation values from model_spec.json, applies the same preprocessing used during validation, and adds the batch dimension:

    

        
        
transform = transforms.Compose(
    [
        transforms.Resize(prep["resize"]),
        transforms.CenterCrop(prep["center_crop"]),
        transforms.ToTensor(),
        transforms.Normalize(mean=prep["mean"], std=prep["std"]),
    ]
)
tensor = transform(image).unsqueeze(0)

    

It then writes the contiguous tensor as raw float32 values, without a file header, so the runner can read the bytes directly:

    

        
        
tensor.contiguous().numpy().astype("float32").tofile(args.out)

    

The resulting [1, 3, 224, 224] tensor occupies 602,112 bytes. The companion JSON file records the source image, shape, data type, and byte count. It is for host-side reference and is not read by the FVP runner.

Previous page Complete and continue