hai-h-nguyen / Yolo2Pascal-annotation-conversion

Convert Yolo Darket to Pascal VOC annotation format and vice versa.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ZeroDivisionError: float division by zero

oliviervd opened this issue · comments

input XML;

<annotation>
	<folder>TRAIN</folder>
	<filename>1451_1-2$8.jpeg</filename>
	<path>/Volumes/Samsung_T5/20201022_RNN_DMG_OS/data/IMG_LBLS/TRAIN/1451_1-2$8.jpeg</path>
	<source>
		<database>Unknown</database>
	</source>
	<size>
		<width>200</width>
		<height>238</height>
		<depth>3</depth>
	</size>
	<segmented>0</segmented>
	<object>
		<name>1451_1-2</name>
		<pose>Unspecified</pose>
		<truncated>1</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>6</xmin>
			<ymin>1</ymin>
			<xmax>175</xmax>
			<ymax>231</ymax>
		</bndbox>
	</object>
</annotation>

stops running with the following error;

Convert 1451_1-2$8.xml
Image path: /volumes/Samsung_T5/IMG_LBLS/train/1451_1-2$8.jpg
Traceback (most recent call last):
  File "voc2yolo.py", line 57, in <module>
    writer.save(targetFile= imgFolderPath + "/" + annotation_no_xml + ".txt")
  File "/Users/oliviervandhuynslager/Documents/DarkNet/darknet/scripts/pascal2yolo/yolo_io.py", line 61, in save
    classIndex, xcen, ycen, w, h = self.BndBox2YoloLine(box, classList)
  File "/Users/oliviervandhuynslager/Documents/DarkNet/darknet/scripts/pascal2yolo/yolo_io.py", line 37, in BndBox2YoloLine
    xcen = float((xmin + xmax)) / 2 / self.imgSize[1]
ZeroDivisionError: float division by zero