[diffusion] feat: support multiple input images for generate mode (#15394)
Co-authored-by: 也渡 <fangxinlei.fxl@alibaba-inc.com>
This commit is contained in:
@@ -88,7 +88,7 @@ class SamplingParams:
|
|||||||
# All fields below are copied from ForwardBatch
|
# All fields below are copied from ForwardBatch
|
||||||
|
|
||||||
# Image inputs
|
# Image inputs
|
||||||
image_path: str | None = None
|
image_path: str | list[str] | None = None
|
||||||
|
|
||||||
# Text inputs
|
# Text inputs
|
||||||
prompt: str | list[str] | None = None
|
prompt: str | list[str] | None = None
|
||||||
@@ -541,8 +541,14 @@ class SamplingParams:
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--image-path",
|
"--image-path",
|
||||||
type=str,
|
type=str,
|
||||||
|
nargs="+",
|
||||||
default=SamplingParams.image_path,
|
default=SamplingParams.image_path,
|
||||||
help="Path to input image for image-to-video generation",
|
help=(
|
||||||
|
"Path(s) to input image(s) for image-to-image / image-to-video "
|
||||||
|
"generation. For multiple images, pass them as space-separated "
|
||||||
|
"values, e.g.: "
|
||||||
|
'--image-path "img1.png" "img2.png"'
|
||||||
|
),
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--moba-config-path",
|
"--moba-config-path",
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class Req:
|
|||||||
generator: torch.Generator | list[torch.Generator] | None = None
|
generator: torch.Generator | list[torch.Generator] | None = None
|
||||||
|
|
||||||
# Image inputs
|
# Image inputs
|
||||||
image_path: str | None = None
|
image_path: str | list[str] | None = None
|
||||||
# Image encoder hidden states
|
# Image encoder hidden states
|
||||||
image_embeds: list[torch.Tensor] = field(default_factory=list)
|
image_embeds: list[torch.Tensor] = field(default_factory=list)
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,54 @@ class TestQwenImageEdit(TestGenerateBase):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestQwenImageEditPlusMultiImageURL(TestGenerateBase):
|
||||||
|
"""CLI-level test for multi-image URL input with Qwen-Image-Edit."""
|
||||||
|
|
||||||
|
model_path = "Qwen/Qwen-Image-Edit-2509"
|
||||||
|
extra_args = []
|
||||||
|
data_type: DataType = DataType.IMAGE
|
||||||
|
|
||||||
|
thresholds = {
|
||||||
|
"test_single_gpu": 33.4 * 1.05,
|
||||||
|
}
|
||||||
|
|
||||||
|
prompt: str | None = (
|
||||||
|
"The magician bear is on the left, the alchemist bear is on the right, facing each other in the central park square."
|
||||||
|
)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp()
|
||||||
|
|
||||||
|
img_urls = [
|
||||||
|
"https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Image/edit2509/edit2509_1.jpg",
|
||||||
|
"https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Image/edit2509/edit2509_2.jpg",
|
||||||
|
]
|
||||||
|
|
||||||
|
self.base_command = [
|
||||||
|
"sglang",
|
||||||
|
"generate",
|
||||||
|
"--text-encoder-cpu-offload",
|
||||||
|
"--pin-cpu-memory",
|
||||||
|
"--prompt",
|
||||||
|
f"{self.prompt}",
|
||||||
|
"--save-output",
|
||||||
|
"--log-level=debug",
|
||||||
|
f"--width={self.width}",
|
||||||
|
f"--height={self.height}",
|
||||||
|
f"--output-path={self.output_path}",
|
||||||
|
]
|
||||||
|
self.base_command += [
|
||||||
|
"--image-path",
|
||||||
|
*img_urls,
|
||||||
|
]
|
||||||
|
|
||||||
|
def test_cfg_parallel(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_mixed(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
del TestGenerateBase
|
del TestGenerateBase
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user