在keras2.1.5下TypeError: unsupported operand type(s) for /=: 'JpegImageFile' and 'float'怎麼解決

在fine-tune incepetion_V3模型時會報如上錯誤

from keras.preprocessing.image import img_to_array, array_to_img

from keras.applications.inception_v3  import InceptionV3, preprocess_input


train_datagen =  ImageDataGenerator(

  preprocessing_function=preprocess_input_new,
  rotation_range=30,
  width_shift_range=0.2,
  height_shift_range=0.2,
  shear_range=0.2,
  zoom_range=0.2,
  horizontal_flip=True

)

常見的圖像生成器中preprocessing_function改成如下函數

def preprocess_input_new(x):
    img = preprocess_input(img_to_array(x))
    return array_to_img(img)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章