【发布时间】:2021-12-05 01:11:06
【问题描述】:
朋友们,美好的一天。
我正在尝试将我自己的文件从我自己的光盘加载到 Google Colab,并使用带有 image.load_img 的代码。但是programm认为没有这样的文件。我看到这个文件,不同意谷歌。 )
您能否建议我如何使代码正常工作。如果我犯了任何错误,请告诉我。当文件在PC上并且文件在Colab文件夹中时,输入路径的正确方法是什么
非常感谢。
代码是:
from tensorflow.keras import utils
from tensorflow.keras.preprocessing import image
import numpy as np
import pandas as pd
import pylab
from google.colab import files
from PIL import Image
path = 'C:\XYZ\pic7.jpg'
x = image.load_img(path, target_size = (800, 600), color_mode = 'grayscale')
Colab 说:
...
FileNotFoundError Traceback (most recent call last)
<ipython-input-43-a3755b9d97b5> in <module>()
9 path = 'C:\XYZ\pic7.jpg'
10
---> 11 x = image.load_img(path, target_size = (800, 600), color_mode = 'grayscale')
1 frames
/usr/local/lib/python3.7/dist-packages/keras_preprocessing/image/utils.py in load_img(path, grayscale, color_mode, target_size, interpolation)
111 raise ImportError('Could not import PIL.Image. '
112 'The use of `load_img` requires PIL.')
--> 113 with open(path, 'rb') as f:
114 img = pil_image.open(io.BytesIO(f.read()))
115 if color_mode == 'grayscale':
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\XYZ\\pic7.jpg'
【问题讨论】:
标签: python image tensorflow google-colaboratory file-not-found