Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions voc2coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ def get_and_check(root, name, length):
return vars


def get_filename_as_int(filename):
def get_filename(filename):
try:
filename = filename.replace("\\", "/")
filename = os.path.splitext(os.path.basename(filename))[0]
return int(filename)
return str(filename)
except:
raise ValueError("Filename %s is supposed to be an integer." % (filename))
raise ValueError("Filename %s has a problem..." % (filename))


def get_categories(xml_files):
Expand Down Expand Up @@ -84,7 +84,7 @@ def convert(xml_files, json_file):
else:
raise ValueError("%d paths found in %s" % (len(path), xml_file))
## The filename must be a number
image_id = get_filename_as_int(filename)
image_id = get_filename(filename)
size = get_and_check(root, "size", 1)
width = int(get_and_check(size, "width", 1).text)
height = int(get_and_check(size, "height", 1).text)
Expand Down