kohya-ss / kohya-ss/sd-scripts
Color profiles of are not handled by the scripts
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.2k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
The script treats all images as sRGB even if they have color profiles.
Handling of color profiles needs to be added in image loading.
https://github.com/kohya-ss/sd-scripts/blob/2857f21abf6ed53abe89dd512b3bf25fd2913e03/library/train_util.py#L2490
Something like this:
image = Image.open( path )
icc = image.info.get('icc_profile', '') # Get color profile in the image
if icc:
src_profile = ImageCms.ImageCmsProfile( io.BytesIO(icc) )
srgb_profile = ImageCms.createProfile("sRGB")
image = ImageCms.profileToProfile(image, src_profile, srgb_profile) # Convert image to sRGB
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at library/train_util.py around line 2490, where images are loaded, and inspect how the current loading path handles embedded color profiles. Use the issue's Pillow ImageCms example as the reference; done means profiled images are converted appropriately to sRGB instead of being treated as unprofiled sRGB.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- computer-vision
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100