Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix importing VOC dataset with incorrect filename properties. Fix copying images after export. #122

Draft
wants to merge 5 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pylabel/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def ExportToYoloV5(
if copy_images:
source_image_path = str(
Path(
ds.path_to_annotations,
#ds.path_to_annotations,
df_single_img_annots.iloc[0].img_folder,
df_single_img_annots.iloc[0].img_filename,
)
Expand Down
10 changes: 9 additions & 1 deletion pylabel/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,14 @@ def GetCatId(cat_name):
root = ET.XML(xml_data) # Parse XML
folder = _GetValueOrBlank(root.find("folder"), user_input=path_to_images)
filename = root.find("filename").text
if path_to_images != None:
# find file that has same name without extension in the images folder
for f in os.listdir(path_to_images):
if f.startswith(filename.name[:-4]):
filename = f
break


size = root.find("size")
size_width = size.find("width").text
size_height = size.find("height").text
Expand All @@ -199,7 +207,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 #filename.name
row["img_id"] = img_id
row["img_width"] = size_width
row["img_height"] = size_height
Expand Down