Skip to content

Commit ade9e02

Browse files
committed
feat(app): image_format call_input; support JXL
1 parent 0af324a commit ade9e02

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

api/app.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
from hashlib import sha256
3333
from threading import Timer
3434
import extras
35+
import jxlpy
36+
from jxlpy import JXLImagePlugin
3537

3638
from diffusers import (
3739
StableDiffusionXLPipeline,
@@ -649,9 +651,11 @@ def callback(step: int, timestep: int, latents: torch.FloatTensor):
649651
}
650652

651653
images_base64 = []
654+
image_format = call_inputs.get("image_format", "PNG")
655+
image_opts = { "lossless": True } if image_format == "PNG" else {}
652656
for image in images:
653657
buffered = BytesIO()
654-
image.save(buffered, format="PNG")
658+
image.save(buffered, format=image_format, **image_opts)
655659
images_base64.append(base64.b64encode(buffered.getvalue()).decode("utf-8"))
656660

657661
await send("inference", "done", {"startRequestId": startRequestId}, send_opts)

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ bitsandbytes==0.41.1 # was 0.40.2 until 2023-09-08
4040

4141
invisible-watermark==0.2.0 # released 2023-07-06
4242
compel==2.0.2 # was 2.0.1 until 2023-09-08
43+
jxlpy==0.9.2 # added 2023-09-11

0 commit comments

Comments
 (0)