detecto icon indicating copy to clipboard operation
detecto copied to clipboard

Handle or raise XMLs without labels

Open erjiang opened this issue 4 years ago • 1 comments

Describe the feature you'd like

When processing a folder of Pascal VOCs, xml_to_csv should detect when an XML file has no labels and either raise an exception or do something else that doesn't break the CSV.

Otherwise, you have issues like #69 and #51 where the code doesn't break until you fit the model or otherwise iterate through the object.

Describe the use cases of the feature

It will prevent a lot of confusing errors that are very hard to diagnose, since the error thrown is "single positional indexer is out-of-bounds" (which is thrown by iloc(0, 0)!), and no file name is printed to let the user know which file caused this problem.

Additional context

One way of fixing it in xml_to_csv:

        # Each object represents each actual image label
        labels = root.findall('object')
        if not labels:
          print("File '%s' contained no labels" % (xml_file,))
          break
        for member in labels:
            box = member.find('bndbox')
            label = member.find('name').text

erjiang avatar Mar 16 '21 23:03 erjiang

Is the issue resolved? I am still facing the error!

SutirthaChakraborty avatar Feb 13 '23 04:02 SutirthaChakraborty