此代碼位於https://github.com/affinelayer/pix2pix-tensorflow/tree/master/tools;pix2pix tensorflow:UnicodeDecodeError:'utf-8'編解碼器無法解碼位置0中的字節0xff:無效起始字節
當我在終端運行:
python3 tools/process.py --input_dir mytest --operation resize --output_dir photos/resized,
我遇到這樣的問題:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
下面的代碼:
def resize(src):
height, width, _ = src.shape
dst = src
if height != width:
if a.pad:
size = max(height, width)
# pad to correct ratio
oh = (size - height) // 2
ow = (size - width) // 2
dst = im.pad(image=dst, offset_height=oh, offset_width=ow, target_height=size, target_width=size)
else:
# crop to correct ratio
size = min(height, width)
oh = (height - size) // 2
ow = (width - size) // 2
dst = im.crop(image=dst, offset_height=oh, offset_width=ow, target_height=size, target_width=size)
assert(dst.shape[0] == dst.shape[1])
size, _, _ = dst.shape
if size > a.size:
dst = im.downscale(images=dst, size=[a.size, a.size])
elif size < a.size:
dst = im.upscale(images=dst, size=[a.size, a.size])
return dst
修復您的縮進。您在這裏發佈的內容不是有效的Python代碼。 –