Skip to content

Commit

Permalink
feat(io_interfaces): add file extension to index_list
Browse files Browse the repository at this point in the history
  • Loading branch information
SherlockMones committed Jun 30, 2022
1 parent af38259 commit 87ae17a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions aucmedi/data_processing/io_interfaces/io_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,10 @@ def csv_loader(path_data, path_imagedir, allowed_image_formats,
if len(index_list) != len(class_ohe):
raise Exception("Numbers of samples and annotations do not match!",
len(index_list), len(class_ohe))

# If the list of samples does not contain the file extension, we add them manually
if not str(index_list[0]).endswith('.{}'.format(image_format)):
index_list = ['{}.{}'.format(file_name, image_format) for file_name in index_list]

# Return parsed CSV data
return index_list, class_ohe, class_n, class_names, image_format
5 changes: 5 additions & 0 deletions aucmedi/data_processing/io_interfaces/io_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,10 @@ def directory_loader(path_imagedir, allowed_image_formats, training=True):
# Raise Exception if image format is unknown
if image_format is None:
raise Exception("Unknown image format.", path_imagedir)

# If the list of samples does not contain the file extension, we add them manually
if not str(index_list[0]).endswith('.{}'.format(image_format)):
index_list = ['{}.{}'.format(file_name, image_format) for file_name in index_list]

# Return parsing
return index_list, None, None, None, image_format
4 changes: 4 additions & 0 deletions aucmedi/data_processing/io_interfaces/io_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,9 @@ def json_loader(path_data, path_imagedir, allowed_image_formats, training=True,
raise Exception("Numbers of samples and annotations do not match!",
len(index_list), len(class_ohe))

# If the list of samples does not contain the file extension, we add them manually
if not str(index_list[0]).endswith('.{}'.format(image_format)):
index_list = ['{}.{}'.format(file_name, image_format) for file_name in index_list]

# Return parsed JSON data
return index_list, class_ohe, class_n, class_names, image_format

0 comments on commit 87ae17a

Please sign in to comment.