Which Khadas SBC do you use?
VIM3 PRO
Which system do you use? Android, Ubuntu, OOWOW or others?
Ubuntu-20.04-gnome
Which version of system do you use? Khadas official images, self built images, or others?
(Khadas official images) vim3-ubuntu-20.04-gnome-linux-4.9-fenix-1.1.2-220930-emmc.img
Please describe your issue below:
To use NPU, keras(MobileNetV3)->onnx->NPU(KSNN) conversion was carried out.
The conversion was successful, but the output is strange when actually using the model.
The ONNX model before conversion is used normally.
I donât know what is the cause.
can you help me?
Post a console log of your issue below:
The terminal command used for conversion:
./convert --model-name o1 --platform onnx --model q10_221018.onnx --input-size-list '244,244,3' --inputs input_1 --mean-values '0 0 0 0.00392156' --quantized-dtype asymmetric_affine --source-files ./data/dataset2/data.txt --kboard VIM3 --print-level 1
ONNX code (python) before conversion:
onnx_model = onnxruntime.InferenceSession("q10_221018.onnx")
frame=cv2.imread("./test/1_1.jpg")
image1 = cv2.resize(frame, (224, 224))
image1 = image1[..., ::-1]
x = np.expand_dims(image1, axis=0).astype(np.float32)
x = x if isinstance(x, list) else [x]
feed = dict([(input.name, x[n]) for n, input in enumerate(onnx_model.get_inputs())])
yhat_ = onnx_model.run(None, feed)
print(yhat_)
--------------output:
[array([[0.04316498, 0.91322935, 0.04360576]], dtype=float32)]
KSNN code (python) after conversion:
mobilenet_v3 = KSNN('VIM3')
mobilenet_v3.nn_init(library="./models/libnn_o1.so", model="./models/o1.nb", level=0)
frame=cv2.imread("./test/1_1.jpg")
image1 = cv2.resize(frame, (224, 224))
image1 = image1[..., ::-1]
x = np.expand_dims(image1, axis=0).astype(np.float32)
yhat_ = mobilenet_v3.nn_inference(x, platform = 'ONNX', reorder='0 1 2', output_format=output_format.OUT_FORMAT_FLOAT32)
print(yhat_)
--------------output:
[array([0.7128906 , 0.06658936, 0.22058105], dtype=float32)]