Skip to content

Add support for JPEG-XL (file extension: jxl) #1413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 115 commits into from
Apr 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
4ccc66f
Add support for JPEG-XL (file extension: jxl)
StableLlama Apr 17, 2025
a4f3417
add HiDream support
Apr 9, 2025
50c3528
better import protection for hidream
Apr 9, 2025
17785d0
fix hidream default path
Apr 9, 2025
8ace6aa
gets closer to loading a full pipeline properly
Apr 9, 2025
115a766
extend text encoder quant to include number 4
Apr 10, 2025
c7b7110
load pipeline using custom tokenisers too
Apr 10, 2025
4f0d5b1
loading and embed generation fixes
Apr 10, 2025
7404830
fix typo to 128 tokens
Apr 10, 2025
7a9721c
allow quant for text encoder 4
Apr 10, 2025
48fbc47
update torchao, transformers, hf hub
Apr 10, 2025
f3e6be4
reformat
Apr 10, 2025
48e2971
add helpers for moving model components around and smarter pipeline r…
Apr 10, 2025
2f76d0b
use text2img pipeline for encoding prompts
Apr 10, 2025
7650ebd
use text2img for encode prompt with hidream
Apr 10, 2025
888e990
format unipc schedule
Apr 10, 2025
19bd8f4
remove flash_attn fallback code for test
Apr 10, 2025
364eae5
reformat
Apr 10, 2025
199ff9d
follow new method for retrieving pipeline
Apr 10, 2025
7cb2aae
update HiDream transformer for newer diffusers gradient checkpointing
Apr 10, 2025
ef4c1ec
use helper method to print embed shapes for convenience
Apr 11, 2025
28bc629
update base image model class to have a prompt embed collator hook
Apr 11, 2025
8e78e97
update hidream model class for better t5 vs llama embed handling, cla…
Apr 11, 2025
ce151d4
update hidream transformer class to properly handle 32 layer bulk inputs
Apr 11, 2025
1d9c175
add handling for model collator hook in prompt embeds
Apr 11, 2025
b06c97b
add helper methods for retrieving embed shapes or moving them
Apr 11, 2025
4d9b145
reorganise hidream transformer class for clarity, move closer to the …
Apr 11, 2025
caa71cc
fix unpatchify, disable it for training
Apr 11, 2025
4e1044b
update pipeline conversion
Apr 11, 2025
9f14917
update pipeline signatures for split embeds
Apr 11, 2025
548b7d9
move embeds to GPU when reformatting inputs
Apr 11, 2025
d781baa
reduce gradient tracking in MoEGate
Apr 12, 2025
af8494b
MoEGate might benefit from gradient checkpointing instead
Apr 12, 2025
3eef92f
Rename HiDreamAttention to Attention, for lycoris config convenience
Apr 12, 2025
52bc09a
FeedForwardSwiGLU -> FeedForward for lycoris config convenience
Apr 12, 2025
8c6fe92
Fix for Attention block rename
Apr 12, 2025
ecf0cca
Revert "FeedForwardSwiGLU -> FeedForward for lycoris config convenience"
Apr 12, 2025
cfd00d0
offload embeds to CPU while formatting
Apr 12, 2025
93b6638
Fix a bug where text encoder will not quantise when the base model is…
Apr 12, 2025
fba14a0
allow HiDream and other validations to fail and not choke on missing …
Apr 12, 2025
2320c46
HiDream validations meta tensor error fix
Apr 12, 2025
35d89b6
use unsloth ungated llama repo in alignment with diffusers example
Apr 12, 2025
e199a7a
use common fork of llama with correct configs since unsloth has wrong…
Apr 12, 2025
980c39d
silence transformers behavioural change warning
Apr 12, 2025
6ddbfbf
add load balancing loss options for hidream MoEGate
Apr 12, 2025
8dcfec0
add auxiliary loss hook for models and a fix for pipeline not having …
Apr 12, 2025
1879dee
add auxiliary loss handler for hidream
Apr 12, 2025
762d909
pipeline fix for vae latent device location/dtype
Apr 12, 2025
1d956ee
hidream should pass aux loss init alpha value along through the modules
Apr 12, 2025
7873ffb
gather and log auxiliary loss values from a model during training
Apr 12, 2025
08d40df
style
Apr 12, 2025
be4564b
update hidream docs with latest info
Apr 12, 2025
d176563
add hidream to readme
Apr 12, 2025
b9cf91c
resolve error with non-square inputs
Apr 12, 2025
789abd3
fix bug with pixart sigma pipeline typo
Apr 12, 2025
4c0c71a
fix differential parent-student loss
Apr 12, 2025
a99d06c
better error logging when debugging
Apr 12, 2025
45180d0
HiDream SDPA support, no more flash_attn required
Apr 12, 2025
1a07d1c
fix publishing of models to the hub
Apr 12, 2025
ea6e9f5
default to hidream-full model instead of dev
Apr 12, 2025
97e0c7a
tests go brr
Apr 12, 2025
f89fa09
fix feedforward training
Apr 12, 2025
939bff3
update hidream doc
Apr 12, 2025
4fff3aa
update tail
Apr 12, 2025
d76b257
hidream configure script enablement
Apr 12, 2025
da9f6bd
Fix HiDream training for train_batch_size > 1.
mhirki Apr 13, 2025
be6d3bb
Fix parent-student training broken by v2 refactor.
mhirki Apr 14, 2025
a72a017
disable fp16 just in case
Apr 13, 2025
4f96787
add auraflow to configure script
Apr 13, 2025
fd0fb58
add auraflow to all models list
Apr 13, 2025
b8ad6e5
fix single text encoder model loading
Apr 13, 2025
ec4cbc0
fix errors and update sd3 model code for consistency
Apr 13, 2025
e7f02a1
add auraflow support
Apr 13, 2025
2ead70f
update docs
Apr 13, 2025
bfd243e
fixes for ckpt-only validations when EMA is enabled, and, token lengt…
Apr 13, 2025
dae88f0
fix for multigpu training
Apr 14, 2025
bde09d9
integrate PE torch compile fix from AstraliteHeart
Apr 14, 2025
0153473
enable regularisation loss training on PEFT Standard LoRA
Apr 14, 2025
edf6b82
model class should always unwrap it for DDP
Apr 14, 2025
aa9fb41
add missing seq len
Apr 15, 2025
fc357c9
(#1393) enable flux_lora_target for v2 lora loading code in flux
Apr 15, 2025
292e6f6
when init controlnet datasets, sync their sizes to the base dataset. …
Apr 15, 2025
b5b168d
formatting
Apr 15, 2025
c9994d1
fixes for init and retrieval of controlnet vs base model
Apr 15, 2025
1cc4075
formatting
Apr 15, 2025
7053d51
controlnet revival for SD1x
Apr 15, 2025
8a8c9ac
formatting
Apr 15, 2025
9e795cf
add state tracker method for retrieving conditioning dataset mapping …
Apr 15, 2025
ae2626d
controlnet trainer fixes for loading controlnet model by abstraction …
Apr 15, 2025
4267cf9
fix controlnet validation image gathering resizing everything to 64px
Apr 15, 2025
a4e11dc
comment out temp code
Apr 15, 2025
63d4026
make sdxl controlnet training work again
Apr 15, 2025
b93234e
split_buckets_between_processes: Fix issue with imbalanced steps betw…
clayne Apr 14, 2025
a82c5aa
HiDream: fix pipeline load so that it uses cached value, unlike other…
Apr 15, 2025
05057b7
fix sana gradient checkpointing code for intervals
Apr 15, 2025
fb3bcda
remove diffusers utils logspam
Apr 15, 2025
f24717a
fix OOM for vae caching on ltxvideo and wan video on 24g cards
Apr 15, 2025
8b9a239
ltxvideo tokeniser shoudl use AutoTokenizer to avoid class mismatches
Apr 15, 2025
ce671f2
wan: fix print of model name at startup
Apr 15, 2025
5b42edb
wandb: for now, only log first video frame. also add more helpful bac…
Apr 15, 2025
7bfb1e8
apple: update diffusers
Apr 15, 2025
6c1d23a
Added check for UniPCMultistepScheduler
ShuyUSTC Apr 17, 2025
3b8a3a4
Fix publishing model card for None caption dropout amount
Apr 17, 2025
6ecf5fd
fix setting default seq len for sd3
Apr 17, 2025
5ae6243
update diffusers to latest git main
Apr 17, 2025
81260e9
Rename FeedForwardSwiGLU back to FeedForward for convenience.
mhirki Apr 17, 2025
25d9876
Add support for JPEG-XL (file extension: jxl)
StableLlama Apr 17, 2025
8262a42
Fix poetry.lock
StableLlama Apr 17, 2025
7f2e580
Add support for JPEG-XL (file extension: jxl)
StableLlama Apr 17, 2025
0be26ce
Add support for JPEG-XL (file extension: jxl)
StableLlama Apr 17, 2025
b2d16e0
Fix poetry.lock
StableLlama Apr 17, 2025
7ac42a4
Merge remote-tracking branch 'origin/jpeg_xl' into jpeg_xl
StableLlama Apr 17, 2025
c31c2c8
Fix poetry.lock
StableLlama Apr 17, 2025
c6d3fb9
Handle CV2 code paths as well and fall back to PIL when CV2 doesn't u…
StableLlama Apr 17, 2025
e30ee6f
Make `pillow-jxl-plugin` and thus JPEG XL optional.
StableLlama Apr 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ poetry install
poetry install -C install/rocm
```

**Note:** When you want to use JPEG XL images, you have to install the optional `jxl` dependency by running `poetry install --with jxl`.

#### NVIDIA Hopper / Blackwell follow-up steps

Optionally, Hopper (or newer) equipment can make use of FlashAttention3 for improved inference and training performance when making use of `torch.compile`
Expand Down
4 changes: 4 additions & 0 deletions helpers/image_manipulation/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

from io import BytesIO
from typing import Union, IO, Any
try:
import pillow_jxl
except ModuleNotFoundError:
pass
from PIL import Image, PngImagePlugin

logger = logging.getLogger(__name__)
Expand Down
4 changes: 4 additions & 0 deletions helpers/image_manipulation/training_sample.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
try:
import pillow_jxl
except ModuleNotFoundError:
pass
from PIL import Image
from PIL.ImageOps import exif_transpose
from helpers.multiaspect.image import MultiaspectImage, resize_helpers
Expand Down
4 changes: 4 additions & 0 deletions helpers/models/sdxl/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
# limitations under the License.

import inspect
try:
import pillow_jxl
except ModuleNotFoundError:
pass
import PIL
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
from diffusers.callbacks import PipelineCallback, MultiPipelineCallbacks
Expand Down
24 changes: 10 additions & 14 deletions helpers/training/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,18 @@
# Hopper! Or blackwell+.
quantised_precision_levels.append("fp8-torchao")

try:
import pillow_jxl
except ModuleNotFoundError:
pass
from PIL import Image

supported_extensions = Image.registered_extensions()
image_file_extensions = set(
[
"jpg",
"jpeg",
"png",
"webp",
"bmp",
"tiff",
"tif",
"mp4",
"avi",
"gif",
"mov",
"webm",
]
ext.lower().lstrip(".") for ext, img_format in supported_extensions.items()
if img_format in Image.OPEN
)

video_file_extensions = set(["mp4", "avi", "gif", "mov", "webm"])

lycoris_defaults = {
Expand Down
4 changes: 4 additions & 0 deletions helpers/training/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
from helpers.training.wrappers import unwrap_model
from helpers.models.common import VideoModelFoundation, ImageModelFoundation
from helpers.models.common import ModelFoundation
try:
import pillow_jxl
except ModuleNotFoundError:
pass
from PIL import Image
from helpers.training.state_tracker import StateTracker
from helpers.models.common import PredictionTypes, PipelineTypes
Expand Down
4 changes: 4 additions & 0 deletions inference_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
from diffusers import AutoPipelineForText2Image
from torch import manual_seed, float16
import os
try:
import pillow_jxl
except ModuleNotFoundError:
pass
from PIL import Image, ImageDraw, ImageFont
from helpers.prompts import prompts

Expand Down
2 changes: 2 additions & 0 deletions install/apple/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ prodigy-plus-schedule-free = "^1.9.0"
imageio-ffmpeg = "^0.6.0"
imageio = {extras = ["pyav"], version = "^2.37.0"}

[tool.poetry.group.jxl.dependencies]
pillow-jxl-plugin = "^1.3.1"

[build-system]
requires = ["poetry-core"]
Expand Down
4 changes: 3 additions & 1 deletion install/rocm/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ huggingface-hub = "^0.29.1"
imageio-ffmpeg = "^0.6.0"
imageio = {extras = ["pyav"], version = "^2.37.0"}

[tool.poetry.group.jxl.dependencies]
pillow-jxl-plugin = "^1.3.1"

[build-system]
requires = ["poetry-core"]
Expand All @@ -58,4 +60,4 @@ build-backend = "poetry.core.masonry.api"
[[tool.poetry.source]]
#priority = "explicit"
name = "pytorch-rocm"
url = "https://download.pytorch.org/whl/test/rocm6.3"
url = "https://download.pytorch.org/whl/test/rocm6.3"
101 changes: 97 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ huggingface-hub = "^0.30.2"
imageio-ffmpeg = "^0.6.0"
imageio = {extras = ["pyav"], version = "^2.37.0"}


[tool.poetry.group.jxl.dependencies]
pillow-jxl-plugin = "^1.3.1"

[build-system]
requires = ["poetry-core", "setuptools", "wheel", "torch"]
Expand Down
4 changes: 4 additions & 0 deletions tests/test_dataset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import unittest
import pandas as pd
from unittest.mock import patch, Mock, MagicMock
try:
import pillow_jxl
except ModuleNotFoundError:
pass
from PIL import Image
from pathlib import Path
from helpers.multiaspect.dataset import MultiAspectDataset
Expand Down
4 changes: 4 additions & 0 deletions tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
logger.setLevel(os.environ.get("SIMPLETUNER_LOG_LEVEL", logging.INFO))
from unittest.mock import patch
from unittest.mock import Mock, MagicMock
try:
import pillow_jxl
except ModuleNotFoundError:
pass
from PIL import Image
from io import BytesIO
from helpers.multiaspect.image import MultiaspectImage
Expand Down
4 changes: 4 additions & 0 deletions tests/test_sampler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import unittest, os, logging
from math import ceil
try:
import pillow_jxl
except ModuleNotFoundError:
pass
from PIL import Image
from unittest import skip
from unittest.mock import Mock, MagicMock, patch
Expand Down
Loading