edenton / svg

186 stars 56 forks source link

Make some fixes for PyTorch 1.0 #6

Open terrybroad opened 5 years ago

terrybroad commented 5 years ago

I made some small fixes for PyTorch 1.0.

transforms.Scale has been deprecated and transforms.Resize should not be used.

And I was getting this bug:

Traceback (most recent call last):
  File "train_svg_lp.py", line 367, in <module>
    plot(x, epoch)
  File "train_svg_lp.py", line 251, in plot
    utils.save_tensors_image(fname, to_plot)
  File "/home/terence/repos/my_code/svg/utils.py", line 187, in save_tensors_image
    return save_image(filename, images)
  File "/home/terence/repos/my_code/svg/utils.py", line 182, in save_image
    img = make_image(tensor)
  File "/home/terence/repos/my_code/svg/utils.py", line 153, in make_image
    channel_axis=0)
  File "/home/terence/.local/lib/python3.6/site-packages/numpy/lib/utils.py", line 101, in newfu$
    return func(*args, **kwds)
  File "/home/terence/.local/lib/python3.6/site-packages/scipy/misc/pilutil.py", line 381, in to$
    bytedata = bytescale(data, high=high, low=low, cmin=cmin, cmax=cmax)
  File "/home/terence/.local/lib/python3.6/site-packages/numpy/lib/utils.py", line 101, in newfu$
    return func(*args, **kwds)
  File "/home/terence/.local/lib/python3.6/site-packages/scipy/misc/pilutil.py", line 105, in by$
    return (bytedata.clip(low, high) + 0.5).astype(uint8)
AttributeError: 'Tensor' object has no attribute 'astype'

When images were trying to be saved so I had to call detach() on the tensor before converting it to a numpy array.