richzhang / colorization-pytorch

PyTorch reimplementation of Interactive Deep Colorization
https://richzhang.github.io/ideepcolor/
MIT License
598 stars 114 forks source link

test.py is not compatible with python 3 #11

Open titsitits opened 5 years ago

titsitits commented 5 years ago

Hi, I am trying to test your model in google colab. I put a dummy image a dummy folder: '/content/colorization-pytorch/dataset/ilsvrc2012/val/MyImages'

I tested these two following commands:

!python test.py --name siggraph_caffemodel --mask_cent 0

!python test.py --name siggraph_retrained

Both led to the same error:

Traceback (most recent call last): File "test.py", line 53, in data_raw[0] = util.crop_mult(data_raw[0], mult=8) File "/content/colorization-pytorch/util/util.py", line 277, in crop_mult return data[:,:,h:h+Hnew,w:w+Wnew] TypeError: slice indices must be integers or None or have an index method

I fixed it by casting indices to integers. Then I got another error in test.py line 57: imgpath = [string.replace('%08d%.3f' % (i, sample_p), '.', 'p')]

string.replace is deprecated in python 2.7, and does not exists in python 3, see here: https://docs.python.org/2.7/library/string.html?highlight=string%20replace#string.replace

However, when I change my google colab execution to python 2, test.py works like a charm.