Both imread and imsave are not available on current version of scipy:
AttributeError: module 'scipy.misc' has no attribute 'imread'
Need to change
import scipy.misc as misc
to
and update the function calls to use imageio.imread and imageio.imsave
Will also need python-imageio to be installed