2017-04-16 82 views
0

此代碼位於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 
+0

修復您的縮進。您在這裏發佈的內容不是有效的Python代碼。 –

回答

0

造成這種情況的主要原因在於有效UTF-8不能包含值爲0xff的字節。我不知道你的代碼的哪一部分試圖讀取UTF-8,但無論它試圖讀取什麼,它都不是UTF-8。

+0

所以我應該怎麼做?謝謝,我的代碼是在網頁https://github.com/affinelayer/pix2pix-tensorflow/tree/master/tools – baozizhao

+0

也許關於此代碼?我該怎麼辦? https://github.com/affinelayer/pix2pix-tensorflow/blob/master/tools/tfimage.py – baozizhao

相關問題