错误:无法读取 Google Colab 中的图像

发布于 2025-01-11 11:04:36 字数 1108 浏览 0 评论 0原文

我正在按照本教程在 Detect 上构建定制的对象检测模型。

https:// /www.analyticsvidhya.com/blog/2021/06/simplest-way-to-do-object-detection-on-custom-datasets/

我已收集并标记我的图像,将它们放在我的云端硬盘上,我正在运行以下代码片段来训练模型,该模型是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相思故 2025-01-18 11:04:36

我检查了 Detecto 的 core.Dataset 实现的代码,并确认了我在评论中所说的内容。

通过获取所有 .xml 注释文件并创建将它们映射到其图像的索引来创建索引。它不会检查图像是否确实存在。

对于图像文件名,它使用 xml 文件内部的文件名,而不是 xml 文件的名称。请参阅下面的注释 XML 文件视图,您可以在其中看到 filename 属性。如果更改图像的名称,则需要在 xml 文件中进行更改。

annotation_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 the xml file. See below a view of an annotation XML file, where you see the filename attribute. If you change the name of your image, you need to change it inside the xml file.

annotation_xml

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文