错误:无法读取 Google Colab 中的图像
我正在按照本教程在 Detect 上构建定制的对象检测模型。
我已收集并标记我的图像,将它们放在我的云端硬盘上,我正在运行以下代码片段来训练模型,该模型是 Google Colab 上 Python Notebook 的一部分:
Train_dataset = core.Dataset('/content/drive/My Drive/training model/Training',transform=custom_transforms)#L1
Test_dataset = core.Dataset('/content/drive/My Drive/training model/Test')#L2
loader=core.DataLoader(Train_dataset, batch_size=2, shuffle=True)#L3
model = core.Model(['black car', 'grey car','white truck'])#L4
losses = model.fit(loader, Test_dataset, epochs=25, lr_step_size=5, learning_rate=0.001, verbose=True)#L5
plt.plot(losses)
plt.show()
但是,在第一个模型纪元开始后不久,我不断收到以下错误:
ValueError: Could not read image /content/drive/My Drive/training model/Training/frame22.jpg
它给出了这个随机错误,不仅与第 22 帧有关,而且与此目录中不存在的其他帧有关。我尝试在脚本开头启用force_remount来重新安装我的驱动器,但错误仍然存在。
I am following this tutorial to build a custom-made object detection model on Detect.
https://www.analyticsvidhya.com/blog/2021/06/simplest-way-to-do-object-detection-on-custom-datasets/
I have collected and labelled my images, put them on my Drive and I am running the following code snippet to train the model which is part of a Python Notebook on Google Colab:
Train_dataset = core.Dataset('/content/drive/My Drive/training model/Training',transform=custom_transforms)#L1
Test_dataset = core.Dataset('/content/drive/My Drive/training model/Test')#L2
loader=core.DataLoader(Train_dataset, batch_size=2, shuffle=True)#L3
model = core.Model(['black car', 'grey car','white truck'])#L4
losses = model.fit(loader, Test_dataset, epochs=25, lr_step_size=5, learning_rate=0.001, verbose=True)#L5
plt.plot(losses)
plt.show()
However, I keep getting the following error shortly after the first model epoch starts :
ValueError: Could not read image /content/drive/My Drive/training model/Training/frame22.jpg
It gives this error randomly, not only with frame22 but with other frames also that are not present in this directory. I tried to remount my Drive with enabling force_remount at the beginning of the script, but the error persists.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我检查了 Detecto 的 core.Dataset 实现的代码,并确认了我在评论中所说的内容。
通过获取所有
.xml
注释文件并创建将它们映射到其图像的索引来创建索引。它不会检查图像是否确实存在。对于图像文件名,它使用
xml
文件内部的文件名,而不是xml
文件的名称。请参阅下面的注释 XML 文件视图,您可以在其中看到filename
属性。如果更改图像的名称,则需要在xml
文件中进行更改。I checked the code of the
core.Dataset
implementation from Detecto and I confirm what I said in my comments.The index is created by getting all the
.xml
annotation files and creating an index that maps them to their image. It does not check that the image is actually there.For the image filename, it uses the one that is inside the
xml
file, not the name of thexml
file. See below a view of an annotation XML file, where you see thefilename
attribute. If you change the name of your image, you need to change it inside thexml
file.