works without ImageCms

This commit is contained in:
JM
2025-09-28 15:10:09 +03:00
parent 1d4c578ac8
commit b9ddf0ce37

View File

@@ -66,7 +66,12 @@ from library import custom_train_functions
from library.original_unet import UNet2DConditionModel
from huggingface_hub import hf_hub_download
import numpy as np
from PIL import Image, ImageCms
import sys
from PIL import Image
try:
from PIL import ImageCms
except:
print( "ImageCms not available. Images will not be converted to sRGB. Colours may be handled incorrectly." )
import imagesize
import cv2
import safetensors.torch
@@ -2494,6 +2499,7 @@ def load_image(image_path, alpha=False):
raise Exception( f"{image_path} is animated" )
# Convert image to sRGB
if "PIL.ImageCms" in sys.modules:
icc = image.info.get('icc_profile', '')
if icc:
try: