[diffusion] feat: make QwenImageLayered resolution configurable (#20044)
This commit is contained in:
@@ -436,6 +436,13 @@ class PipelineConfig:
|
||||
default=PipelineConfig.flow_shift,
|
||||
help="Flow shift parameter",
|
||||
)
|
||||
parser.add_argument(
|
||||
f"--{prefix_with_dot}resolution",
|
||||
type=int,
|
||||
dest=f"{prefix_with_dot.replace('-', '_')}resolution",
|
||||
default=None,
|
||||
help="Override the selected pipeline config's resolution setting. Only applies to pipelines that define a resolution field.",
|
||||
)
|
||||
|
||||
# DiT configuration
|
||||
parser.add_argument(
|
||||
|
||||
@@ -500,7 +500,7 @@ class QwenImageEditPlus_2511_PipelineConfig(QwenImageEditPlusPipelineConfig):
|
||||
|
||||
@dataclass
|
||||
class QwenImageLayeredPipelineConfig(QwenImageEditPipelineConfig):
|
||||
resolution: int = 640 # TODO: allow user to set resolution
|
||||
resolution: int = 640
|
||||
vae_precision: str = "bf16"
|
||||
|
||||
def _prepare_edit_cond_kwargs(
|
||||
|
||||
@@ -422,7 +422,7 @@ the image\n<|vision_start|><|image_pad|><|vision_end|><|im_end|>\n<|im_start|>as
|
||||
image = load_image(batch.image_path[0])
|
||||
image = image.convert("RGBA")
|
||||
image_size = image.size
|
||||
resolution = 640 # TODO: support user-specified resolution
|
||||
resolution = server_args.pipeline_config.resolution
|
||||
calculated_width, calculated_height = calculate_dimensions(
|
||||
resolution * resolution, image_size[0] / image_size[1]
|
||||
)
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from sglang.multimodal_gen.registry import _get_config_info
|
||||
from sglang.multimodal_gen.runtime.server_args import ServerArgs
|
||||
from sglang.multimodal_gen.utils import FlexibleArgumentParser
|
||||
|
||||
|
||||
class TestServerArgsPathExpansion(unittest.TestCase):
|
||||
@@ -46,5 +49,26 @@ class TestModelIdResolution(unittest.TestCase):
|
||||
_get_config_info("/data/no-such-model", model_id="NonExistentModelXYZ")
|
||||
|
||||
|
||||
class TestPipelineResolutionCliOverride(unittest.TestCase):
|
||||
def setUp(self):
|
||||
_get_config_info.cache_clear()
|
||||
|
||||
def test_resolution_flag_overrides_qwen_image_layered_pipeline_config(self):
|
||||
parser = FlexibleArgumentParser()
|
||||
ServerArgs.add_cli_args(parser)
|
||||
argv = [
|
||||
"--model-path",
|
||||
"Qwen/Qwen-Image-Layered",
|
||||
"--resolution",
|
||||
"768",
|
||||
]
|
||||
|
||||
with patch.object(sys, "argv", ["sglang"] + argv):
|
||||
args, unknown_args = parser.parse_known_args(argv)
|
||||
server_args = ServerArgs.from_cli_args(args, unknown_args)
|
||||
|
||||
self.assertEqual(server_args.pipeline_config.resolution, 768)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user