lora-training icon indicating copy to clipboard operation
lora-training copied to clipboard

ensure HEIC support

Open anotherjesse opened this issue 2 years ago • 2 comments

by default PIL / python imaging libraries tend to break on HEIC / iphone photos.

This has caused issues in the dreambooth trainers. Perhaps this can be addressed before we share this publically

anotherjesse avatar Feb 01 '23 14:02 anotherjesse

I assume this can be fixed with pre-processing? Python packages mentioned here https://stackoverflow.com/questions/54395735/how-to-work-with-heic-image-file-types-in-python can be used?

cloneofsimo avatar Feb 03 '23 17:02 cloneofsimo

Here's what I did to pre-process my HEIC images, should be simple enough to implement into whatever you're doing

import os from PIL import Image from pillow_heif import register_heif_opener

images_directory = "/path/to/images" content = os.listdir(images_directory)

register_heif_opener()

for file_name in content: if ".heic" in file_name: image = Image.open(images_directory + "/" + file_name) image.save(f"{images_directory}/{file_name.replace('.heic','.jpeg')}", format="jpeg", quality=90) os.remove(f"{images_directory}/{file_name}")

IcelandicIcecream avatar Mar 12 '23 03:03 IcelandicIcecream