raccoon_dataset icon indicating copy to clipboard operation
raccoon_dataset copied to clipboard

xml_to_csv.py error index is out of range

Open slashplusdash opened this issue 1 year ago • 1 comments

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 avatar Apr 03 '24 16:04 slashplusdash

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>

slashplusdash avatar Apr 03 '24 16:04 slashplusdash