Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeDecodeError when running construct_delta_patch.py #9

Open
sv303 opened this issue Dec 31, 2020 · 1 comment
Open

UnicodeDecodeError when running construct_delta_patch.py #9

sv303 opened this issue Dec 31, 2020 · 1 comment

Comments

@sv303
Copy link

sv303 commented Dec 31, 2020

Hello, I run into a UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte error when running scripts/construct_delta_patch.py. Searching online, this looks like Python not opening a file in binary format when it should be. My Python version is 3.7.4 and TensorFlow version is 1.15.0. Is there an older version I should use instead? Thank you.

Full error message:

Traceback (most recent call last):
  File "scripts/construct_delta_patch.py", line 220, in <module>
    compute_and_save_delta_patch()
  File "scripts/construct_delta_patch.py", line 192, in compute_and_save_delta_patch
    'dog-bamboo_forest*'))))
  File "scripts/construct_delta_patch.py", line 39, in load_imgs
    fnames)
  File "/Users/.../opt/anaconda3/lib/python3.7/multiprocessing/pool.py", line 268, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/Users/.../opt/anaconda3/lib/python3.7/multiprocessing/pool.py", line 657, in get
    raise self._value
  File "/Users/.../opt/anaconda3/lib/python3.7/multiprocessing/pool.py", line 121, in worker
    result = (True, func(*args, **kwds))
  File "/Users/.../opt/anaconda3/lib/python3.7/multiprocessing/pool.py", line 44, in mapstar
    return list(map(*args))
  File "scripts/construct_delta_patch.py", line 36, in <lambda>
    Image.open(tf.gfile.GFile(f)).convert('RGB').resize(
  File "/Users/.../opt/anaconda3/lib/python3.7/site-packages/PIL/Image.py", line 2775, in open
    prefix = fp.read(16)
  File "/Users/.../opt/anaconda3/lib/python3.7/site-packages/tensorflow_core/python/lib/io/file_io.py", line 128, in read
    pywrap_tensorflow.ReadFromStream(self._read_buf, length))
  File "/Users/.../opt/anaconda3/lib/python3.7/site-packages/tensorflow_core/python/lib/io/file_io.py", line 98, in _prepare_value
    return compat.as_str_any(val)
  File "/Users/.../opt/anaconda3/lib/python3.7/site-packages/tensorflow_core/python/util/compat.py", line 123, in as_str_any
    return as_str(value)
  File "/Users/.../opt/anaconda3/lib/python3.7/site-packages/tensorflow_core/python/util/compat.py", line 93, in as_text
    return bytes_or_text.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
@Piyushi-0
Copy link

@sv303 As a workaround I modified the function load_imgs to replace the return statement with

return pool.map(
            lambda f: np.array(
                Image.open(f).convert('RGB').resize(
                    shape, Image.BILINEAR)).astype(np.float32) - np.expand_dims(
                        np.expand_dims(_CHANNEL_MEANS, 0), 0).astype(np.float32),
            fnames)

& it seems to work. Please let me know if you found a better way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants