Skip to content

Commit

Permalink
Handle capital letter image extensions (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
frutiemax92 authored Jun 28, 2024
1 parent cefaa95 commit 2b08ce5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion diffusion/data/datasets/InternalData.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

# helper function for replacing image extensions with an another
def replace_img_ext(path, dst_ext: str) -> str:
return path.replace('.png', dst_ext).replace('.jpg', dst_ext).replace('.webp', dst_ext)
return path.replace('.png', dst_ext).replace('.jpg', dst_ext).replace('.webp', dst_ext).replace('.jpeg', dst_ext).\
replace('.JPEG', dst_ext).replace('.JPG', dst_ext)


@DATASETS.register_module()
Expand Down
2 changes: 1 addition & 1 deletion tools/convert_images_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def main():
# check if an image exists for this caption
image_filename = filename[:-len(caption_extension)]

for image_extension in ['.jpg', '.png', '.jpeg', 'webp']:
for image_extension in ['.jpg', '.png', '.jpeg', 'webp', '.JPEG', '.JPG']:
image_path = Path(dirpath).joinpath(image_filename + image_extension)
if path.exists(image_path):
write_entry(json_entries, dirpath, image_path, Path(dirpath).joinpath(filename), image_filename + image_extension, intern_imgs_folder)
Expand Down

0 comments on commit 2b08ce5

Please sign in to comment.