CVHub520 / X-AnyLabeling

Effortless data labeling with AI support from Segment Anything and other awesome models.
GNU General Public License v3.0
3.82k stars 442 forks source link

File Open Error: Expected Byte-like Object, Got ‘NoneType’ for JSON Label File #404

Closed Rarvar closed 3 months ago

Rarvar commented 4 months ago

打开文件时出错 需要类似字节的对象,而不是“None Type” 确保E:/zhujiaqi/MONO\img\20231220_2_3_2.json是一个有效的标签文件。 但是这确实是一个有效的标签文件。这是为什么?

1 2
CVHub520 commented 4 months ago

打开文件时出错 需要类似字节的对象,而不是“None Type” 确保E:/zhujiaqi/MONO\img\20231220_2_3_2.json是一个有效的标签文件。 但是这确实是一个有效的标签文件。这是为什么? 1 2

您好,此类情况要么是文件路径索引出错,要么是标注文件存在非法的内容。

Rarvar commented 4 months ago

确实是文件路径索引出错,感谢。┭┮﹏┭┮

tigerdhl commented 3 months ago

I got the same error, but my path of json is right,and can't find any unvalid word in json file image It was working just yesterday

tigerdhl commented 3 months ago

I find that the error appear when I use "shutil.copy" to copy the file to another path and rename the file name.but why this error appear after doing that?

CVHub520 commented 3 months ago

I understand your confusion. In X-AnyLabeling, when importing label files, the tool prioritizes fetching the image file referenced by the imagePath field within the label file. If you change the file name during the copy process, the imagePath in the label file will no longer match the actual file name on disk, leading to the error you're encountering. 😓

To resolve this issue, you have a couple of options:

  1. Update the imagePath in the label file: After copying and renaming the file, you can manually update the imagePath in the label file to reflect the new file name and path.

  2. Use a consistent naming convention: When copying and renaming files, maintain a consistent naming convention so that the imagePath in the label file matches the new file names.

If you're comfortable with scripting, you could also write a small script to automate the process of updating the imagePath in the label files after copying and renaming the images. This can help prevent such errors in the future. 🚀

I hope this explanation helps clarify the situation. If you have any more questions or need further assistance, please feel free to ask!

tigerdhl commented 3 months ago

I understand your confusion. In X-AnyLabeling, when importing label files, the tool prioritizes fetching the image file referenced by the imagePath field within the label file. If you change the file name during the copy process, the imagePath in the label file will no longer match the actual file name on disk, leading to the error you're encountering. 😓

To resolve this issue, you have a couple of options:

  1. Update the imagePath in the label file: After copying and renaming the file, you can manually update the imagePath in the label file to reflect the new file name and path.
  2. Use a consistent naming convention: When copying and renaming files, maintain a consistent naming convention so that the imagePath in the label file matches the new file names.

If you're comfortable with scripting, you could also write a small script to automate the process of updating the imagePath in the label files after copying and renaming the images. This can help prevent such errors in the future. 🚀

I hope this explanation helps clarify the situation. If you have any more questions or need further assistance, please feel free to ask!

thank u