Hvass-Labs / TensorFlow-Tutorials

TensorFlow Tutorials with YouTube Videos
MIT License
9.28k stars 4.19k forks source link

Deprecated scipy libraries #110

Closed farrp2011 closed 5 years ago

farrp2011 commented 5 years ago

reinforcement_learning.py

On line 441 the image libraries have been deprecated that resize the image img = scipy.misc.imresize(img, size=state_img_size, interp='bicubic')

My fix it to add this to the imports import cv2 as cv and this to replace that deprecated line with this img = cv.resize(img,None,fy=state_height, fx=state_width, interpolation = cv.INTER_CUBIC)

I'm also having a problem with the shape of the model. I believe the problem steams from line 1302. I'm not experienced with this enough to fix it. Screenshot from 2019-06-08 22-00-11

Hvass-Labs commented 5 years ago

Thanks for reporting this problem.

The doc-page for 'scipy.misc.imresize()' had suggested a replacement but the page is gone now.

It looks like the standard Python library for image manipulation is Pillow, so this function might work:

https://pillow.readthedocs.io/en/3.1.x/reference/Image.html#PIL.Image.Image.resize

It looks like I already used this in another tutorial:

https://github.com/Hvass-Labs/TensorFlow-Tutorials/blob/master/14_DeepDream.ipynb

I don't have time to fix this now, but please let me know if you get it working. You don't have to submit a Pull Request, just copy-paste the code here if you get it working.

Hvass-Labs commented 5 years ago

I have fixed this now.

It takes a surprisingly long time to fix minor problems like this, because a lot of testing has to be done as well. For example, PIL's version of bicubic interpolation is apparently much different from scipy's, so it didn't work very well and I had to use linear interpolation instead.

farrp2011 commented 5 years ago

Wow your awesome!