kpu load model error

Hi,
I am trying to upload a trained model (.tflite) to sipeed maixduino by compiling the model using nncase converter. Converted K-model size is 2.2MB. I am using the following script to check if the model is getting loaded using kpu function:
import sensor
import image
import lcd
import KPU as kpu

lcd.init()
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.run(1)
task = kpu.load(0x200000)
flash-list.json file used :
{
“version”: “0.1.0”,
“files”: [
{
“address”: 0x400000,
“bin”: “peleenet_bright_27.kmodel”,
“sha256Prefix”: false
}
]
}

Error:
raise PyboardError(‘exception’, ret, ret_err)
ampy.pyboard.PyboardError: (‘exception’, b’init i2c2\r\r\n[MAIXPY]: find ov2640\r\n\x1b[0;31mE (6234186457) SYSCALL: Out of memory\r\n\x1b[0m\n’, b’Traceback (most recent call last):\r\n File “”, line 18, in \r\nValueError: \x01\x00\x00\x00\x00\x00\x00\x00\x9f\x8e \x80\x00\x00\x00\x00\xe4\xa0\x00\x80\x00\x00\x00\x006\r\n’)

@zepan

hi,you can use kpu.memtest() to confirm the free memory.
2.2MB kmodel should use minimum version MaixPy to get maximum free memory to run it.
we suggest update to v0.5 MaixPy minimum version

Thank you for your reply. :slightly_smiling_face:
I will check the new firmware and get back to you.

Downloaded the latest firmware from https://www.github.com/sipeed/MaixPy and was able to flash the maixpy_k210_minimum version to the maixduino board. Tried to load the model from sd card and entered the path of the model present inside sd card to kpu.load().
KModel size: 2.2MB
Script used:
import sensor,image,lcd
import KPU as kpu
kpu.memtest()
lcd.init()
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.set_hmirror(0)
sensor.run(1)
task = kpu.load(“classification.kmodel”)

Error:
ampy.pyboard.PyboardError: (‘exception’, b’###free gc heap memory : 490 KB\r\r\n###free sys heap memory: 4660 KB\r\r\ninit i2c2\r\r\n[MAIXPY]: find ov2640\r\n\x1b[0;31mE (317776905368) SYSCALL: Out of memory\r\n\x1b[0m\n’, b’Traceback (most recent call last):\r\n File “”, line 10, in \r\nValueError: [MAIXPY]kpu: load error:6\r\n’)

kpu.memtest()'s return value without loading the model:
###free gc heap memory : 489 KB
###free sys heap memory: 4680 KB

kpu.memtest()'s return value after loading the kmodel:
###free gc heap memory : 490 KB
###free sys heap memory: 4660 KB

@Zepan