Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MemoryError: Out of Memory! Please reduce the resolution of the image you are running this algorithm on to bypass this issue! #482

Open
adelinawong opened this issue Mar 2, 2023 · 0 comments

Comments

@adelinawong
Copy link

Board: m5stickv

Code:

import sensor
import image
import lcd
import KPU as kpu

lcd.init()
lcd.rotation(2)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing((224, 224))
sensor.set_vflip(0)
sensor.set_hmirror(0)
sensor.run(1)
lcd.clear()
#lcd.draw_string(135, 0, "MobileNetDemo")
f = open('labels.txt', 'r')
labels = f.readlines()
f.close()
#print(labels)
task = kpu.load("/sd/model.kmodel")

#for image capturing
path = "/sd/images/"
ext=".jpg"
cnt=0
img=image.Image()

while(True):
img = sensor.snapshot()
fmap = kpu.forward(task, img)
plist = fmap[:]
pmax = max(plist)
max_index = plist.index(pmax)
#a = lcd.display(img, roi=(0, 0, 135, 135), oft=(0, 0))
a=lcd.display(img)
#lcd.draw_string(135, 100, "%s" % (labels[max_index].strip()))
#lcd.draw_string(135, 119, "%.2f" % (pmax))
if max_index==1:
lcd.draw_string(135,0,"Person",lcd.RED)
cnt+=1
fname=path+str(cnt)+ext
img.save(fname,quality=95)
print("image saved as", fname)
a = kpu.deinit(task)

May I know how to reduce the resolution of the image? I tried using img.resize() but it does not work. Thank you and hope to hear from you soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant