Skip to content

Commit

Permalink
Merge pull request #118 from pizixie/dev
Browse files Browse the repository at this point in the history
yaml support chinese and handle voc format
  • Loading branch information
alexheat committed Jul 16, 2023
2 parents 9d49260 + 151bca0 commit 83a42a0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pylabel/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,13 @@ def GetCatId(cat_name):
filepath = filename.path
xml_data = open(filepath, "r", encoding=encoding).read() # Read file
root = ET.XML(xml_data) # Parse XML
folder = _GetValueOrBlank(root.find("folder"), user_input=path_to_images)
filename = root.find("filename").text
# ignore "folder" node in xml
#folder = _GetValueOrBlank(root.find("folder"), user_input=path_to_images)
folder = path_to_images if path_to_images else "."
# "filename" node in xml sometimes is invalid
# only get suffix
filename_node = root.find("filename").text
suffix = Path(filename_node).suffix
size = root.find("size")
size_width = size.find("width").text
size_height = size.find("height").text
Expand All @@ -199,7 +204,7 @@ def GetCatId(cat_name):
row = {}
# Build dictionary that will be become the row in the dataframe
row["img_folder"] = folder
row["img_filename"] = filename
row["img_filename"] = filename.name.replace(".xml",suffix)
row["img_id"] = img_id
row["img_width"] = size_width
row["img_height"] = size_height
Expand Down

0 comments on commit 83a42a0

Please sign in to comment.