running mobilenet on m5stickv
-
hello
I'm trying to run the mobilenet classifier script:
https://github.com/sipeed/MaixPy_scripts/tree/master/machine_vision/mobilenet_1000_classThe tutorial says we should use the minimum firmware:
https://cn.maixpy.sipeed.com/maixpy/en/course/ai/image/1000_type_classifier.htmlSo I compiled a minimum firmware with only support for video and k4. It ended up with 1.2Mb. I also change the gc heap size as the tutorial says. But when I run the script, it says it doesn't have enough memory.
E (2704939464) SYSCALL: Out of memory
The error happens before I feed the images the the kpu, in the line where I define the sensor.framesize
Is it even possible to run this script on the m5stickV?
import lcd, sensor
import KPU as kpudef lcd_init():
lcd.init(type=3)
lcd.register(0x3A, 0x05)
lcd.register(0xB2, [0x05, 0x05, 0x00, 0x33, 0x33])
lcd.register(0xB7, 0x23)
lcd.register(0xBB, 0x22)
lcd.register(0xC0, 0x2C)
lcd.register(0xC2, 0x01)
lcd.register(0xC3, 0x13)
lcd.register(0xC4, 0x20)
lcd.register(0xC6, 0x0F)
lcd.register(0xD0, [0xA4, 0xA1])
lcd.register(0xD6, 0xA1)
lcd.register(0xE0, [0x23, 0x70, 0x06, 0x0C, 0x08, 0x09, 0x27, 0x2E, 0x34, 0x46, 0x37, 0x13, 0x13, 0x25, 0x2A])
lcd.register(0xE1,[0x70, 0x04, 0x08, 0x09, 0x07, 0x03, 0x2C, 0x42, 0x42, 0x38, 0x14, 0x14, 0x27, 0x2C])task = kpu.load(0x300000)
f=open('/flash/labels.txt','r')
labels=f.readlines()
f.close()print ('ok load kpu and labels')
lcd_init()
lcd.rotation(2) #Rotate the lcd 180degsensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
#sensor.set_framesize(sensor.B128X128)
sensor.run(1)
sensor.skip_frames()print ('ok sensor')
while (True):
img = sensor.snapshot()
img.crop(x_size=224, y_size=224)fmap = kpu.forward(task, img)
plist=fmap[:]
pmax=max(plist)
max_index=plist.index(pmax)img = img.draw_string(0, 0, "%.2f: %s" %(pmax, labels[max_index].strip()), color=(255, 0, 0))
#lcd.display(img, oft=(0,0))
print(fps)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login