magenta / magenta-demos

Demonstrations of Magenta Models
Apache License 2.0
1.32k stars 419 forks source link

Image Stylization jupyter book doesn't work on Windows #73

Open SidShetye opened 5 years ago

SidShetye commented 5 years ago

Two issues.

1. OS agnostic path delimiting needed

In magenta-demos/jupyter-notebooks/Image_Stylization.ipynb at line 38 os.path.join(example_path, 'evaluation_images/guerrillero_heroico.jpg') should be os.path.join(example_path, 'evaluation_images', 'guerrillero_heroico.jpg')

2. image_utils.load_np_image failure

This is then followed by an error inside image_utils.load_np_image (line 48). Here the call attempts to load the image into a temp file but that temp file is garbage collected / disposed / deleted before the call returns.

~\Anaconda3\envs\tensorflow\lib\site-packages\magenta\models\image_stylization\image_utils.py in load_np_image(image_file)
    389     with values in [0, 1].
    390   """
--> 391   return np.float32(load_np_image_uint8(image_file) / 255.0)
    392 
    393 

~\Anaconda3\envs\tensorflow\lib\site-packages\magenta\models\image_stylization\image_utils.py in load_np_image_uint8(image_file)
    405     f.write(tf.gfile.GFile(image_file, 'rb').read())
    406     f.flush()
--> 407     image = scipy.misc.imread(f.name)
    408     # Workaround for black-and-white images
    409     if image.ndim == 2:

~\Anaconda3\envs\tensorflow\lib\site-packages\numpy\lib\utils.py in newfunc(*args, **kwds)
     99             """`arrayrange` is deprecated, use `arange` instead!"""
    100             warnings.warn(depdoc, DeprecationWarning, stacklevel=2)
--> 101             return func(*args, **kwds)
    102 
    103         newfunc = _set_function_name(newfunc, old_name)

~\Anaconda3\envs\tensorflow\lib\site-packages\scipy\misc\pilutil.py in imread(name, flatten, mode)
    162     """
    163 
--> 164     im = Image.open(name)
    165     return fromimage(im, flatten=flatten, mode=mode)
    166 

~\Anaconda3\envs\tensorflow\lib\site-packages\PIL\Image.py in open(fp, mode)
   2650 
   2651     if filename:
-> 2652         fp = builtins.open(filename, "rb")
   2653         exclusive_fp = True
   2654 

PermissionError: [Errno 13] Permission denied: 'C:\\Users\\lab\\AppData\\Local\\Temp\\tmpkvttffnd'

Note that C:\\Users\\lab\\AppData\\Local\\Temp\\tmpkvttffnd doesn't exist at the time of the error.

romanoss commented 5 years ago

same