Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Rarvar opened this issue May 10, 2024 · 6 comments
Labels
question Further information is requested

Comments

@Rarvar
Copy link

Rarvar commented May 10, 2024

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

@CVHub520
Copy link
Owner

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

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

@CVHub520 CVHub520 added the question Further information is requested label May 10, 2024
@Rarvar
Copy link
Author

Rarvar commented May 11, 2024

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

@CVHub520 CVHub520 changed the title 打开文件时出错,需要类似字节的对象,而不是“None Type” 确保E:/zhujiaqi/MONO\img\20231220_2_3_2.json是一个有效的标签文件。 File Open Error: Expected Byte-like Object, Got ‘NoneType’ for JSON Label File May 26, 2024
@tigerdhl
Copy link

tigerdhl commented Jun 6, 2024

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
Copy link

tigerdhl commented Jun 6, 2024

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
Copy link
Owner

CVHub520 commented Jun 6, 2024

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
Copy link

tigerdhl commented Jun 7, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants