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

自动生成的标签图片尺寸错误 #1

Open
suhaolun opened this issue Jun 15, 2023 · 2 comments
Open

自动生成的标签图片尺寸错误 #1

suhaolun opened this issue Jun 15, 2023 · 2 comments

Comments

@suhaolun
Copy link

suhaolun commented Jun 15, 2023

自动生成的xml标签文件的size固定为2560 x 1440,而图片的实际尺寸是3392 x 2008

@ZayneYe
Copy link
Owner

ZayneYe commented Jun 16, 2023

可以在data/origin.xml中修改默认size,不修改的话手动调整并保存标签文件后图片尺寸正常

@suhaolun
Copy link
Author

我加入了以下代码,现在可以自适应图片尺寸了
labelImg.py(line:2471)

from PIL import Image
img = Image.open(path)
width, height = img.size
depth = len(img.getbands())
for size in root.iter('size'):
	size.find('width').text = str(width)
	size.find('height').text = str(height)
	size.find('depth').text = str(depth)

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

No branches or pull requests

2 participants