face-frontalization icon indicating copy to clipboard operation
face-frontalization copied to clipboard

Memory Error

Open haridatascientist opened this issue 8 years ago • 3 comments

Hi, I run demo.py for a single image. it worked well

When I run more than 300 images in a loop in windows 32bit it shows the following error Traceback (most recent call last):   File "demo.py", line 75, in     demo()   File "demo.py", line 57, in demo     frontal_raw, frontal_sym = frontalize.frontalize(img, proj_matrix, model3D.r ef_U, eyemask)   File "C:\Users\Hubino\Downloads\face-frontalization-master\face-frontalization -master\frontalize.py", line 88, in frontalize     denominator = weights + weight_take_from_org + weight_take_from_sym MemoryError

How to avoid the memory error

Thanks in advance for your valuable help

haridatascientist avatar Apr 26 '16 14:04 haridatascientist

Hi @haridatascientist

As you posted, the line that is throwing the error is:

denominator = weights + weight_take_from_org + weight_take_from_sym

This is a simple Numpy matrix addition which shouldn't be a problem. It seems that you are running out of memory to perform this operation. Are you seeing this error specifically after frontalizing more than 300 images? Are you keeping all those images in memory? I suggest you keep track of your memory usage. One thing you can do is write the image to disk after you frontalize in order to free memory space.

If you want to go further, you can check which Numpy operations are not inplace and optimize the memory usage as they mention here: http://stackoverflow.com/questions/4318615/python-numpy-memoryerror. But I don't think this would solve the problem if you're trying to keep this many images loaded in memory.

Hope it helps!

dougsouza avatar Apr 26 '16 17:04 dougsouza

Hi @dougsouza I tried to run the code but I got an error

image

adilalazzawi avatar Oct 12 '16 02:10 adilalazzawi

Hi @haridatascientist could you send me the instruction that you used to run demo().py I tried to run it but i got some errrors my email is [email protected] could you send me the code that you used and the instructions please???

adilalazzawi avatar Oct 12 '16 02:10 adilalazzawi