Error: StackVM stack underflow
narduzzi opened this issue · 2 comments
narduzzi commented
Describe the bug
Hi,
I am trying to perform inference using a MLP Network with 70 inputs.
import sensor, image, time, lcd
from maix import KPU
import gc
lcd.init(freq=15000000)
sensor.reset() # Reset and initialize the sensor. It will
# run automatically, call sensor.run(0) to stop
print("SensorOK")
sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240)
print("FrameSet")
print("Sensor on. Loading kmodel")
kpu = KPU()
kpu.load("/sd/audio_model.kmodel") # network input size is [1,1,1,70]
print("Start run")
try:
while True:
gc.collect()
img = sensor.snapshot()
# to grayscale
img_gray=img.to_grayscale(1) #convert to gray
print("Gray:")
print(img_gray)
# cut at the right size
print("CUT:")
img_mnist2=img_gray.resize(70,1) # As a trial, use 70 pixels from the image.
print(img_mnist2)
a=img_mnist2.pix_to_ai()
print(img_mnist2)
kpu.run(img_mnist2)
print("DONE")
out = kpu.get_outputs()
print(out)
except Exception as e:
print(e)
kpu.deinit()
del kpu
gc.collect()
And it raises the following exception:
error: StackVM stack underflow
Model Buffer maybe dirty!
What could be the source of the problem?
I am attaching the kmodel converted using NNCase [1.9.0.]
Configuration
- IDE version: v2.9.2-2-0-g132467a
- Firmware version: MicroPython v1.0.5-5-ge1b2766 on 2023-05-23; CanMV_Board with kendryte-k210
- Board: Sipeed Maix M1 Dock
- OS: MacOS
model.zip
kendryte747 commented
this error is reported by nncase runtime,please check your model or use pc tool to simulate.
narduzzi commented
The problem was that the network was compiled using nncase 1.8.0 while the firmware was using nncase 1.1.0.
Updating the firmware library to use nncase 1.8.0 and reflashing the chip solved the problem.