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

xml_to_csv.py error index is out of range #130

Open
slashplusdash opened this issue Apr 3, 2024 · 1 comment
Open

xml_to_csv.py error index is out of range #130

slashplusdash opened this issue Apr 3, 2024 · 1 comment

Comments

@slashplusdash
Copy link

I got a dataset from roboflow and downloaded it in a PASCAL VOC format. I got the image and xml file but I get an error saying index is out of range. I get this error:

Traceback (most recent call last):
  File "/content/create_csv.py", line 36, in <module>
    main()
  File "/content/create_csv.py", line 32, in main
    xml_df = xml_to_csv(image_path)
  File "/content/create_csv.py", line 19, in xml_to_csv
    int(member[4][0].text),
IndexError: child index out of range

Here is an example of an XML file from roboflow that will cause an error.

<annotation>
	<folder></folder>
	<filename>93CZGI8230K5_jpg.rf.376be08df50f4850e6fd70f287a649cc.jpg</filename>
	<path>93CZGI8230K5_jpg.rf.376be08df50f4850e6fd70f287a649cc.jpg</path>
	<source>
		<database>roboflow.com</database>
	</source>
	<size>
		<width>416</width>
		<height>416</height>
		<depth>3</depth>
	</size>
	<segmented>0</segmented>
	<object>
		<name>Bicycle</name>
		<pose>Unspecified</pose>
		<truncated>0</truncated>
		<difficult>0</difficult>
		<occluded>0</occluded>
		<bndbox>
			<xmin>31</xmin>
			<xmax>415</xmax>
			<ymin>92</ymin>
			<ymax>345</ymax>
		</bndbox>
	</object>
</annotation>

Any help on this?

@slashplusdash
Copy link
Author

I tried labeling an image on my own and it won't error. Here is the format

<annotation>
	<folder>images</folder>
	<filename>421698574_934312888326861_559565050525667982_n.jpg</filename>
	<path>(path to image)\images\421698574_934312888326861_559565050525667982_n.jpg</path>
	<source>
		<database>Unknown</database>
	</source>
	<size>
		<width>1536</width>
		<height>2048</height>
		<depth>3</depth>
	</size>
	<segmented>0</segmented>
	<object>
		<name>person</name>
		<pose>Unspecified</pose>
		<truncated>1</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>203</xmin>
			<ymin>988</ymin>
			<xmax>691</xmax>
			<ymax>2048</ymax>
		</bndbox>
	</object>
	<object>
		<name>person</name>
		<pose>Unspecified</pose>
		<truncated>1</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>1114</xmin>
			<ymin>1359</ymin>
			<xmax>1536</xmax>
			<ymax>2020</ymax>
		</bndbox>
	</object>
	<object>
		<name>person</name>
		<pose>Unspecified</pose>
		<truncated>0</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>720</xmin>
			<ymin>1270</ymin>
			<xmax>1103</xmax>
			<ymax>2023</ymax>
		</bndbox>
	</object>
	<object>
		<name>person</name>
		<pose>Unspecified</pose>
		<truncated>1</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>1</xmin>
			<ymin>879</ymin>
			<xmax>247</xmax>
			<ymax>1494</ymax>
		</bndbox>
	</object>
	<object>
		<name>person</name>
		<pose>Unspecified</pose>
		<truncated>0</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>491</xmin>
			<ymin>811</ymin>
			<xmax>647</xmax>
			<ymax>959</ymax>
		</bndbox>
	</object>
	<object>
		<name>person</name>
		<pose>Unspecified</pose>
		<truncated>0</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>697</xmin>
			<ymin>909</ymin>
			<xmax>947</xmax>
			<ymax>1264</ymax>
		</bndbox>
	</object>
	<object>
		<name>person</name>
		<pose>Unspecified</pose>
		<truncated>0</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>941</xmin>
			<ymin>817</ymin>
			<xmax>1159</xmax>
			<ymax>1100</ymax>
		</bndbox>
	</object>
	<object>
		<name>person</name>
		<pose>Unspecified</pose>
		<truncated>0</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>1200</xmin>
			<ymin>879</ymin>
			<xmax>1379</xmax>
			<ymax>1126</ymax>
		</bndbox>
	</object>
	<object>
		<name>person</name>
		<pose>Unspecified</pose>
		<truncated>0</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>1017</xmin>
			<ymin>1076</ymin>
			<xmax>1276</xmax>
			<ymax>1314</ymax>
		</bndbox>
	</object>
	<object>
		<name>person</name>
		<pose>Unspecified</pose>
		<truncated>1</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>1329</xmin>
			<ymin>1153</ymin>
			<xmax>1536</xmax>
			<ymax>1381</ymax>
		</bndbox>
	</object>
	<object>
		<name>person</name>
		<pose>Unspecified</pose>
		<truncated>1</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>1432</xmin>
			<ymin>909</ymin>
			<xmax>1536</xmax>
			<ymax>1108</ymax>
		</bndbox>
	</object>
</annotation>

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

1 participant