iitmcvg / Super-Resolution

Efficient Subpixel based super resolution on different architectures
MIT License
2 stars 3 forks source link

MemoryError on main.py #1

Closed xolott closed 7 years ago

xolott commented 7 years ago

Hi,

After download this repo, and try the example, I get:

python main.py --test_image /home/jose/Desktop/o.jpg 
...
Done Iteration number:  1056
Done Iteration number:  1057
Done Iteration number:  1058
Done Iteration number:  1059
Done Iteration number:  1060
Done Iteration number:  1061
Done Iteration number:  1062
Done Iteration number:  1063
Done Iteration number:  1064
Done Iteration number:  1065
Traceback (most recent call last):
  File "main.py", line 53, in <module>
    tf.app.run()
  File "/media/Documents/Symmetrik/PythonEnviroments/tesnorflow1.0Python3.5/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 44, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "main.py", line 50, in main
    dcgan.variable_size_test(z=img_name,config=FLAGS)
  File "/media/Server/Symmetrik/DesarrolloSymmetrik/Dev/BlackList/imageEnhancer/Super-Resolution/model.py", line 216, in variable_size_test
    save_images([joined_outputs], [1, 1], os.path.join(config.sample_dir, 'joined_outputs.jpg'))
  File "/media/Server/Symmetrik/DesarrolloSymmetrik/Dev/BlackList/imageEnhancer/Super-Resolution/utils.py", line 22, in save_images
    return imsave(inverse_transform(images[:num_im]), size, image_path)
  File "/media/Server/Symmetrik/DesarrolloSymmetrik/Dev/BlackList/imageEnhancer/Super-Resolution/utils.py", line 43, in imsave
    return scipy.misc.imsave(path, merge(images, size))
  File "/media/Documents/Symmetrik/PythonEnviroments/tesnorflow1.0Python3.5/lib/python3.5/site-packages/scipy/misc/pilutil.py", line 197, in imsave
    im = toimage(arr, channel_axis=2)
  File "/media/Documents/Symmetrik/PythonEnviroments/tesnorflow1.0Python3.5/lib/python3.5/site-packages/scipy/misc/pilutil.py", line 343, in toimage
    bytedata = bytescale(data, high=high, low=low, cmin=cmin, cmax=cmax)
  File "/media/Documents/Symmetrik/PythonEnviroments/tesnorflow1.0Python3.5/lib/python3.5/site-packages/scipy/misc/pilutil.py", line 102, in bytescale
    return (bytedata.clip(low, high) + 0.5).astype(uint8)
MemoryError

With full RAM memory usage (32GB), hanging out my PC

rsnk96 commented 7 years ago

Hi

The partial output of the program should be stored in the folder samples. Can you tell if there are 1067 files in the folder?

Also, can you tell what the dimensions of /home/jose/Desktop/o.jpg are? Based on the number of iterations it is taking, I am assuming one of your image dimensions is greater than 1024. This program was built while training and testing on smaller images. One negative of the current version of this program is that it stores the partial outputs in the RAM, which is unnecessary, as they are anyways being stored in the hard disk too, and so can be loaded later for the final processing.

Also

or

If you would like to enhance a general purpose image, I recommend training on a dataset like ImageNet, which contains images containing all sorts of subjects

xolott commented 7 years ago

Hi,

There are 1067 test_ouput images in the samples folder. The dimensions of the o.jpg image are 1920x1080.

I directly run the main.py.

Today I tested your repo with some 160x160's faces, and runned without problem. I'm assuming that the enhanced image is the file sample/joined_output_resized.jpg file

Is there a way to avoid the grey border? I'm currently playing with your code, trying to make some changes and check the behavior. How can I change the dimensions of the generated image file?

Regards,

rsnk96 commented 7 years ago

@xolott I've made a couple of changes:

  1. I've modified the code so that the grey border does not come in. It was coming in in the first place because of the padding that was being done to make each dimension of the image a multiple of 32. If you would like to play around with this part of the code, the parts you would need to modify are primarily the functions make_grid() and join_grid() in utils.py.

  2. I've also stopped loading the downsized and upsampled inputs in the RAM unnecssarily. You could try running the program on your full sized image now. It should be able to do more of the smaller images, but probably still not the entire image. The way to go around completely overcoming the RAM usage problem would be to simply comment out the line output_list.append(output[0]) in model.py, and instead just read the partial outputs written in the samples folder at the end of the program and modify join_grid to work upon them. If you are up for doing that, do send a pull request later :smile:

  3. Previously, the joined_output_resized.jpg image was being forced to the size 128x128x3. I've changed that, and the resized image will now be of the size of the input image

Do pull the repo so that the changes are reflected on your side to

"I directly run the main.py" - I am guessing you meant you ran python main.py --test_image /home/jose/Desktop/o.jpg. If you would like better results, do also try training the model with your own dataset first, which also runs main.py, but with different parameters (See training section in usage)

Also, the final output is not samples/joined_output_resized.jpg, but samples/joined_output_resized_full_resolution.jpg (before today's update, it was simply called samples/joined_output.jpg)

Do note however that when running on bigger images, this program will give good results, but with a rectangular grid artefact. This is the next item in the list of future updates, and you can refer to point 1 in the To-Do section in the readme for more info