0

i am new to python, trying to parse a csv. Made some bounding boxes for MNIST. Now i want to convert the csv to xmls to train a yolo detector.

But i came along a pretty strange thing: (python keywords^^)

These are my rows, got thousends of them, 10 to one image:

filename    mnist_images_300_300_bigger_all/mnist_1.jpg
width                                               300
height                                              300
class                                                 7
xmin                                                  0
ymin                                                  0
xmax                                                 42
ymax                                                 42
Name: 0, dtype: object
Path were to write xml:  Bilder_LabelXML/mnist_images_300_300_bigger_all/mnist_1.xml
Path were image from:    mnist_images_300_300_bigger_all/mnist_1.jpg

If i want to access them now, i wrote in my script:

for index, row in group.object.iterrows():
    print(row.class)

Which gave me that error:

File "annotations_CSV_to_XML.py", line 81
    ET.SubElement(size, "name").text = row.class
                                           ^
SyntaxError: invalid syntax

If i access ymax, everything is fine:

for index, row in group.object.iterrows():
    print(row.ymin)

How can i delimit or mask the keyword "class", that python understands it and does not thing i want to create a new class?

Thanks in advance..

AldegarRızvan
  • 188
  • 4
  • 12

0 Answers0