dnuffer / large_neural_style

Neural Style applied to large images
Apache License 2.0
15 stars 0 forks source link

utf-8 codec error #2

Open fsck1 opened 5 years ago

fsck1 commented 5 years ago

Hello . After put this command python3 large_neural_style.py --style /home/fsck/neural/large_neural_style/ir.jpg --content /home/fsck/neural/large_neural_style/1322.jpg --content-weight 90.6e11 --output /home/fsck/neural/large_neural_style/ i get error "large_neural_style.py", line 193, in sys.exit(main()) File "large_neural_style.py", line 129, in main args.print_loss) File "/home/fsck/neural/large_neural_style/stylize.py", line 30, in generate_stylized_image stylize = Stylize(content, True, style, content_weight, style_weight, style_layer_weight_factor, total_variation_weight, print_loss, print_progress=True) File "/home/fsck/neural/large_neural_style/stylize.py", line 92, in init self.net.load_params('vgg19_normalized.pkl') File "/home/fsck/neural/large_neural_style/vgg19.py", line 37, in load_params values = pickle.load(open(weights_filename))['param values'] File "/usr/lib/python3.5/codecs.py", line 321, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte Can you help fix this ?

greycubesgav commented 4 years ago

This seems to be an issue with pickle binaries between Python 2 and Python 3.

See a potential fix here: https://stackoverflow.com/a/41366785, adding 'encoding='latin1' to the pickle.load line referenced above.

From: values = pickle.load(open(weights_filename))['param values'] To: values = pickle.load(open(weights_filename,'rb'),encoding='latin1')['param values']

greycubesgav commented 4 years ago

Relates to: #1

rivermonster commented 4 years ago

After fixing the issues in #1 AND #2 this is working. Thank you for the assistance! Running it on Ubuntu 20.4 (AMD 3700x, 32GB RAM, NVIDA 1080 FTW2 GPU)

(though it seems to only be using CPU--I'll open that issue after I test to make sure, possible I'm missing the environment variable for cuda for theano or something like that). I'm new to this and don't know Python yet, so it's been an uphill battle--but very rewarding. And once I get the GPU rendering instead of the CPU I'll be really geeked up!