ProGamerGov / neural-style-pt

PyTorch implementation of neural style transfer algorithm
MIT License
833 stars 178 forks source link

2nd file not found when using a list of 2 style images #76

Closed jerome8811 closed 3 years ago

jerome8811 commented 4 years ago

First of all, congratulation for you nice job !

I always have an error "file not found" on the 2nd file of the list, when using a list of 2 style images:

python -u ./neural_style.py -content_image "/c/Users/A455435/w/m/content/IN.jpg" -style_image "/c/Users/A455435/w/m/style/mix/A.jpg,/c/Users/A455435/w/m/style/mix/B.jpg" -style_blend_weights 5,5 -output_image "/c/Users/A455435/w/m/output/IN(Albena_04XX)px100,cw5e0,sw2e2,ss0.8,oc0,it2,i.jpg" -print_iter 1 -save_iter 0 -image_size 100 -num_iterations 2 -content_weight 5e0 -style_weight 2e2 -style_scale 0.8 -original_colors 0 -init image -seed 7 -gpu c VGG-19 Architecture Detected Successfully loaded models/vgg19-d01eb7cb.pth conv1_1: 64 3 3 3 conv1_2: 64 64 3 3 conv2_1: 128 64 3 3 conv2_2: 128 128 3 3 conv3_1: 256 128 3 3 conv3_2: 256 256 3 3 conv3_3: 256 256 3 3 conv3_4: 256 256 3 3 conv4_1: 512 256 3 3 conv4_2: 512 512 3 3 conv4_3: 512 512 3 3 conv4_4: 512 512 3 3 conv5_1: 512 512 3 3 conv5_2: 512 512 3 3 conv5_3: 512 512 3 3 conv5_4: 512 512 3 3 Traceback (most recent call last): File "./neural_style.py", line 468, in main() File "./neural_style.py", line 75, in main img_caffe = preprocess(image, style_size).type(dtype) File "./neural_style.py", line 336, in preprocess image = Image.open(image_name).convert('RGB') File "C:UsersA455435AppDataLocalProgramsPythonPython37libsite-packagesPILImage.py", line 2843, in open fp = builtins.open(filename, "rb") FileNotFoundError: [Errno 2] No such file or directory: '/c/Users/A455435/w/m/style/mix/B.jpg'

While the file exists: $ ls /c/Users/A455435/w/m/style/mix/B.jpg /c/Users/A455435/w/m/style/mix/B.jpg

Any idea of what could be the reason ?

Regards Jerome

ProGamerGov commented 3 years ago

@jerome8811 It looks like it's mistaking your absolute path for a relative one.

jerome8811 commented 3 years ago

@jerome8811 It looks like it's mistaking your absolute path for a relative one.

Curiously, the problem is only on windows, it doesn't happens on linux.

ProGamerGov commented 3 years ago

Have you tried using C:\ instead of c/? This issue makes it seem like it should work, as the parameter is just a list of strings:

https://stackoverflow.com/questions/2953834/windows-path-in-python

jerome8811 commented 3 years ago

Hello ! The file name and path are listed and handled by a bash script that also automatically generate the command to launch neural_style.py On windows, I use the bach interpreter msysgit. The windows path is converted by the interpreter to suit windows/python. It works well in most cases, exept in this very particular case of the list of 2 style images. Yes, it should be a problem when separating the items of the list in neural_style.py ? Because the problem is only on the second file of the list... (unfortunately I don't know the python language, to try a change in python code) But according to your advice, I will try to change the "/c/..." by a "C:/..." automatically when running the script on windows, to see if it works better :-)

jerome8811 commented 3 years ago

This solution works well :-)